Skip to content

Commit

Permalink
Merge pull request #169 from wxtim/do_not_cleanup_failed_functional_t…
Browse files Browse the repository at this point in the history
…ests

functional tests only cleanup if succeeded
  • Loading branch information
oliver-sanders authored Aug 16, 2022
2 parents a0d9b65 + 8bdf184 commit 0e7a5a9
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 25 deletions.
7 changes: 4 additions & 3 deletions tests/functional/test_ROSE_ORIG_HOST.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def monkeymodule():


@pytest.fixture(scope='module')
def fixture_provide_flow(tmp_path_factory):
def fixture_provide_flow(tmp_path_factory, request):
"""Provide a cylc workflow based on the contents of a folder which can
be either validated or installed.
"""
Expand All @@ -99,8 +99,9 @@ def fixture_provide_flow(tmp_path_factory):
'flowpath': flowpath,
'srcpath': srcpath
}
shutil.rmtree(srcpath)
shutil.rmtree(flowpath)
if not request.session.testsfailed:
shutil.rmtree(srcpath)
shutil.rmtree(flowpath)


@pytest.fixture(scope='module')
Expand Down
12 changes: 7 additions & 5 deletions tests/functional/test_reinstall.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def monkeymodule():


@pytest.fixture(scope='module')
def fixture_provide_flow(tmp_path_factory):
def fixture_provide_flow(tmp_path_factory, request):
"""Provide a cylc workflow based on the contents of a folder which can
be either validated or installed.
"""
Expand All @@ -71,8 +71,9 @@ def fixture_provide_flow(tmp_path_factory):
'flowpath': flowpath,
'srcpath': srcpath
}
shutil.rmtree(srcpath)
shutil.rmtree(flowpath)
if not request.session.testsfailed:
shutil.rmtree(srcpath)
shutil.rmtree(flowpath)


@pytest.fixture(scope='module')
Expand Down Expand Up @@ -251,7 +252,7 @@ def test_cylc_reinstall_files2(fixture_reinstall_flow2, file_, expect):
assert (fpath / file_).read_text() == expect


def test_cylc_reinstall_fail_on_clashing_template_vars(tmp_path):
def test_cylc_reinstall_fail_on_clashing_template_vars(tmp_path, request):
"""If you re-install with a different templating engine in suite.rc
reinstall should fail.
"""
Expand Down Expand Up @@ -282,4 +283,5 @@ def test_cylc_reinstall_fail_on_clashing_template_vars(tmp_path):
in reinstall.stderr.decode()
)
# Clean up run dir:
shutil.rmtree(get_workflow_run_dir(test_flow_name))
if not request.session.testsfailed:
shutil.rmtree(get_workflow_run_dir(test_flow_name))
7 changes: 4 additions & 3 deletions tests/functional/test_reinstall_clean.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def monkeymodule():


@pytest.fixture(scope='module')
def fixture_provide_flow(tmp_path_factory):
def fixture_provide_flow(tmp_path_factory, request):
"""Provide a cylc workflow based on the contents of a folder which can
be either validated or installed.
"""
Expand All @@ -71,8 +71,9 @@ def fixture_provide_flow(tmp_path_factory):
'flowpath': flowpath,
'srcpath': srcpath
}
shutil.rmtree(srcpath)
shutil.rmtree(flowpath)
if not request.session.testsfailed:
shutil.rmtree(srcpath)
shutil.rmtree(flowpath)


@pytest.fixture(scope='module')
Expand Down
7 changes: 4 additions & 3 deletions tests/functional/test_reinstall_fileinstall.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@


@pytest.fixture(scope='module')
def fixture_provide_flow(tmp_path_factory):
def fixture_provide_flow(tmp_path_factory, request):
"""Provide a cylc workflow based on the contents of a folder which can
be either validated or installed.
"""
Expand All @@ -46,8 +46,9 @@ def fixture_provide_flow(tmp_path_factory):
'flowpath': flowpath,
'srcpath': srcpath
}
shutil.rmtree(srcpath)
shutil.rmtree(flowpath)
if not request.session.testsfailed:
shutil.rmtree(srcpath)
shutil.rmtree(flowpath)


def test_install_flow(fixture_provide_flow):
Expand Down
8 changes: 4 additions & 4 deletions tests/functional/test_rose_fileinstall.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def fixture_provide_flow(tmp_path):


@pytest.fixture
def fixture_install_flow(fixture_provide_flow):
def fixture_install_flow(fixture_provide_flow, request):
srcpath, datapath, flow_name = fixture_provide_flow
result = subprocess.run(
['cylc', 'install', '--workflow-name', flow_name, f'{str(srcpath)}'],
Expand All @@ -67,8 +67,8 @@ def fixture_install_flow(fixture_provide_flow):
destpath = Path(get_workflow_run_dir(flow_name))

yield srcpath, datapath, flow_name, result, destpath

shutil.rmtree(destpath)
if not request.session.testsfailed:
shutil.rmtree(destpath)


def test_rose_fileinstall_validate(fixture_provide_flow):
Expand All @@ -94,7 +94,7 @@ def test_rose_fileinstall_subfolders(fixture_install_flow):


def test_rose_fileinstall_concatenation(fixture_install_flow):
"""Multiple files concatenated on install (source contained wildcard):
"""Multiple files concatenated on install(source contained wildcard):
"""
_, datapath, _, _, destpath = fixture_install_flow
assert ((destpath / 'runN/data').read_text() ==
Expand Down
5 changes: 1 addition & 4 deletions tests/functional/test_rose_stem.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,10 +173,7 @@ def setup_stem_repo(tmp_path_factory, monkeymodule, request):
'suite_install_dir': suite_install_dir
}
# Only clean up if all went well.
if all([
i.outcome == 'passed' or i.outcome == 'skipped'
for i in request.node.obj._module_outcomes.values()
]):
if not request.session.testsfailed:
shutil.rmtree(suite_install_dir)


Expand Down
6 changes: 3 additions & 3 deletions tests/unit/test_rose_opts.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def fixture_provide_flow(tmp_path_factory):


@pytest.fixture(scope='module')
def fixture_install_flow(fixture_provide_flow):
def fixture_install_flow(fixture_provide_flow, request):
srcpath, datapath, flow_name = fixture_provide_flow
cmd = shlex.split(
f'cylc install --workflow-name {flow_name} {str(srcpath)} '
Expand All @@ -72,8 +72,8 @@ def fixture_install_flow(fixture_provide_flow):
destpath = Path(get_workflow_run_dir(flow_name))

yield srcpath, datapath, flow_name, result, destpath

shutil.rmtree(destpath)
if not request.session.testsfailed:
shutil.rmtree(destpath)


def test_rose_fileinstall_validate(fixture_provide_flow):
Expand Down

0 comments on commit 0e7a5a9

Please sign in to comment.