From 8f2b4e9aa0631b8622804206d5742701fd3e03c0 Mon Sep 17 00:00:00 2001 From: Tristan Van Berkom Date: Fri, 11 Jan 2019 14:02:14 -0500 Subject: tests: Migrate test for load_ref() unsupporting plugins into format/project.py The tests/format/project.py test already has some tests about how we error gracefully for bad plugins and bad plugin configurations, lets put it there rather than tests/pipeline/load.py which we will remove. --- tests/format/project.py | 32 +++++++++++++++++++ .../project/plugin-no-load-ref/noloadref.bst | 7 +++++ .../plugin-no-load-ref/plugins/noloadref.py | 36 ++++++++++++++++++++++ .../format/project/plugin-no-load-ref/project.refs | 6 ++++ tests/pipeline/load.py | 32 ------------------- tests/pipeline/load/noloadref/noloadref.bst | 7 ----- tests/pipeline/load/noloadref/plugins/noloadref.py | 36 ---------------------- tests/pipeline/load/noloadref/project.refs | 6 ---- 8 files changed, 81 insertions(+), 81 deletions(-) create mode 100644 tests/format/project/plugin-no-load-ref/noloadref.bst create mode 100644 tests/format/project/plugin-no-load-ref/plugins/noloadref.py create mode 100644 tests/format/project/plugin-no-load-ref/project.refs delete mode 100644 tests/pipeline/load/noloadref/noloadref.bst delete mode 100644 tests/pipeline/load/noloadref/plugins/noloadref.py delete mode 100644 tests/pipeline/load/noloadref/project.refs diff --git a/tests/format/project.py b/tests/format/project.py index 02e8afb37..294b9a4ff 100644 --- a/tests/format/project.py +++ b/tests/format/project.py @@ -155,6 +155,38 @@ def test_project_plugin_load_forbidden(cli, datafiles): result.assert_main_error(ErrorDomain.PLUGIN, None) +@pytest.mark.datafiles(DATA_DIR) +@pytest.mark.parametrize("ref_storage", [('inline'), ('project.refs')]) +def test_project_plugin_no_load_ref(cli, datafiles, ref_storage): + project = os.path.join(datafiles.dirname, datafiles.basename, 'plugin-no-load-ref') + + # Generate project with access to the noloadref plugin and project.refs enabled + # + config = { + 'name': 'test', + 'ref-storage': ref_storage, + 'plugins': [ + { + 'origin': 'local', + 'path': 'plugins', + 'sources': { + 'noloadref': 0 + } + } + ] + } + _yaml.dump(config, os.path.join(project, 'project.conf')) + + result = cli.run(project=project, silent=True, args=['show', 'noloadref.bst']) + + # There is no error if project.refs is not in use, otherwise we + # assert our graceful failure + if ref_storage == 'inline': + result.assert_success() + else: + result.assert_main_error(ErrorDomain.SOURCE, 'unsupported-load-ref') + + @pytest.mark.datafiles(DATA_DIR) def test_project_conf_duplicate_plugins(cli, datafiles): project = os.path.join(datafiles.dirname, datafiles.basename, 'duplicate-plugins') diff --git a/tests/format/project/plugin-no-load-ref/noloadref.bst b/tests/format/project/plugin-no-load-ref/noloadref.bst new file mode 100644 index 000000000..23a52ef8f --- /dev/null +++ b/tests/format/project/plugin-no-load-ref/noloadref.bst @@ -0,0 +1,7 @@ +kind: import +description: | + + Import a source which does not support the load_ref() method + +sources: +- kind: noloadref diff --git a/tests/format/project/plugin-no-load-ref/plugins/noloadref.py b/tests/format/project/plugin-no-load-ref/plugins/noloadref.py new file mode 100644 index 000000000..0cc457f07 --- /dev/null +++ b/tests/format/project/plugin-no-load-ref/plugins/noloadref.py @@ -0,0 +1,36 @@ +from buildstream import Source, Consistency + + +# Just a dummy plugin which does not support the new load_ref() method. +# +# Use this to test that the core behaves as expected with such plugins. +# +class NoLoadRefSource(Source): + + def configure(self, node): + pass + + def preflight(self): + pass + + def get_unique_key(self): + return {} + + def get_consistency(self): + return Consistency.CACHED + + def get_ref(self): + return None + + def set_ref(self, ref, node): + pass + + def fetch(self): + pass + + def stage(self, directory): + pass + + +def setup(): + return NoLoadRefSource diff --git a/tests/format/project/plugin-no-load-ref/project.refs b/tests/format/project/plugin-no-load-ref/project.refs new file mode 100644 index 000000000..b06a4577d --- /dev/null +++ b/tests/format/project/plugin-no-load-ref/project.refs @@ -0,0 +1,6 @@ +# A project.refs file with an existing ref for the noloadref element +# +projects: + test: + noloadref.bst: + - ref: dummy diff --git a/tests/pipeline/load.py b/tests/pipeline/load.py index 50fa184b6..9f51d8e33 100644 --- a/tests/pipeline/load.py +++ b/tests/pipeline/load.py @@ -16,35 +16,3 @@ def test_load_simple(cli, datafiles): result = cli.get_element_config(basedir, 'simple.bst') assert(result['configure-commands'][0] == 'pony') - - -@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): - basedir = os.path.join(datafiles.dirname, datafiles.basename) - - # Generate project with access to the noloadref plugin and project.refs enabled - # - config = { - 'name': 'test', - 'ref-storage': ref_storage, - 'plugins': [ - { - 'origin': 'local', - 'path': 'plugins', - 'sources': { - 'noloadref': 0 - } - } - ] - } - _yaml.dump(config, os.path.join(basedir, 'project.conf')) - - result = cli.run(project=basedir, silent=True, args=['show', 'noloadref.bst']) - - # There is no error if project.refs is not in use, otherwise we - # assert our graceful failure - if ref_storage == 'inline': - result.assert_success() - else: - result.assert_main_error(ErrorDomain.SOURCE, 'unsupported-load-ref') diff --git a/tests/pipeline/load/noloadref/noloadref.bst b/tests/pipeline/load/noloadref/noloadref.bst deleted file mode 100644 index 23a52ef8f..000000000 --- a/tests/pipeline/load/noloadref/noloadref.bst +++ /dev/null @@ -1,7 +0,0 @@ -kind: import -description: | - - Import a source which does not support the load_ref() method - -sources: -- kind: noloadref diff --git a/tests/pipeline/load/noloadref/plugins/noloadref.py b/tests/pipeline/load/noloadref/plugins/noloadref.py deleted file mode 100644 index 0cc457f07..000000000 --- a/tests/pipeline/load/noloadref/plugins/noloadref.py +++ /dev/null @@ -1,36 +0,0 @@ -from buildstream import Source, Consistency - - -# Just a dummy plugin which does not support the new load_ref() method. -# -# Use this to test that the core behaves as expected with such plugins. -# -class NoLoadRefSource(Source): - - def configure(self, node): - pass - - def preflight(self): - pass - - def get_unique_key(self): - return {} - - def get_consistency(self): - return Consistency.CACHED - - def get_ref(self): - return None - - def set_ref(self, ref, node): - pass - - def fetch(self): - pass - - def stage(self, directory): - pass - - -def setup(): - return NoLoadRefSource diff --git a/tests/pipeline/load/noloadref/project.refs b/tests/pipeline/load/noloadref/project.refs deleted file mode 100644 index b06a4577d..000000000 --- a/tests/pipeline/load/noloadref/project.refs +++ /dev/null @@ -1,6 +0,0 @@ -# A project.refs file with an existing ref for the noloadref element -# -projects: - test: - noloadref.bst: - - ref: dummy -- cgit v1.2.1