Skip to content
Merged
Changes from 5 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
26 changes: 18 additions & 8 deletions cylc/flow/scripts/cylc.py
Original file line number Diff line number Diff line change
Expand Up @@ -582,7 +582,11 @@ def pycoverage(cmd_args): # pragma: no cover
from pathlib import Path

# 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]
print(f'START: {sys.argv[1:]}', file=sys.stderr)

# initiate coverage
try:
Expand All @@ -604,13 +608,9 @@ 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):
print(f'STOP: {sys.argv[1:]}', file=sys.stderr)
cov.stop()
cov.save()
if cylc_coverage == '2':
Expand All @@ -619,6 +619,16 @@ def pycoverage(cmd_args): # pragma: no cover
'$ cylc ' + (' '.join(cmd_args) + '\n'),
)

# start the coverage running
cov.start()
import signal
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