diff options
author | Tristan Van Berkom <tristan.vanberkom@codethink.co.uk> | 2019-01-11 13:45:16 -0500 |
---|---|---|
committer | Tristan Van Berkom <tristan.vanberkom@codethink.co.uk> | 2019-01-16 18:35:21 -0500 |
commit | 1eafc25c7a1841d0c43425bba0f078e0aa686eb0 (patch) | |
tree | a727ccaa229a580ab23105666fc70a840ec35a5b | |
parent | 5ea2f59d64ed0b5bf521c925247ffc90175be711 (diff) | |
download | buildstream-1eafc25c7a1841d0c43425bba0f078e0aa686eb0.tar.gz |
tests: Migrate `--except` testing to tests/frontend/show.py
The tests/pipeline directory will be removed, and this test
is the better of the two but also redundant with the one in
tests/frontend/show.
Renamed existing test in show.py to `test_show_except_simple`
and added the better test as `test_show_except` below it.
-rw-r--r-- | tests/frontend/exceptions/build.bst (renamed from tests/pipeline/load/exceptions/build.bst) | 0 | ||||
-rw-r--r-- | tests/frontend/exceptions/first-level-1.bst (renamed from tests/pipeline/load/exceptions/first-level-1.bst) | 0 | ||||
-rw-r--r-- | tests/frontend/exceptions/first-level-2.bst (renamed from tests/pipeline/load/exceptions/first-level-2.bst) | 0 | ||||
-rw-r--r-- | tests/frontend/exceptions/fourth-level-1.bst (renamed from tests/pipeline/load/exceptions/fourth-level-1.bst) | 0 | ||||
-rw-r--r-- | tests/frontend/exceptions/fourth-level-2.bst (renamed from tests/pipeline/load/exceptions/fourth-level-2.bst) | 0 | ||||
-rw-r--r-- | tests/frontend/exceptions/fourth-level-3.bst (renamed from tests/pipeline/load/exceptions/fourth-level-3.bst) | 0 | ||||
-rw-r--r-- | tests/frontend/exceptions/project.conf (renamed from tests/pipeline/load/exceptions/project.conf) | 0 | ||||
-rw-r--r-- | tests/frontend/exceptions/second-level-1.bst (renamed from tests/pipeline/load/exceptions/second-level-1.bst) | 0 | ||||
-rw-r--r-- | tests/frontend/exceptions/third-level-1.bst (renamed from tests/pipeline/load/exceptions/third-level-1.bst) | 0 | ||||
-rw-r--r-- | tests/frontend/exceptions/third-level-2.bst (renamed from tests/pipeline/load/exceptions/third-level-2.bst) | 0 | ||||
-rw-r--r-- | tests/frontend/exceptions/third-level-3.bst (renamed from tests/pipeline/load/exceptions/third-level-3.bst) | 0 | ||||
-rw-r--r-- | tests/frontend/exceptions/unrelated-1.bst (renamed from tests/pipeline/load/exceptions/unrelated-1.bst) | 0 | ||||
-rw-r--r-- | tests/frontend/exceptions/unrelated-2.bst (renamed from tests/pipeline/load/exceptions/unrelated-2.bst) | 0 | ||||
-rw-r--r-- | tests/frontend/show.py | 95 | ||||
-rw-r--r-- | tests/pipeline/load.py | 79 |
15 files changed, 86 insertions, 88 deletions
diff --git a/tests/pipeline/load/exceptions/build.bst b/tests/frontend/exceptions/build.bst index d0c5e2138..d0c5e2138 100644 --- a/tests/pipeline/load/exceptions/build.bst +++ b/tests/frontend/exceptions/build.bst diff --git a/tests/pipeline/load/exceptions/first-level-1.bst b/tests/frontend/exceptions/first-level-1.bst index 3c870b7bc..3c870b7bc 100644 --- a/tests/pipeline/load/exceptions/first-level-1.bst +++ b/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 index fd7ac1704..fd7ac1704 100644 --- a/tests/pipeline/load/exceptions/first-level-2.bst +++ b/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 index 531378acc..531378acc 100644 --- a/tests/pipeline/load/exceptions/fourth-level-1.bst +++ b/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 index e0d34d70e..e0d34d70e 100644 --- a/tests/pipeline/load/exceptions/fourth-level-2.bst +++ b/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 index 6812e2fa1..6812e2fa1 100644 --- a/tests/pipeline/load/exceptions/fourth-level-3.bst +++ b/tests/frontend/exceptions/fourth-level-3.bst diff --git a/tests/pipeline/load/exceptions/project.conf b/tests/frontend/exceptions/project.conf index 2027cc27a..2027cc27a 100644 --- a/tests/pipeline/load/exceptions/project.conf +++ b/tests/frontend/exceptions/project.conf diff --git a/tests/pipeline/load/exceptions/second-level-1.bst b/tests/frontend/exceptions/second-level-1.bst index 3183e670b..3183e670b 100644 --- a/tests/pipeline/load/exceptions/second-level-1.bst +++ b/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 index 960419d68..960419d68 100644 --- a/tests/pipeline/load/exceptions/third-level-1.bst +++ b/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 index 067e6f95a..067e6f95a 100644 --- a/tests/pipeline/load/exceptions/third-level-2.bst +++ b/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 index 56fbe5586..56fbe5586 100644 --- a/tests/pipeline/load/exceptions/third-level-3.bst +++ b/tests/frontend/exceptions/third-level-3.bst diff --git a/tests/pipeline/load/exceptions/unrelated-1.bst b/tests/frontend/exceptions/unrelated-1.bst index 10de373ca..10de373ca 100644 --- a/tests/pipeline/load/exceptions/unrelated-1.bst +++ b/tests/frontend/exceptions/unrelated-1.bst diff --git a/tests/pipeline/load/exceptions/unrelated-2.bst b/tests/frontend/exceptions/unrelated-2.bst index f90b755a5..f90b755a5 100644 --- a/tests/pipeline/load/exceptions/unrelated-2.bst +++ b/tests/frontend/exceptions/unrelated-2.bst diff --git a/tests/frontend/show.py b/tests/frontend/show.py index 57f04e46d..9c32dd664 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 29ceb6dde..6a5dff7e4 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): |