diff options
author | Tristan Van Berkom <tristan.vanberkom@codethink.co.uk> | 2017-09-22 12:16:14 +0900 |
---|---|---|
committer | Tristan Van Berkom <tristan.vanberkom@codethink.co.uk> | 2017-10-08 17:03:36 +0900 |
commit | e1df2e2d0a33667993c9800ca567b755037704a0 (patch) | |
tree | 705d3ae22a7e3d01abac663a118f77c550fae700 /tests | |
parent | eab5a8805da0a11ddbd16555eb90bd21421b3478 (diff) | |
download | buildstream-e1df2e2d0a33667993c9800ca567b755037704a0.tar.gz |
Removing variant tests
Diffstat (limited to 'tests')
23 files changed, 0 insertions, 545 deletions
diff --git a/tests/loader/variants.py b/tests/loader/variants.py deleted file mode 100644 index 6fe28c08d..000000000 --- a/tests/loader/variants.py +++ /dev/null @@ -1,354 +0,0 @@ -import os -import pytest - -from buildstream import LoadError, LoadErrorReason -from buildstream._loader import Loader -from buildstream._metaelement import MetaElement - -DATA_DIR = os.path.join( - os.path.dirname(os.path.realpath(__file__)), - 'variants', -) - - -############################################################## -# Test Basic Failure Modes # -############################################################## -@pytest.mark.datafiles(DATA_DIR) -def test_variant_not_list(datafiles): - - basedir = os.path.join(datafiles.dirname, datafiles.basename) - loader = Loader(basedir, 'elements/variants-not-list.bst', None, None, None, []) - - with pytest.raises(LoadError) as exc: - element = loader.load() - - assert (exc.value.reason == LoadErrorReason.INVALID_DATA) - - -@pytest.mark.datafiles(DATA_DIR) -def test_variant_unnamed(datafiles): - - basedir = os.path.join(datafiles.dirname, datafiles.basename) - loader = Loader(basedir, 'elements/unnamed-variant.bst', None, None, None, []) - - with pytest.raises(LoadError) as exc: - element = loader.load() - - assert (exc.value.reason == LoadErrorReason.INVALID_DATA) - - -@pytest.mark.datafiles(DATA_DIR) -def test_variant_bad_name(datafiles): - - basedir = os.path.join(datafiles.dirname, datafiles.basename) - loader = Loader(basedir, 'elements/variant-bad-name.bst', None, None, None, []) - - with pytest.raises(LoadError) as exc: - element = loader.load() - - assert (exc.value.reason == LoadErrorReason.INVALID_DATA) - - -@pytest.mark.datafiles(DATA_DIR) -def test_variant_only_one(datafiles): - - basedir = os.path.join(datafiles.dirname, datafiles.basename) - loader = Loader(basedir, 'elements/only-one-variant.bst', None, None, None, []) - - with pytest.raises(LoadError) as exc: - element = loader.load() - - assert (exc.value.reason == LoadErrorReason.INVALID_DATA) - - -@pytest.mark.datafiles(DATA_DIR) -def test_variant_illegal_composite(datafiles): - - basedir = os.path.join(datafiles.dirname, datafiles.basename) - loader = Loader( - basedir, 'elements/variant-illegal-composite.bst', None, None, None, []) - - with pytest.raises(LoadError) as exc: - element = loader.load() - - assert (exc.value.reason == LoadErrorReason.ILLEGAL_COMPOSITE) - - -############################################################## -# Test Invalid Variant Requests # -############################################################## -@pytest.mark.datafiles(DATA_DIR) -def test_variant_invalid_target(datafiles): - - # Test that an invalid variant requested as the pipeline target raises the appropriate error - basedir = os.path.join(datafiles.dirname, datafiles.basename) - loader = Loader( - basedir, 'elements/simple-variant-compositing.bst', 'green', None, None, []) - - with pytest.raises(LoadError) as exc: - element = loader.load() - - assert (exc.value.reason == LoadErrorReason.INVALID_VARIANT) - - -@pytest.mark.datafiles(DATA_DIR) -def test_variant_invalid_dependency(datafiles): - - # Test that an invalid variant requested as an element dependency raises the appropriate error - basedir = os.path.join(datafiles.dirname, datafiles.basename) - loader = Loader( - basedir, 'elements/simple-variant-invalid.bst', None, None, None, []) - - with pytest.raises(LoadError) as exc: - element = loader.load() - - assert (exc.value.reason == LoadErrorReason.INVALID_VARIANT) - - -@pytest.mark.datafiles(DATA_DIR) -def test_variant_invalid_unused_dependency(datafiles): - - # Test that an invalid variant requested as an element dependency which is - # unused in the effective variant resolution still raises the appropriate - # error (ensure that errors occur even on unused variant paths) - basedir = os.path.join(datafiles.dirname, datafiles.basename) - loader = Loader( - basedir, 'elements/simple-unused-variant-invalid.bst', 'blue', None, None, []) - - with pytest.raises(LoadError) as exc: - element = loader.load() - - assert (exc.value.reason == LoadErrorReason.INVALID_VARIANT) - - -############################################################## -# Test Variant Default and Priority # -############################################################## -@pytest.mark.datafiles(DATA_DIR) -def test_variant_default_target(datafiles): - - # Assert that the default (first) variant is chosen for a toplevel target with variants. - basedir = os.path.join(datafiles.dirname, datafiles.basename) - loader = Loader( - basedir, 'elements/simple-variant-compositing.bst', None, None, None, []) - - element = loader.load() - assert(element.variant == 'pink') - - -@pytest.mark.datafiles(DATA_DIR) -def test_variant_default_dependency(datafiles): - - # Assert that the default (first) variant is chosen for a dependency of a toplevel - basedir = os.path.join(datafiles.dirname, datafiles.basename) - loader = Loader( - basedir, 'elements/depends-on-element-with-variants.bst', None, None, None, []) - - element = loader.load() - dependency = element.dependencies[0] - assert(dependency.variant == 'pink') - - -############################################################## -# Test Simple Variant Compositing # -############################################################## -@pytest.mark.datafiles(DATA_DIR) -def test_variant_simple_composite_default(datafiles): - - basedir = os.path.join(datafiles.dirname, datafiles.basename) - loader = Loader( - basedir, 'elements/simple-variant-compositing.bst', None, None, None, []) - - element = loader.load() - - assert(isinstance(element, MetaElement)) - assert(element.kind == 'pony') - - # Without specifying a variant, the default (first) should have been chosen - assert(element.config.get('somedata') == 5) - assert(element.config.get('pony-color') == 'pink') - - -@pytest.mark.datafiles(DATA_DIR) -def test_variant_simple_composite_pink_pony(datafiles): - - basedir = os.path.join(datafiles.dirname, datafiles.basename) - loader = Loader( - basedir, 'elements/simple-variant-compositing.bst', 'pink', None, None, []) - - element = loader.load() - - assert(isinstance(element, MetaElement)) - assert(element.kind == 'pony') - - # We explicitly asked for the pink variation of this pony - assert(element.config.get('somedata') == 5) - assert(element.config.get('pony-color') == 'pink') - - -@pytest.mark.datafiles(DATA_DIR) -def test_variant_simple_composite_blue_pony(datafiles): - - basedir = os.path.join(datafiles.dirname, datafiles.basename) - loader = Loader( - basedir, 'elements/simple-variant-compositing.bst', 'blue', None, None, []) - - element = loader.load() - - assert(isinstance(element, MetaElement)) - assert(element.kind == 'pony') - - # We explicitly asked for the blue variation of this pony, - # which has the side effect of overriding the value of 'somedata' - assert(element.config.get('somedata') == 6) - assert(element.config.get('pony-color') == 'blue') - - -############################################################## -# Test Variant Dependency Plotting # -############################################################## -# -# Convenience for asserting dependencies -# -def assert_dependency(element, index, name, key, value): - - # Test that the dependency we got is the pink color by default - assert(len(element.dependencies) >= index + 1) - dep = element.dependencies[index] - - assert(isinstance(dep, MetaElement)) - assert(dep.name == name) - assert(isinstance(dep.config, dict)) - assert(dep.config.get(key) == value) - - return dep - - -@pytest.mark.datafiles(DATA_DIR) -def test_variant_simple_dependency_default(datafiles): - - basedir = os.path.join(datafiles.dirname, datafiles.basename) - loader = Loader( - basedir, 'elements/simple-dependency-variants.bst', None, None, None, []) - element = loader.load() - - assert(isinstance(element, MetaElement)) - assert(element.kind == 'pony') - - # Test that the default is a pink pony - assert_dependency(element, 0, 'elements/simply-pink.bst', 'color', 'pink') - - -@pytest.mark.datafiles(DATA_DIR) -def test_variant_simple_dependency_pink_pony(datafiles): - - basedir = os.path.join(datafiles.dirname, datafiles.basename) - loader = Loader( - basedir, 'elements/simple-dependency-variants.bst', 'pink', None, None, []) - element = loader.load() - - assert(isinstance(element, MetaElement)) - assert(element.kind == 'pony') - - # Test that the explicit pink dependency is correct - assert_dependency(element, 0, 'elements/simply-pink.bst', 'color', 'pink') - - -@pytest.mark.datafiles(DATA_DIR) -def test_variant_simple_dependency_blue_pony(datafiles): - - basedir = os.path.join(datafiles.dirname, datafiles.basename) - loader = Loader( - basedir, 'elements/simple-dependency-variants.bst', 'blue', None, None, []) - element = loader.load() - - assert(isinstance(element, MetaElement)) - assert(element.kind == 'pony') - - # Test that the explicit blue dependency is correct - assert_dependency(element, 0, 'elements/simply-blue.bst', 'color', 'blue') - - -@pytest.mark.datafiles(DATA_DIR) -def test_variant_indirect_dependency_default(datafiles): - - basedir = os.path.join(datafiles.dirname, datafiles.basename) - loader = Loader( - basedir, 'elements/indirect-dependency-variants.bst', None, None, None, []) - element = loader.load() - - assert(isinstance(element, MetaElement)) - assert(element.kind == 'pony') - - # Test that the default is a blue pony-color by default - simple = assert_dependency( - element, 0, 'elements/simple-dependency-variants.bst', 'pony-color', 'blue') - - # Test that the element we depend on now depends on the blue color - assert_dependency(simple, 0, 'elements/simply-blue.bst', 'color', 'blue') - - -@pytest.mark.datafiles(DATA_DIR) -def test_variant_indirect_dependency_blue_pony(datafiles): - - basedir = os.path.join(datafiles.dirname, datafiles.basename) - loader = Loader( - basedir, 'elements/indirect-dependency-variants.bst', 'blue', None, None, []) - element = loader.load() - - assert(isinstance(element, MetaElement)) - assert(element.kind == 'pony') - - # Test for a blue pony-color - simple = assert_dependency( - element, 0, 'elements/simple-dependency-variants.bst', 'pony-color', 'blue') - - # Test that the element we depend on now depends on the blue color - assert_dependency(simple, 0, 'elements/simply-blue.bst', 'color', 'blue') - - -@pytest.mark.datafiles(DATA_DIR) -def test_variant_indirect_dependency_pink_pony(datafiles): - - basedir = os.path.join(datafiles.dirname, datafiles.basename) - loader = Loader( - basedir, 'elements/indirect-dependency-variants.bst', 'pink', None, None, []) - element = loader.load() - - assert(isinstance(element, MetaElement)) - assert(element.kind == 'pony') - - # Test for a blue pony-color - simple = assert_dependency( - element, 0, 'elements/simple-dependency-variants.bst', 'pony-color', 'pink') - - # Test that the element we depend on now depends on the blue color - assert_dependency(simple, 0, 'elements/simply-pink.bst', 'color', 'pink') - - -@pytest.mark.datafiles(DATA_DIR) -def test_engine_resolve_agreement(datafiles): - - basedir = os.path.join(datafiles.dirname, datafiles.basename) - loader = Loader(basedir, 'elements/tricky.bst', None, None, None, []) - element = loader.load() - - assert(isinstance(element, MetaElement)) - assert(element.kind == 'tricky') - - # Test the first dependency - first = assert_dependency(element, 0, 'elements/tricky-first.bst', 'choice', 'second') - second = assert_dependency(element, 1, 'elements/tricky-second.bst', 'choice', 'second') - - -@pytest.mark.datafiles(DATA_DIR) -def test_engine_disagreement(datafiles): - - basedir = os.path.join(datafiles.dirname, datafiles.basename) - loader = Loader(basedir, 'elements/disagreement-no-choice.bst', None, None, None, []) - - with pytest.raises(LoadError) as exc: - element = loader.load() - - assert (exc.value.reason == LoadErrorReason.VARIANT_DISAGREEMENT) diff --git a/tests/loader/variants/elements/depends-on-element-with-variants.bst b/tests/loader/variants/elements/depends-on-element-with-variants.bst deleted file mode 100644 index b58eb6903..000000000 --- a/tests/loader/variants/elements/depends-on-element-with-variants.bst +++ /dev/null @@ -1,4 +0,0 @@ -kind: pony -description: An element which depends on an element with variants -depends: -- elements/simple-dependency-variants.bst diff --git a/tests/loader/variants/elements/disagreement-no-choice.bst b/tests/loader/variants/elements/disagreement-no-choice.bst deleted file mode 100644 index 81f989c5b..000000000 --- a/tests/loader/variants/elements/disagreement-no-choice.bst +++ /dev/null @@ -1,9 +0,0 @@ -kind: disagreement -description: | - This pipeline cannot be built because elements are in disagreement about - what variants to choose - -depends: -- elements/disagreement-one-no-choice.bst -- filename: elements/disagreement-two-no-choice.bst - variant: second diff --git a/tests/loader/variants/elements/disagreement-one-no-choice.bst b/tests/loader/variants/elements/disagreement-one-no-choice.bst deleted file mode 100644 index 07781e0ab..000000000 --- a/tests/loader/variants/elements/disagreement-one-no-choice.bst +++ /dev/null @@ -1,5 +0,0 @@ -kind: color -description: Something or other -depends: -- filename: elements/disagreement-two-no-choice.bst - variant: first diff --git a/tests/loader/variants/elements/disagreement-one.bst b/tests/loader/variants/elements/disagreement-one.bst deleted file mode 100644 index 37ab8e833..000000000 --- a/tests/loader/variants/elements/disagreement-one.bst +++ /dev/null @@ -1,6 +0,0 @@ -kind: color -description: Something or other -choice: pony -depends: -- filename: elements/disagreement-two.bst - variant: first diff --git a/tests/loader/variants/elements/disagreement-two-no-choice.bst b/tests/loader/variants/elements/disagreement-two-no-choice.bst deleted file mode 100644 index d16bf95bc..000000000 --- a/tests/loader/variants/elements/disagreement-two-no-choice.bst +++ /dev/null @@ -1,5 +0,0 @@ -kind: color -description: Something or other -variants: -- variant: first -- variant: second diff --git a/tests/loader/variants/elements/disagreement-two.bst b/tests/loader/variants/elements/disagreement-two.bst deleted file mode 100644 index e5cec1546..000000000 --- a/tests/loader/variants/elements/disagreement-two.bst +++ /dev/null @@ -1,8 +0,0 @@ -kind: color -description: Something or other -choice: None -variants: -- variant: first - choice: first -- variant: second - choice: second diff --git a/tests/loader/variants/elements/disagreement.bst b/tests/loader/variants/elements/disagreement.bst deleted file mode 100644 index b26c51c14..000000000 --- a/tests/loader/variants/elements/disagreement.bst +++ /dev/null @@ -1,9 +0,0 @@ -kind: disagreement -description: | - This pipeline cannot be built because elements are in disagreement about - what variants to choose - -depends: -- elements/disagreement-one.bst -- filename: elements/disagreement-two.bst - variant: second diff --git a/tests/loader/variants/elements/indirect-dependency-variants.bst b/tests/loader/variants/elements/indirect-dependency-variants.bst deleted file mode 100644 index 81f227691..000000000 --- a/tests/loader/variants/elements/indirect-dependency-variants.bst +++ /dev/null @@ -1,17 +0,0 @@ -kind: pony -description: | - Indirect dependency variants, depend on a different variant of the simple test, - depending on the selected variant -variants: -- variant: blue - config: - pony-color: blue - depends: - - filename: elements/simple-dependency-variants.bst - variant: blue -- variant: pink - config: - pony-color: pink - depends: - - filename: elements/simple-dependency-variants.bst - variant: pink diff --git a/tests/loader/variants/elements/only-one-variant.bst b/tests/loader/variants/elements/only-one-variant.bst deleted file mode 100644 index 623bf2655..000000000 --- a/tests/loader/variants/elements/only-one-variant.bst +++ /dev/null @@ -1,8 +0,0 @@ -kind: pony -description: | - Elements which declare variants must declare a minimum of two variants, even - if the declared variant does not augment the element in anyway. This is because - every variant of every element must be addressable by name. -variants: -- variant: pink - pony-color: pink diff --git a/tests/loader/variants/elements/simple-dependency-variants.bst b/tests/loader/variants/elements/simple-dependency-variants.bst deleted file mode 100644 index 721be88f3..000000000 --- a/tests/loader/variants/elements/simple-dependency-variants.bst +++ /dev/null @@ -1,13 +0,0 @@ -kind: pony -description: Simple dependency variants, different variants depend on different elements -variants: -- variant: pink - config: - pony-color: pink - depends: - - elements/simply-pink.bst -- variant: blue - config: - pony-color: blue - depends: - - elements/simply-blue.bst diff --git a/tests/loader/variants/elements/simple-unused-variant-invalid.bst b/tests/loader/variants/elements/simple-unused-variant-invalid.bst deleted file mode 100644 index 610bfaf76..000000000 --- a/tests/loader/variants/elements/simple-unused-variant-invalid.bst +++ /dev/null @@ -1,14 +0,0 @@ -kind: pony -description: An element which depends on an invalid variant of a dependency -variants: -- variant: pink - config: - pony-color: pink - depends: - - filename: elements/simply-pink.bst - variant: green -- variant: blue - config: - pony-color: blue - depends: - - elements/simply-blue.bst diff --git a/tests/loader/variants/elements/simple-variant-compositing.bst b/tests/loader/variants/elements/simple-variant-compositing.bst deleted file mode 100644 index 33c6571f2..000000000 --- a/tests/loader/variants/elements/simple-variant-compositing.bst +++ /dev/null @@ -1,12 +0,0 @@ -kind: pony -description: Simple test of variant compositing, without fancy dependencies -config: - somedata: 5 -variants: -- variant: pink - config: - pony-color: pink -- variant: blue - config: - pony-color: blue - somedata: 6 diff --git a/tests/loader/variants/elements/simple-variant-invalid.bst b/tests/loader/variants/elements/simple-variant-invalid.bst deleted file mode 100644 index d8c2a40e7..000000000 --- a/tests/loader/variants/elements/simple-variant-invalid.bst +++ /dev/null @@ -1,5 +0,0 @@ -kind: pony -description: An element which depends on an invalid variant of a dependency -depends: -- filename: elements/simple-variant-compositing.bst - variant: green diff --git a/tests/loader/variants/elements/simply-blue.bst b/tests/loader/variants/elements/simply-blue.bst deleted file mode 100644 index 2565d762c..000000000 --- a/tests/loader/variants/elements/simply-blue.bst +++ /dev/null @@ -1,4 +0,0 @@ -kind: color -description: A color dependency for variant tests -config: - color: blue diff --git a/tests/loader/variants/elements/simply-pink.bst b/tests/loader/variants/elements/simply-pink.bst deleted file mode 100644 index b51a07f7b..000000000 --- a/tests/loader/variants/elements/simply-pink.bst +++ /dev/null @@ -1,4 +0,0 @@ -kind: color -description: A color dependency for variant tests -config: - color: pink diff --git a/tests/loader/variants/elements/tricky-first.bst b/tests/loader/variants/elements/tricky-first.bst deleted file mode 100644 index fdc14f75f..000000000 --- a/tests/loader/variants/elements/tricky-first.bst +++ /dev/null @@ -1,14 +0,0 @@ -kind: color -description: Something or other -config: - choice: None -variants: -- variant: first - config: - choice: first - depends: - - filename: elements/tricky-second.bst - variant: first -- variant: second - config: - choice: second diff --git a/tests/loader/variants/elements/tricky-second.bst b/tests/loader/variants/elements/tricky-second.bst deleted file mode 100644 index f386eaff4..000000000 --- a/tests/loader/variants/elements/tricky-second.bst +++ /dev/null @@ -1,11 +0,0 @@ -kind: color -description: Something or other -config: - choice: None -variants: -- variant: first - config: - choice: first -- variant: second - config: - choice: second diff --git a/tests/loader/variants/elements/tricky.bst b/tests/loader/variants/elements/tricky.bst deleted file mode 100644 index 06596cb1d..000000000 --- a/tests/loader/variants/elements/tricky.bst +++ /dev/null @@ -1,15 +0,0 @@ -kind: tricky -description: | - This element depends ambivalently on tricky-first, then specifically - on the second variant of tricky-second. The default variant of tricky-first - depends explicitly on the first variant of tricky-second. - - This forces the engine to make a choice and resolve the tree, we're expecting - the tree to end up with: - o tricky - o tricky-first(second) - o tricky-second(second) -depends: -- elements/tricky-first.bst -- filename: elements/tricky-second.bst - variant: second diff --git a/tests/loader/variants/elements/unnamed-variant.bst b/tests/loader/variants/elements/unnamed-variant.bst deleted file mode 100644 index 18767e95c..000000000 --- a/tests/loader/variants/elements/unnamed-variant.bst +++ /dev/null @@ -1,5 +0,0 @@ -kind: pony -description: This has variants but they dont specify the 'variant' name -variants: -- pony: 4 -- horse: Hello diff --git a/tests/loader/variants/elements/variant-bad-name.bst b/tests/loader/variants/elements/variant-bad-name.bst deleted file mode 100644 index aefcfcf4b..000000000 --- a/tests/loader/variants/elements/variant-bad-name.bst +++ /dev/null @@ -1,9 +0,0 @@ -kind: pony -description: These variants dont have string types for their name -variants: -- variant: - - pony - - horse - horse: Hello -- variant: 5 - pony: 4 diff --git a/tests/loader/variants/elements/variant-illegal-composite.bst b/tests/loader/variants/elements/variant-illegal-composite.bst deleted file mode 100644 index d28382f1a..000000000 --- a/tests/loader/variants/elements/variant-illegal-composite.bst +++ /dev/null @@ -1,11 +0,0 @@ -kind: pony -description: This variant overrides a config value with an incorrect type -config: - number: 5 -variants: -- variant: first - config: - number: four -- variant: second - config: - number: six diff --git a/tests/loader/variants/elements/variants-not-list.bst b/tests/loader/variants/elements/variants-not-list.bst deleted file mode 100644 index 9d5399939..000000000 --- a/tests/loader/variants/elements/variants-not-list.bst +++ /dev/null @@ -1,3 +0,0 @@ -kind: pony -description: This has variants but not a list of them -variants: This is not a list |