diff options
author | Tristan Van Berkom <tristan.vanberkom@codethink.co.uk> | 2017-07-17 22:52:45 +0900 |
---|---|---|
committer | Tristan Van Berkom <tristan.vanberkom@codethink.co.uk> | 2017-07-17 22:55:29 +0900 |
commit | c3181f4b443b618c38d24faefa48a84d4c10253a (patch) | |
tree | 82a42d86514a2bcab9d26b176df146d19da60b4e /tests | |
parent | b1e4fcfc41d56ff82547541298ffa186ebd4bd32 (diff) | |
download | buildstream-c3181f4b443b618c38d24faefa48a84d4c10253a.tar.gz |
Test Cases: Updated for new Project / Loader API changes
Diffstat (limited to 'tests')
-rw-r--r-- | tests/loader/arches.py | 30 | ||||
-rw-r--r-- | tests/loader/basics.py | 10 | ||||
-rw-r--r-- | tests/loader/dependencies.py | 18 | ||||
-rw-r--r-- | tests/loader/variants.py | 42 | ||||
-rw-r--r-- | tests/project/project.py | 5 | ||||
-rw-r--r-- | tests/sources/fixture.py | 12 |
6 files changed, 62 insertions, 55 deletions
diff --git a/tests/loader/arches.py b/tests/loader/arches.py index bc69d5b8f..eb823c6f3 100644 --- a/tests/loader/arches.py +++ b/tests/loader/arches.py @@ -19,7 +19,7 @@ def test_simple_conditional_nomatch(datafiles): basedir = os.path.join(datafiles.dirname, datafiles.basename) loader = Loader( - basedir, 'elements/simple-conditional.bst', None, 'arm', None) + basedir, 'elements/simple-conditional.bst', None, 'arm', None, []) element = loader.load() assert(isinstance(element, MetaElement)) @@ -34,7 +34,7 @@ def test_simple_conditional_x86_64(datafiles): basedir = os.path.join(datafiles.dirname, datafiles.basename) loader = Loader( - basedir, 'elements/simple-conditional.bst', None, 'x86_64', None) + basedir, 'elements/simple-conditional.bst', None, 'x86_64', None, []) element = loader.load() assert(isinstance(element, MetaElement)) @@ -49,7 +49,7 @@ def test_simple_conditional_x86_32(datafiles): basedir = os.path.join(datafiles.dirname, datafiles.basename) loader = Loader( - basedir, 'elements/simple-conditional.bst', None, 'x86_32', None) + basedir, 'elements/simple-conditional.bst', None, 'x86_32', None, []) element = loader.load() assert(isinstance(element, MetaElement)) @@ -69,7 +69,7 @@ def test_host_arch_conditional_armv8(datafiles): basedir = os.path.join(datafiles.dirname, datafiles.basename) loader = Loader( - basedir, 'elements/host-arch-conditional.bst', None, 'armv8', None) + basedir, 'elements/host-arch-conditional.bst', None, 'armv8', None, []) element = loader.load() assert(isinstance(element, MetaElement)) @@ -84,7 +84,7 @@ def test_host_arch_conditional_ignores_target_arch(datafiles): basedir = os.path.join(datafiles.dirname, datafiles.basename) loader = Loader( - basedir, 'elements/host-arch-conditional.bst', None, 'armv8', 'x86_32') + basedir, 'elements/host-arch-conditional.bst', None, 'armv8', 'x86_32', []) element = loader.load() assert(isinstance(element, MetaElement)) @@ -100,7 +100,7 @@ def test_host_arch_conditional_overridden(datafiles): basedir = os.path.join(datafiles.dirname, datafiles.basename) loader = Loader( - basedir, 'elements/host-arch-conditional.bst', None, 'armv8', 'x86_64') + basedir, 'elements/host-arch-conditional.bst', None, 'armv8', 'x86_64', []) element = loader.load() assert(isinstance(element, MetaElement)) @@ -119,7 +119,7 @@ def test_variant_arch_default(datafiles): basedir = os.path.join(datafiles.dirname, datafiles.basename) loader = Loader( - basedir, 'elements/variant-arch-conditional.bst', None, 'arm', None) + basedir, 'elements/variant-arch-conditional.bst', None, 'arm', None, []) element = loader.load() assert(isinstance(element, MetaElement)) @@ -134,7 +134,7 @@ def test_variant_arch_default_x86_64(datafiles): basedir = os.path.join(datafiles.dirname, datafiles.basename) loader = Loader( - basedir, 'elements/variant-arch-conditional.bst', None, 'x86_64', None) + basedir, 'elements/variant-arch-conditional.bst', None, 'x86_64', None, []) element = loader.load() assert(isinstance(element, MetaElement)) @@ -148,7 +148,7 @@ def test_variant_arch_default_x86_32(datafiles): basedir = os.path.join(datafiles.dirname, datafiles.basename) loader = Loader( - basedir, 'elements/variant-arch-conditional.bst', None, 'x86_32', None) + basedir, 'elements/variant-arch-conditional.bst', None, 'x86_32', None, []) element = loader.load() assert(isinstance(element, MetaElement)) @@ -162,7 +162,7 @@ def test_variant_arch_pink_pony(datafiles): basedir = os.path.join(datafiles.dirname, datafiles.basename) loader = Loader( - basedir, 'elements/variant-arch-conditional.bst', 'pink', 'arm', None) + basedir, 'elements/variant-arch-conditional.bst', 'pink', 'arm', None, []) element = loader.load() assert(isinstance(element, MetaElement)) @@ -177,7 +177,7 @@ def test_variant_arch_pink_pony_x86_64(datafiles): basedir = os.path.join(datafiles.dirname, datafiles.basename) loader = Loader( - basedir, 'elements/variant-arch-conditional.bst', 'pink', 'x86_64', None) + basedir, 'elements/variant-arch-conditional.bst', 'pink', 'x86_64', None, []) element = loader.load() assert(isinstance(element, MetaElement)) @@ -191,7 +191,7 @@ def test_variant_arch_pink_pony_x86_32(datafiles): basedir = os.path.join(datafiles.dirname, datafiles.basename) loader = Loader( - basedir, 'elements/variant-arch-conditional.bst', 'pink', 'x86_32', None) + basedir, 'elements/variant-arch-conditional.bst', 'pink', 'x86_32', None, []) element = loader.load() assert(isinstance(element, MetaElement)) @@ -205,7 +205,7 @@ def test_variant_arch_blue_pony(datafiles): basedir = os.path.join(datafiles.dirname, datafiles.basename) loader = Loader( - basedir, 'elements/variant-arch-conditional.bst', 'blue', 'arm', None) + basedir, 'elements/variant-arch-conditional.bst', 'blue', 'arm', None, []) element = loader.load() assert(isinstance(element, MetaElement)) @@ -220,7 +220,7 @@ def test_variant_arch_blue_pony_x86_64(datafiles): basedir = os.path.join(datafiles.dirname, datafiles.basename) loader = Loader( - basedir, 'elements/variant-arch-conditional.bst', 'blue', 'x86_64', None) + basedir, 'elements/variant-arch-conditional.bst', 'blue', 'x86_64', None, []) element = loader.load() assert(isinstance(element, MetaElement)) @@ -234,7 +234,7 @@ def test_variant_arch_blue_pony_x86_32(datafiles): basedir = os.path.join(datafiles.dirname, datafiles.basename) loader = Loader( - basedir, 'elements/variant-arch-conditional.bst', 'blue', 'x86_32', None) + basedir, 'elements/variant-arch-conditional.bst', 'blue', 'x86_32', None, []) element = loader.load() assert(isinstance(element, MetaElement)) diff --git a/tests/loader/basics.py b/tests/loader/basics.py index d7f85b0fe..4830702df 100644 --- a/tests/loader/basics.py +++ b/tests/loader/basics.py @@ -18,7 +18,7 @@ DATA_DIR = os.path.join( def test_one_file(datafiles): basedir = os.path.join(datafiles.dirname, datafiles.basename) - loader = Loader(basedir, 'elements/onefile.bst', None, None, None) + loader = Loader(basedir, 'elements/onefile.bst', None, None, None, []) element = loader.load() @@ -30,7 +30,7 @@ def test_one_file(datafiles): def test_missing_file(datafiles): basedir = os.path.join(datafiles.dirname, datafiles.basename) - loader = Loader(basedir, 'elements/missing.bst', None, None, None) + loader = Loader(basedir, 'elements/missing.bst', None, None, None, []) with pytest.raises(LoadError) as exc: element = loader.load() @@ -42,7 +42,7 @@ def test_missing_file(datafiles): def test_invalid_reference(datafiles): basedir = os.path.join(datafiles.dirname, datafiles.basename) - loader = Loader(basedir, 'elements/badreference.bst', None, None, None) + loader = Loader(basedir, 'elements/badreference.bst', None, None, None, []) with pytest.raises(LoadError) as exc: element = loader.load() @@ -54,7 +54,7 @@ def test_invalid_reference(datafiles): def test_invalid_yaml(datafiles): basedir = os.path.join(datafiles.dirname, datafiles.basename) - loader = Loader(basedir, 'elements/badfile.bst', None, None, None) + loader = Loader(basedir, 'elements/badfile.bst', None, None, None, []) with pytest.raises(LoadError) as exc: element = loader.load() @@ -69,6 +69,6 @@ def test_fail_fullpath_target(datafiles): fullpath = os.path.join(basedir, 'elements', 'onefile.bst') with pytest.raises(LoadError) as exc: - loader = Loader(basedir, fullpath, None, None, None) + loader = Loader(basedir, fullpath, None, None, None, []) assert (exc.value.reason == LoadErrorReason.INVALID_DATA) diff --git a/tests/loader/dependencies.py b/tests/loader/dependencies.py index a701d4723..058e46603 100644 --- a/tests/loader/dependencies.py +++ b/tests/loader/dependencies.py @@ -18,7 +18,7 @@ DATA_DIR = os.path.join( def test_two_files(datafiles): basedir = os.path.join(datafiles.dirname, datafiles.basename) - loader = Loader(basedir, 'elements/target.bst', None, None, None) + loader = Loader(basedir, 'elements/target.bst', None, None, None, []) element = loader.load() assert(isinstance(element, MetaElement)) @@ -34,7 +34,7 @@ def test_two_files(datafiles): def test_shared_dependency(datafiles): basedir = os.path.join(datafiles.dirname, datafiles.basename) - loader = Loader(basedir, 'elements/shareddeptarget.bst', None, None, None) + loader = Loader(basedir, 'elements/shareddeptarget.bst', None, None, None, []) element = loader.load() # Toplevel is 'pony' with 2 dependencies @@ -77,7 +77,7 @@ def test_shared_dependency(datafiles): def test_dependency_dict(datafiles): basedir = os.path.join(datafiles.dirname, datafiles.basename) - loader = Loader(basedir, 'elements/target-depdict.bst', None, None, None) + loader = Loader(basedir, 'elements/target-depdict.bst', None, None, None, []) element = loader.load() assert(isinstance(element, MetaElement)) @@ -92,7 +92,7 @@ def test_dependency_dict(datafiles): @pytest.mark.datafiles(DATA_DIR) def test_invalid_dependency_declaration(datafiles): basedir = os.path.join(datafiles.dirname, datafiles.basename) - loader = Loader(basedir, 'elements/invaliddep.bst', None, None, None) + loader = Loader(basedir, 'elements/invaliddep.bst', None, None, None, []) with pytest.raises(LoadError) as exc: element = loader.load() @@ -103,7 +103,7 @@ def test_invalid_dependency_declaration(datafiles): @pytest.mark.datafiles(DATA_DIR) def test_circular_dependency(datafiles): basedir = os.path.join(datafiles.dirname, datafiles.basename) - loader = Loader(basedir, 'elements/circulartarget.bst', None, None, None) + loader = Loader(basedir, 'elements/circulartarget.bst', None, None, None, []) with pytest.raises(LoadError) as exc: element = loader.load() @@ -114,7 +114,7 @@ def test_circular_dependency(datafiles): @pytest.mark.datafiles(DATA_DIR) def test_invalid_dependency_type(datafiles): basedir = os.path.join(datafiles.dirname, datafiles.basename) - loader = Loader(basedir, 'elements/invaliddeptype.bst', None, None, None) + loader = Loader(basedir, 'elements/invaliddeptype.bst', None, None, None, []) with pytest.raises(LoadError) as exc: element = loader.load() @@ -125,7 +125,7 @@ def test_invalid_dependency_type(datafiles): @pytest.mark.datafiles(DATA_DIR) def test_build_dependency(datafiles): basedir = os.path.join(datafiles.dirname, datafiles.basename) - loader = Loader(basedir, 'elements/builddep.bst', None, None, None) + loader = Loader(basedir, 'elements/builddep.bst', None, None, None, []) element = loader.load() assert(isinstance(element, MetaElement)) @@ -141,7 +141,7 @@ def test_build_dependency(datafiles): @pytest.mark.datafiles(DATA_DIR) def test_runtime_dependency(datafiles): basedir = os.path.join(datafiles.dirname, datafiles.basename) - loader = Loader(basedir, 'elements/runtimedep.bst', None, None, None) + loader = Loader(basedir, 'elements/runtimedep.bst', None, None, None, []) element = loader.load() assert(isinstance(element, MetaElement)) @@ -157,7 +157,7 @@ def test_runtime_dependency(datafiles): @pytest.mark.datafiles(DATA_DIR) def test_build_runtime_dependency(datafiles): basedir = os.path.join(datafiles.dirname, datafiles.basename) - loader = Loader(basedir, 'elements/target.bst', None, None, None) + loader = Loader(basedir, 'elements/target.bst', None, None, None, []) element = loader.load() assert(isinstance(element, MetaElement)) diff --git a/tests/loader/variants.py b/tests/loader/variants.py index 9a3b186d6..ad23389e8 100644 --- a/tests/loader/variants.py +++ b/tests/loader/variants.py @@ -18,7 +18,7 @@ DATA_DIR = os.path.join( 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) + loader = Loader(basedir, 'elements/variants-not-list.bst', None, None, None, []) with pytest.raises(LoadError) as exc: element = loader.load() @@ -30,7 +30,7 @@ def test_variant_not_list(datafiles): def test_variant_unnamed(datafiles): basedir = os.path.join(datafiles.dirname, datafiles.basename) - loader = Loader(basedir, 'elements/unnamed-variant.bst', None, None, None) + loader = Loader(basedir, 'elements/unnamed-variant.bst', None, None, None, []) with pytest.raises(LoadError) as exc: element = loader.load() @@ -42,7 +42,7 @@ def test_variant_unnamed(datafiles): 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) + loader = Loader(basedir, 'elements/variant-bad-name.bst', None, None, None, []) with pytest.raises(LoadError) as exc: element = loader.load() @@ -54,7 +54,7 @@ def test_variant_bad_name(datafiles): 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) + loader = Loader(basedir, 'elements/only-one-variant.bst', None, None, None, []) with pytest.raises(LoadError) as exc: element = loader.load() @@ -67,7 +67,7 @@ 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) + basedir, 'elements/variant-illegal-composite.bst', None, None, None, []) with pytest.raises(LoadError) as exc: element = loader.load() @@ -84,7 +84,7 @@ 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) + basedir, 'elements/simple-variant-compositing.bst', 'green', None, None, []) with pytest.raises(LoadError) as exc: element = loader.load() @@ -98,7 +98,7 @@ 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) + basedir, 'elements/simple-variant-invalid.bst', None, None, None, []) with pytest.raises(LoadError) as exc: element = loader.load() @@ -114,7 +114,7 @@ def test_variant_invalid_unused_dependency(datafiles): # 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) + basedir, 'elements/simple-unused-variant-invalid.bst', 'blue', None, None, []) with pytest.raises(LoadError) as exc: element = loader.load() @@ -131,7 +131,7 @@ 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) + basedir, 'elements/simple-variant-compositing.bst', None, None, None, []) element = loader.load() assert(element.variant == 'pink') @@ -143,7 +143,7 @@ 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) + basedir, 'elements/depends-on-element-with-variants.bst', None, None, None, []) element = loader.load() dependency = element.dependencies[0] @@ -158,7 +158,7 @@ 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) + basedir, 'elements/simple-variant-compositing.bst', None, None, None, []) element = loader.load() @@ -175,7 +175,7 @@ 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) + basedir, 'elements/simple-variant-compositing.bst', 'pink', None, None, []) element = loader.load() @@ -192,7 +192,7 @@ 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) + basedir, 'elements/simple-variant-compositing.bst', 'blue', None, None, []) element = loader.load() @@ -230,7 +230,7 @@ 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) + basedir, 'elements/simple-dependency-variants.bst', None, None, None, []) element = loader.load() assert(isinstance(element, MetaElement)) @@ -245,7 +245,7 @@ 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) + basedir, 'elements/simple-dependency-variants.bst', 'pink', None, None, []) element = loader.load() assert(isinstance(element, MetaElement)) @@ -260,7 +260,7 @@ 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) + basedir, 'elements/simple-dependency-variants.bst', 'blue', None, None, []) element = loader.load() assert(isinstance(element, MetaElement)) @@ -275,7 +275,7 @@ 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) + basedir, 'elements/indirect-dependency-variants.bst', None, None, None, []) element = loader.load() assert(isinstance(element, MetaElement)) @@ -294,7 +294,7 @@ 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) + basedir, 'elements/indirect-dependency-variants.bst', 'blue', None, None, []) element = loader.load() assert(isinstance(element, MetaElement)) @@ -313,7 +313,7 @@ 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) + basedir, 'elements/indirect-dependency-variants.bst', 'pink', None, None, []) element = loader.load() assert(isinstance(element, MetaElement)) @@ -331,7 +331,7 @@ def test_variant_indirect_dependency_pink_pony(datafiles): def test_engine_resolve_agreement(datafiles): basedir = os.path.join(datafiles.dirname, datafiles.basename) - loader = Loader(basedir, 'elements/tricky.bst', None, None, None) + loader = Loader(basedir, 'elements/tricky.bst', None, None, None, []) element = loader.load() assert(isinstance(element, MetaElement)) @@ -346,7 +346,7 @@ def test_engine_resolve_agreement(datafiles): def test_engine_disagreement(datafiles): basedir = os.path.join(datafiles.dirname, datafiles.basename) - loader = Loader(basedir, 'elements/disagreement.bst', None, None, None) + loader = Loader(basedir, 'elements/disagreement.bst', None, None, None, []) with pytest.raises(LoadError) as exc: element = loader.load() diff --git a/tests/project/project.py b/tests/project/project.py index 08a302bd8..6940770d9 100644 --- a/tests/project/project.py +++ b/tests/project/project.py @@ -16,6 +16,7 @@ def test_missing_project_conf(datafiles): with pytest.raises(LoadError) as exc: project = Project(directory, 'x86_64') + project._resolve(None) assert (exc.value.reason == LoadErrorReason.MISSING_FILE) @@ -26,6 +27,7 @@ def test_missing_project_name(datafiles): with pytest.raises(LoadError) as exc: project = Project(directory, 'x86_64') + project._resolve(None) assert (exc.value.reason == LoadErrorReason.INVALID_DATA) @@ -35,6 +37,7 @@ def test_load_basic_project(datafiles): directory = os.path.join(datafiles.dirname, datafiles.basename, "basic") project = Project(directory, 'x86_64') + project._resolve(None) # User provided assert (project.name == "pony") @@ -50,6 +53,7 @@ def test_override_project_path(datafiles): directory = os.path.join(datafiles.dirname, datafiles.basename, "overridepath") project = Project(directory, 'x86_64') + project._resolve(None) # Test the override assert (project._environment['PATH'] == "/bin:/sbin") @@ -60,6 +64,7 @@ def test_project_alias(datafiles): directory = os.path.join(datafiles.dirname, datafiles.basename, "alias") project = Project(directory, 'x86_64') + project._resolve(None) # Test the override assert (project.translate_url('baserock:foo') == 'git://git.baserock.org/baserock/foo') diff --git a/tests/sources/fixture.py b/tests/sources/fixture.py index c7b3a8fe6..b231d5ce7 100644 --- a/tests/sources/fixture.py +++ b/tests/sources/fixture.py @@ -24,10 +24,6 @@ class Setup(): self.context = Context('x86_64') self.project = Project(directory, 'x86_64') - # Allow repo aliases to access files in the directories using tmpdir and datafiles - self.project._aliases['tmpdir'] = "file:///" + str(tmpdir) - self.project._aliases['datafiles'] = "file:///" + str(datafiles) - # A message handler is required self.context._set_message_handler(message_handler) @@ -39,8 +35,14 @@ class Setup(): if not os.path.exists(self.context.builddir): os.mkdir(self.context.builddir) - loader = Loader(directory, target, None, None, None) + loader = Loader(directory, target, None, None, None, []) element = loader.load() + self.project._resolve(loader.project_variant) + + # Allow repo aliases to access files in the directories using tmpdir and datafiles + self.project._aliases['tmpdir'] = "file:///" + str(tmpdir) + self.project._aliases['datafiles'] = "file:///" + str(datafiles) + assert(len(element.sources) == 1) self.meta_source = element.sources[0] |