diff --git a/tests/pipeline/load/exceptions/build.bst b/tests/frontend/exceptions/build.bst similarity index 100% rename from tests/pipeline/load/exceptions/build.bst rename to tests/frontend/exceptions/build.bst diff --git a/tests/pipeline/load/exceptions/first-level-1.bst b/tests/frontend/exceptions/first-level-1.bst similarity index 100% rename from tests/pipeline/load/exceptions/first-level-1.bst rename to tests/frontend/exceptions/first-level-1.bst diff --git a/tests/pipeline/load/exceptions/first-level-2.bst b/tests/frontend/exceptions/first-level-2.bst similarity index 100% rename from tests/pipeline/load/exceptions/first-level-2.bst rename to tests/frontend/exceptions/first-level-2.bst diff --git a/tests/pipeline/load/exceptions/fourth-level-1.bst b/tests/frontend/exceptions/fourth-level-1.bst similarity index 100% rename from tests/pipeline/load/exceptions/fourth-level-1.bst rename to tests/frontend/exceptions/fourth-level-1.bst diff --git a/tests/pipeline/load/exceptions/fourth-level-2.bst b/tests/frontend/exceptions/fourth-level-2.bst similarity index 100% rename from tests/pipeline/load/exceptions/fourth-level-2.bst rename to tests/frontend/exceptions/fourth-level-2.bst diff --git a/tests/pipeline/load/exceptions/fourth-level-3.bst b/tests/frontend/exceptions/fourth-level-3.bst similarity index 100% rename from tests/pipeline/load/exceptions/fourth-level-3.bst rename to tests/frontend/exceptions/fourth-level-3.bst diff --git a/tests/pipeline/load/exceptions/project.conf b/tests/frontend/exceptions/project.conf similarity index 100% rename from tests/pipeline/load/exceptions/project.conf rename to tests/frontend/exceptions/project.conf diff --git a/tests/pipeline/load/exceptions/second-level-1.bst b/tests/frontend/exceptions/second-level-1.bst similarity index 100% rename from tests/pipeline/load/exceptions/second-level-1.bst rename to tests/frontend/exceptions/second-level-1.bst diff --git a/tests/pipeline/load/exceptions/third-level-1.bst b/tests/frontend/exceptions/third-level-1.bst similarity index 100% rename from tests/pipeline/load/exceptions/third-level-1.bst rename to tests/frontend/exceptions/third-level-1.bst diff --git a/tests/pipeline/load/exceptions/third-level-2.bst b/tests/frontend/exceptions/third-level-2.bst similarity index 100% rename from tests/pipeline/load/exceptions/third-level-2.bst rename to tests/frontend/exceptions/third-level-2.bst diff --git a/tests/pipeline/load/exceptions/third-level-3.bst b/tests/frontend/exceptions/third-level-3.bst similarity index 100% rename from tests/pipeline/load/exceptions/third-level-3.bst rename to tests/frontend/exceptions/third-level-3.bst diff --git a/tests/pipeline/load/exceptions/unrelated-1.bst b/tests/frontend/exceptions/unrelated-1.bst similarity index 100% rename from tests/pipeline/load/exceptions/unrelated-1.bst rename to tests/frontend/exceptions/unrelated-1.bst diff --git a/tests/pipeline/load/exceptions/unrelated-2.bst b/tests/frontend/exceptions/unrelated-2.bst similarity index 100% rename from tests/pipeline/load/exceptions/unrelated-2.bst rename to tests/frontend/exceptions/unrelated-2.bst diff --git a/tests/frontend/show.py b/tests/frontend/show.py index 57f04e46df3ef8b7e16f6c711d8880cf0f7a759f..9c32dd6649bc50dc597dd29ab6731dbda97a8146 100644 --- a/tests/frontend/show.py +++ b/tests/frontend/show.py @@ -12,11 +12,10 @@ from . import configure_project # Project directory DATA_DIR = os.path.join( os.path.dirname(os.path.realpath(__file__)), - "project", ) -@pytest.mark.datafiles(DATA_DIR) +@pytest.mark.datafiles(os.path.join(DATA_DIR, 'project')) @pytest.mark.parametrize("target,format,expected", [ ('import-bin.bst', '%{name}', 'import-bin.bst'), ('import-bin.bst', '%{state}', 'buildable'), @@ -49,14 +48,14 @@ def test_show_invalid_element_path(cli, datafiles): result.assert_main_error(ErrorDomain.LOAD, LoadErrorReason.INVALID_DATA) -@pytest.mark.datafiles(DATA_DIR) +@pytest.mark.datafiles(os.path.join(DATA_DIR, 'project')) @pytest.mark.parametrize("target,except_,expected", [ ('target.bst', 'import-bin.bst', ['import-dev.bst', 'compose-all.bst', 'target.bst']), ('target.bst', 'import-dev.bst', ['import-bin.bst', 'compose-all.bst', 'target.bst']), ('target.bst', 'compose-all.bst', ['import-bin.bst', 'target.bst']), ('compose-all.bst', 'import-bin.bst', ['import-dev.bst', 'compose-all.bst']) ]) -def test_show_except(cli, datafiles, target, except_, expected): +def test_show_except_simple(cli, datafiles, target, except_, expected): project = os.path.join(datafiles.dirname, datafiles.basename) result = cli.run(project=project, silent=True, args=[ 'show', @@ -73,10 +72,88 @@ def test_show_except(cli, datafiles, target, except_, expected): .format(expected, results)) +# This test checks various constructions of a pipeline +# with one or more targets and 0 or more exception elements, +# each data set provides the targets, exceptions and expected +# result list. +# +@pytest.mark.datafiles(os.path.join(DATA_DIR, 'exceptions')) +@pytest.mark.parametrize("targets,exceptions,expected", [ + + # Test without exceptions, lets just see the whole list here + (['build.bst'], None, [ + 'fourth-level-1.bst', + 'third-level-1.bst', + 'fourth-level-2.bst', + 'third-level-2.bst', + 'fourth-level-3.bst', + 'third-level-3.bst', + 'second-level-1.bst', + 'first-level-1.bst', + 'first-level-2.bst', + 'build.bst', + ]), + + # Test one target and excepting a part of the pipeline, this + # removes forth-level-1 and third-level-1 + (['build.bst'], ['third-level-1.bst'], [ + 'fourth-level-2.bst', + 'third-level-2.bst', + 'fourth-level-3.bst', + 'third-level-3.bst', + 'second-level-1.bst', + 'first-level-1.bst', + 'first-level-2.bst', + 'build.bst', + ]), + + # Test one target and excepting a part of the pipeline, check that + # excepted dependencies remain in the pipeline if depended on from + # outside of the except element + (['build.bst'], ['second-level-1.bst'], [ + 'fourth-level-2.bst', + 'third-level-2.bst', # first-level-2 depends on this, so not excepted + 'first-level-1.bst', + 'first-level-2.bst', + 'build.bst', + ]), + + # The same as the above test, but excluding the toplevel build.bst, + # instead only select the two toplevel dependencies as targets + (['first-level-1.bst', 'first-level-2.bst'], ['second-level-1.bst'], [ + 'fourth-level-2.bst', + 'third-level-2.bst', # first-level-2 depends on this, so not excepted + 'first-level-1.bst', + 'first-level-2.bst', + ]), + + # Test one target and excepting an element outisde the pipeline + (['build.bst'], ['unrelated-1.bst'], [ + 'fourth-level-2.bst', + 'third-level-2.bst', # first-level-2 depends on this, so not excepted + 'first-level-1.bst', + 'first-level-2.bst', + 'build.bst', + ]), + + # Test one target and excepting two elements + (['build.bst'], ['unrelated-1.bst', 'unrelated-2.bst'], [ + 'first-level-1.bst', + 'build.bst', + ]), +]) +def test_show_except(cli, datafiles, targets, exceptions, expected): + basedir = os.path.join(datafiles.dirname, datafiles.basename) + results = cli.get_pipeline(basedir, targets, except_=exceptions, scope='all') + if results != expected: + raise AssertionError("Expected elements:\n{}\nInstead received elements:\n{}" + .format(expected, results)) + + ############################################################### # Testing multiple targets # ############################################################### -@pytest.mark.datafiles(DATA_DIR) +@pytest.mark.datafiles(os.path.join(DATA_DIR, 'project')) def test_parallel_order(cli, tmpdir, datafiles): project = os.path.join(datafiles.dirname, datafiles.basename) elements = ['multiple_targets/order/0.bst', @@ -105,7 +182,7 @@ def test_parallel_order(cli, tmpdir, datafiles): assert names in orderings, "We got: {}".format(", ".join(names)) -@pytest.mark.datafiles(DATA_DIR) +@pytest.mark.datafiles(os.path.join(DATA_DIR, 'project')) def test_target_is_dependency(cli, tmpdir, datafiles): project = os.path.join(datafiles.dirname, datafiles.basename) elements = ['multiple_targets/dependency/zebry.bst', @@ -123,7 +200,7 @@ def test_target_is_dependency(cli, tmpdir, datafiles): assert names == ['pony.bst', 'horsey.bst', 'zebry.bst'] -@pytest.mark.datafiles(DATA_DIR) +@pytest.mark.datafiles(os.path.join(DATA_DIR, 'project')) @pytest.mark.parametrize("ref_storage", [('inline'), ('project.refs')]) @pytest.mark.parametrize("element_name", ['junction-dep.bst', 'junction.bst:import-etc.bst']) def test_unfetched_junction(cli, tmpdir, datafiles, ref_storage, element_name): @@ -175,7 +252,7 @@ def test_unfetched_junction(cli, tmpdir, datafiles, ref_storage, element_name): result.assert_main_error(ErrorDomain.LOAD, LoadErrorReason.SUBPROJECT_FETCH_NEEDED) -@pytest.mark.datafiles(DATA_DIR) +@pytest.mark.datafiles(os.path.join(DATA_DIR, 'project')) @pytest.mark.parametrize("ref_storage", [('inline'), ('project.refs')]) @pytest.mark.parametrize("element_name", ['junction-dep.bst', 'junction.bst:import-etc.bst']) def test_inconsistent_junction(cli, tmpdir, datafiles, ref_storage, element_name): @@ -211,7 +288,7 @@ def test_inconsistent_junction(cli, tmpdir, datafiles, ref_storage, element_name result.assert_main_error(ErrorDomain.LOAD, LoadErrorReason.SUBPROJECT_INCONSISTENT) -@pytest.mark.datafiles(DATA_DIR) +@pytest.mark.datafiles(os.path.join(DATA_DIR, 'project')) @pytest.mark.parametrize("element_name", ['junction-dep.bst', 'junction.bst:import-etc.bst']) def test_fetched_junction(cli, tmpdir, datafiles, element_name): project = os.path.join(datafiles.dirname, datafiles.basename) diff --git a/tests/pipeline/load.py b/tests/pipeline/load.py index 29ceb6dde0f2768c4691c2ab4040c1fcf6aa1e8c..6a5dff7e48eb7cc53956d909239ceea7e6ab5268 100644 --- a/tests/pipeline/load.py +++ b/tests/pipeline/load.py @@ -108,85 +108,6 @@ def test_iterate_no_recurse(cli, datafiles): assert(element_list[6] == 'target.bst') -# This test checks various constructions of a pipeline -# with one or more targets and 0 or more exception elements, -# each data set provides the targets, exceptions and expected -# result list. -# -@pytest.mark.datafiles(os.path.join(DATA_DIR, 'exceptions')) -@pytest.mark.parametrize("elements,exceptions,results", [ - - # Test without exceptions, lets just see the whole list here - (['build.bst'], None, [ - 'fourth-level-1.bst', - 'third-level-1.bst', - 'fourth-level-2.bst', - 'third-level-2.bst', - 'fourth-level-3.bst', - 'third-level-3.bst', - 'second-level-1.bst', - 'first-level-1.bst', - 'first-level-2.bst', - 'build.bst', - ]), - - # Test one target and excepting a part of the pipeline, this - # removes forth-level-1 and third-level-1 - (['build.bst'], ['third-level-1.bst'], [ - 'fourth-level-2.bst', - 'third-level-2.bst', - 'fourth-level-3.bst', - 'third-level-3.bst', - 'second-level-1.bst', - 'first-level-1.bst', - 'first-level-2.bst', - 'build.bst', - ]), - - # Test one target and excepting a part of the pipeline, check that - # excepted dependencies remain in the pipeline if depended on from - # outside of the except element - (['build.bst'], ['second-level-1.bst'], [ - 'fourth-level-2.bst', - 'third-level-2.bst', # first-level-2 depends on this, so not excepted - 'first-level-1.bst', - 'first-level-2.bst', - 'build.bst', - ]), - - # The same as the above test, but excluding the toplevel build.bst, - # instead only select the two toplevel dependencies as targets - (['first-level-1.bst', 'first-level-2.bst'], ['second-level-1.bst'], [ - 'fourth-level-2.bst', - 'third-level-2.bst', # first-level-2 depends on this, so not excepted - 'first-level-1.bst', - 'first-level-2.bst', - ]), - - # Test one target and excepting an element outisde the pipeline - (['build.bst'], ['unrelated-1.bst'], [ - 'fourth-level-2.bst', - 'third-level-2.bst', # first-level-2 depends on this, so not excepted - 'first-level-1.bst', - 'first-level-2.bst', - 'build.bst', - ]), - - # Test one target and excepting two elements - (['build.bst'], ['unrelated-1.bst', 'unrelated-2.bst'], [ - 'first-level-1.bst', - 'build.bst', - ]), -]) -def test_except_elements(cli, datafiles, elements, exceptions, results): - basedir = os.path.join(datafiles.dirname, datafiles.basename) - - # Except second-level-2 and check that the correct dependencies - # are removed. - element_list = cli.get_pipeline(basedir, elements, except_=exceptions, scope='all') - assert element_list == results - - @pytest.mark.datafiles(os.path.join(DATA_DIR, 'noloadref')) @pytest.mark.parametrize("ref_storage", [('inline'), ('project.refs')]) def test_unsupported_load_ref(cli, datafiles, ref_storage):