From 4005ff5f7a2aedc0d39425278fb337b4aa6a85d6 Mon Sep 17 00:00:00 2001 From: Tristan Van Berkom Date: Wed, 30 Aug 2017 22:17:16 -0400 Subject: plugin tests: Adding new tests with plugins loaded in a pipeline o Testing that we can load a custom element or source o Testing that we assert and trigger an error when the requested format version of a plugin by the project is greater than the reported version of the plugin --- tests/plugins/pipeline.py | 52 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 tests/plugins/pipeline.py (limited to 'tests/plugins/pipeline.py') diff --git a/tests/plugins/pipeline.py b/tests/plugins/pipeline.py new file mode 100644 index 000000000..868145a11 --- /dev/null +++ b/tests/plugins/pipeline.py @@ -0,0 +1,52 @@ +import os +import pytest + +from buildstream import Context, Project, Scope, PluginError +from buildstream._pipeline import Pipeline + +DATA_DIR = os.path.join( + os.path.dirname(os.path.realpath(__file__)), + 'pipeline', +) + + +def create_pipeline(tmpdir, basedir, target, variant): + context = Context('x86_64') + project = Project(basedir, 'x86_64') + + context.deploydir = os.path.join(str(tmpdir), 'deploy') + context.artifactdir = os.path.join(str(tmpdir), 'artifact') + + return Pipeline(context, project, target, variant) + + +@pytest.mark.datafiles(os.path.join(DATA_DIR, 'customsource')) +def test_customsource(datafiles, tmpdir): + + basedir = os.path.join(datafiles.dirname, datafiles.basename) + pipeline = create_pipeline(tmpdir, basedir, 'simple.bst', None) + assert(pipeline.target.get_kind() == "autotools") + + +@pytest.mark.datafiles(os.path.join(DATA_DIR, 'customelement')) +def test_customelement(datafiles, tmpdir): + + basedir = os.path.join(datafiles.dirname, datafiles.basename) + pipeline = create_pipeline(tmpdir, basedir, 'simple.bst', None) + assert(pipeline.target.get_kind() == "foo") + + +@pytest.mark.datafiles(os.path.join(DATA_DIR, 'badversionsource')) +def test_badversionsource(datafiles, tmpdir): + basedir = os.path.join(datafiles.dirname, datafiles.basename) + + with pytest.raises(PluginError) as exc: + pipeline = create_pipeline(tmpdir, basedir, 'simple.bst', None) + + +@pytest.mark.datafiles(os.path.join(DATA_DIR, 'badversionelement')) +def test_badversionelement(datafiles, tmpdir): + basedir = os.path.join(datafiles.dirname, datafiles.basename) + + with pytest.raises(PluginError) as exc: + pipeline = create_pipeline(tmpdir, basedir, 'simple.bst', None) -- cgit v1.2.1