Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 16 additions & 8 deletions cylc/flow/scripts/cylc.py
Original file line number Diff line number Diff line change
Expand Up @@ -580,9 +580,13 @@ def pycoverage(cmd_args): # pragma: no cover
import cylc.flow
import coverage
from pathlib import Path
import signal

# the cylc working directory
cylc_wc = Path(cylc.flow.__file__).parents[2]
if 'CYLC_COVERAGE_BASE' in os.environ:
cylc_wc = Path(os.environ['CYLC_COVERAGE_BASE'])
else:
cylc_wc = Path(cylc.flow.__file__).parents[2]

# initiate coverage
try:
Expand All @@ -604,13 +608,7 @@ def pycoverage(cmd_args): # pragma: no cover
'\n\n*****************************\n\n'
) from exc

# start the coverage running
cov.start()
try:
# yield control back to cylc, return once the command exits
yield
finally:
# stop the coverage and save the data
def cov_stop(*a, **k):
cov.stop()
cov.save()
if cylc_coverage == '2':
Expand All @@ -619,6 +617,16 @@ def pycoverage(cmd_args): # pragma: no cover
'$ cylc ' + (' '.join(cmd_args) + '\n'),
)

# start the coverage running
cov.start()
signal.signal(signal.SIGINT, cov_stop)
try:
# yield control back to cylc, return once the command exits
yield
finally:
# stop the coverage and save the data
cov_stop()


def get_arg_parser():
parser = argparse.ArgumentParser(add_help=False)
Expand Down
Loading