diff options
author | Tristan Van Berkom <tristan.vanberkom@codethink.co.uk> | 2017-11-18 18:46:22 +0900 |
---|---|---|
committer | Tristan Van Berkom <tristan.vanberkom@codethink.co.uk> | 2017-11-18 18:57:43 +0900 |
commit | 0214e4c5be01412466c19be83e6b97bc0a441f26 (patch) | |
tree | 986c943ed19ce36b1ce0ef1b608803a67247b06b /tests | |
parent | 5458a9251cc70373d13f25e3f6dc2fd9dfe75d03 (diff) | |
download | buildstream-0214e4c5be01412466c19be83e6b97bc0a441f26.tar.gz |
tests/pipeline/load.py: Enhanced and added test cases for exceptions
Make this into a single paramaterized test case and test a few more
combinations:
o Ensure that excepting works with multiple targets in play
o Ensure that multiple exceptions succeed in excepting the commonly
depended elements which are otherwise referred to by the target
Diffstat (limited to 'tests')
-rw-r--r-- | tests/pipeline/load.py | 103 | ||||
-rw-r--r-- | tests/pipeline/load/exceptions/build.bst (renamed from tests/pipeline/load/remove/build.bst) | 0 | ||||
-rw-r--r-- | tests/pipeline/load/exceptions/first-level-1.bst (renamed from tests/pipeline/load/remove/first-level-1.bst) | 0 | ||||
-rw-r--r-- | tests/pipeline/load/exceptions/first-level-2.bst (renamed from tests/pipeline/load/remove/first-level-2.bst) | 0 | ||||
-rw-r--r-- | tests/pipeline/load/exceptions/fourth-level-1.bst (renamed from tests/pipeline/load/remove/fourth-level-1.bst) | 0 | ||||
-rw-r--r-- | tests/pipeline/load/exceptions/fourth-level-2.bst (renamed from tests/pipeline/load/remove/fourth-level-2.bst) | 0 | ||||
-rw-r--r-- | tests/pipeline/load/exceptions/project.conf (renamed from tests/pipeline/load/remove/project.conf) | 0 | ||||
-rw-r--r-- | tests/pipeline/load/exceptions/second-level-1.bst (renamed from tests/pipeline/load/remove/second-level-1.bst) | 0 | ||||
-rw-r--r-- | tests/pipeline/load/exceptions/third-level-1.bst (renamed from tests/pipeline/load/remove/third-level-1.bst) | 0 | ||||
-rw-r--r-- | tests/pipeline/load/exceptions/third-level-2.bst (renamed from tests/pipeline/load/remove/third-level-2.bst) | 0 | ||||
-rw-r--r-- | tests/pipeline/load/exceptions/unrelated-1.bst (renamed from tests/pipeline/load/remove/unrelated.bst) | 0 | ||||
-rw-r--r-- | tests/pipeline/load/exceptions/unrelated-2.bst | 4 |
12 files changed, 73 insertions, 34 deletions
diff --git a/tests/pipeline/load.py b/tests/pipeline/load.py index cc818dc3b..80a366a6b 100644 --- a/tests/pipeline/load.py +++ b/tests/pipeline/load.py @@ -112,41 +112,76 @@ def test_iterate_no_recurse(cli, datafiles, tmpdir): assert(element_list[6] == 'target.bst') -############################################################### -# Testing element removal # -############################################################### -@pytest.mark.datafiles(os.path.join(DATA_DIR, 'remove')) -def test_remove_elements(cli, datafiles, tmpdir): +# 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', + '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', + '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, tmpdir, elements, exceptions, results): basedir = os.path.join(datafiles.dirname, datafiles.basename) - elements = ['build.bst'] - except_ = ['second-level-1.bst'] # Except second-level-2 and check that the correct dependencies # are removed. - element_list = cli.get_pipeline(basedir, elements, except_=except_, scope='all') - - assert(element_list[0] == 'fourth-level-2.bst') - assert(element_list[1] == 'third-level-2.bst') - assert(element_list[2] == 'first-level-1.bst') - assert(element_list[3] == 'first-level-2.bst') - assert(element_list[4] == 'build.bst') - - -@pytest.mark.datafiles(os.path.join(DATA_DIR, 'remove')) -def test_remove_unrelated_element(cli, datafiles, tmpdir): - basedir = os.path.join(datafiles.dirname, datafiles.basename) - elements = ['build.bst'] - except_ = ['unrelated.bst'] - - # Ensure that we don't just except the given element, but the - # first row of intersection elements, while still including things - # that are accessible through another route. - element_list = cli.get_pipeline(basedir, elements, except_=except_, scope='all') - - assert(len(element_list) == 5) - - assert(element_list[0] == 'fourth-level-2.bst') - assert(element_list[1] == 'third-level-2.bst') - assert(element_list[2] == 'first-level-1.bst') - assert(element_list[3] == 'first-level-2.bst') - assert(element_list[4] == 'build.bst') + element_list = cli.get_pipeline(basedir, elements, except_=exceptions, scope='all') + assert element_list == results diff --git a/tests/pipeline/load/remove/build.bst b/tests/pipeline/load/exceptions/build.bst index d0c5e2138..d0c5e2138 100644 --- a/tests/pipeline/load/remove/build.bst +++ b/tests/pipeline/load/exceptions/build.bst diff --git a/tests/pipeline/load/remove/first-level-1.bst b/tests/pipeline/load/exceptions/first-level-1.bst index 3c870b7bc..3c870b7bc 100644 --- a/tests/pipeline/load/remove/first-level-1.bst +++ b/tests/pipeline/load/exceptions/first-level-1.bst diff --git a/tests/pipeline/load/remove/first-level-2.bst b/tests/pipeline/load/exceptions/first-level-2.bst index fd7ac1704..fd7ac1704 100644 --- a/tests/pipeline/load/remove/first-level-2.bst +++ b/tests/pipeline/load/exceptions/first-level-2.bst diff --git a/tests/pipeline/load/remove/fourth-level-1.bst b/tests/pipeline/load/exceptions/fourth-level-1.bst index 531378acc..531378acc 100644 --- a/tests/pipeline/load/remove/fourth-level-1.bst +++ b/tests/pipeline/load/exceptions/fourth-level-1.bst diff --git a/tests/pipeline/load/remove/fourth-level-2.bst b/tests/pipeline/load/exceptions/fourth-level-2.bst index e0d34d70e..e0d34d70e 100644 --- a/tests/pipeline/load/remove/fourth-level-2.bst +++ b/tests/pipeline/load/exceptions/fourth-level-2.bst diff --git a/tests/pipeline/load/remove/project.conf b/tests/pipeline/load/exceptions/project.conf index 2027cc27a..2027cc27a 100644 --- a/tests/pipeline/load/remove/project.conf +++ b/tests/pipeline/load/exceptions/project.conf diff --git a/tests/pipeline/load/remove/second-level-1.bst b/tests/pipeline/load/exceptions/second-level-1.bst index bd45ef344..bd45ef344 100644 --- a/tests/pipeline/load/remove/second-level-1.bst +++ b/tests/pipeline/load/exceptions/second-level-1.bst diff --git a/tests/pipeline/load/remove/third-level-1.bst b/tests/pipeline/load/exceptions/third-level-1.bst index 960419d68..960419d68 100644 --- a/tests/pipeline/load/remove/third-level-1.bst +++ b/tests/pipeline/load/exceptions/third-level-1.bst diff --git a/tests/pipeline/load/remove/third-level-2.bst b/tests/pipeline/load/exceptions/third-level-2.bst index 067e6f95a..067e6f95a 100644 --- a/tests/pipeline/load/remove/third-level-2.bst +++ b/tests/pipeline/load/exceptions/third-level-2.bst diff --git a/tests/pipeline/load/remove/unrelated.bst b/tests/pipeline/load/exceptions/unrelated-1.bst index 10de373ca..10de373ca 100644 --- a/tests/pipeline/load/remove/unrelated.bst +++ b/tests/pipeline/load/exceptions/unrelated-1.bst diff --git a/tests/pipeline/load/exceptions/unrelated-2.bst b/tests/pipeline/load/exceptions/unrelated-2.bst new file mode 100644 index 000000000..f90b755a5 --- /dev/null +++ b/tests/pipeline/load/exceptions/unrelated-2.bst @@ -0,0 +1,4 @@ +kind: autotools +description: Unrelated to the rest of the pipeline, not loaded when targeting build.bst +depends: + - first-level-2.bst |