diff options
author | Tristan Van Berkom <tristan.vanberkom@codethink.co.uk> | 2017-12-13 11:49:39 -0500 |
---|---|---|
committer | Tristan Van Berkom <tristan.vanberkom@codethink.co.uk> | 2017-12-13 12:36:41 -0500 |
commit | 683a6d406aa91d1cf51e0fd6b1adf3f1ff77eac6 (patch) | |
tree | 09acc4c0d48d6b2d522a118ca271eb770aae3506 /tests | |
parent | fd92ebc9267f51b6b84b17a7ef6f4bde535436e1 (diff) | |
download | buildstream-683a6d406aa91d1cf51e0fd6b1adf3f1ff77eac6.tar.gz |
Adapting test cases to expect logs in stderr
And also adapted them to remove any occurrences of HAVE_ROOT.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/context/context.py | 4 | ||||
-rw-r--r-- | tests/frontend/buildtrack.py | 6 | ||||
-rw-r--r-- | tests/frontend/overlaps.py | 6 | ||||
-rw-r--r-- | tests/frontend/show.py | 10 | ||||
-rw-r--r-- | tests/plugins/pipeline.py | 14 | ||||
-rw-r--r-- | tests/project/plugins.py | 10 | ||||
-rw-r--r-- | tests/sources/tar.py | 2 | ||||
-rw-r--r-- | tests/sources/zip.py | 2 | ||||
-rw-r--r-- | tests/variables/variables.py | 11 |
9 files changed, 27 insertions, 38 deletions
diff --git a/tests/context/context.py b/tests/context/context.py index 0db589a1a..442069bf6 100644 --- a/tests/context/context.py +++ b/tests/context/context.py @@ -4,8 +4,6 @@ import pytest from buildstream._context import Context from buildstream._exceptions import LoadError, LoadErrorReason -from tests.testutils.site import HAVE_ROOT - DATA_DIR = os.path.join( os.path.dirname(os.path.realpath(__file__)), 'data', @@ -37,7 +35,6 @@ def test_context_create(context_fixture): ####################################### # Test configuration loading # ####################################### -@pytest.mark.skipif(not HAVE_ROOT, reason="requires root permissions") def test_context_load(context_fixture): context = context_fixture['context'] cache_home = context_fixture['xdg-cache'] @@ -52,7 +49,6 @@ def test_context_load(context_fixture): # Test that values in a user specified config file # override the defaults -@pytest.mark.skipif(not HAVE_ROOT, reason="requires root permissions") @pytest.mark.datafiles(os.path.join(DATA_DIR)) def test_context_load_user_config(context_fixture, datafiles): context = context_fixture['context'] diff --git a/tests/frontend/buildtrack.py b/tests/frontend/buildtrack.py index e91274a29..45dd30d82 100644 --- a/tests/frontend/buildtrack.py +++ b/tests/frontend/buildtrack.py @@ -300,12 +300,12 @@ def test_build_track_track_first(cli, datafiles, tmpdir, strict): assert result.exit_code == 0 # Assert that 1.bst successfully tracks before 0.bst builds - track_messages = re.finditer(r'\[track:1.bst\s*]', result.output) - build_0 = re.search(r'\[build:0.bst\s*] START', result.output).start() + track_messages = re.finditer(r'\[track:1.bst\s*]', result.stderr) + build_0 = re.search(r'\[build:0.bst\s*] START', result.stderr).start() assert all(track_message.start() < build_0 for track_message in track_messages) # Assert that 2.bst is *only* rebuilt if we are in strict mode - build_2 = re.search(r'\[build:2.bst\s*] START', result.output) + build_2 = re.search(r'\[build:2.bst\s*] START', result.stderr) if strict == '--strict': assert build_2 is not None else: diff --git a/tests/frontend/overlaps.py b/tests/frontend/overlaps.py index cc7c08fa6..4ef5657fb 100644 --- a/tests/frontend/overlaps.py +++ b/tests/frontend/overlaps.py @@ -17,6 +17,6 @@ def test_overlaps(cli, datafiles): assert result.exit_code == 0 print(result.output) - assert "/file1: three.bst above one.bst" in result.output - assert "/file2: two.bst above three.bst above one.bst" in result.output - assert "/file3: two.bst above three.bst" in result.output + assert "/file1: three.bst above one.bst" in result.stderr + assert "/file2: two.bst above three.bst above one.bst" in result.stderr + assert "/file3: two.bst above three.bst" in result.stderr diff --git a/tests/frontend/show.py b/tests/frontend/show.py index fde620137..2c2f03d96 100644 --- a/tests/frontend/show.py +++ b/tests/frontend/show.py @@ -70,9 +70,8 @@ def test_parallel_order(cli, tmpdir, datafiles): assert result.exit_code == 0 - # Get the planned order, excepting the 'Loading' messages before - # the pipeline is printed - names = result.output.splitlines()[3:] + # Get the planned order + names = result.output.splitlines() names = [name[len('multiple_targets/order/'):] for name in names] # Create all possible 'correct' topological orderings @@ -100,9 +99,8 @@ def test_target_is_dependency(cli, tmpdir, datafiles): assert result.exit_code == 0 - # Get the planned order, excepting the 'Loading' messages before - # the pipeline is printed - names = result.output.splitlines()[3:] + # Get the planned order + names = result.output.splitlines() names = [name[len('multiple_targets/dependency/'):] for name in names] assert names == ['pony.bst', 'horsey.bst', 'zebry.bst'] diff --git a/tests/plugins/pipeline.py b/tests/plugins/pipeline.py index c659aa34e..a77dcd1d2 100644 --- a/tests/plugins/pipeline.py +++ b/tests/plugins/pipeline.py @@ -5,9 +5,6 @@ from buildstream._context import Context from buildstream._project import Project from buildstream._exceptions import PluginError from buildstream._pipeline import Pipeline -from buildstream._platform import Platform - -from tests.testutils.site import HAVE_ROOT DATA_DIR = os.path.join( os.path.dirname(os.path.realpath(__file__)), @@ -18,15 +15,17 @@ DATA_DIR = os.path.join( def create_pipeline(tmpdir, basedir, target): context = Context([]) project = Project(basedir, context) - context.deploydir = os.path.join(str(tmpdir), 'deploy') context.artifactdir = os.path.join(str(tmpdir), 'artifact') - context._platform = Platform.get_platform() + + def dummy_handler(message, context): + pass + + context._set_message_handler(dummy_handler) return Pipeline(context, project, [target], []) -@pytest.mark.skipif(not HAVE_ROOT, reason="requires root permissions") @pytest.mark.datafiles(os.path.join(DATA_DIR, 'customsource')) def test_customsource(datafiles, tmpdir): @@ -35,7 +34,6 @@ def test_customsource(datafiles, tmpdir): assert(pipeline.targets[0].get_kind() == "autotools") -@pytest.mark.skipif(not HAVE_ROOT, reason="requires root permissions") @pytest.mark.datafiles(os.path.join(DATA_DIR, 'customelement')) def test_customelement(datafiles, tmpdir): @@ -44,7 +42,6 @@ def test_customelement(datafiles, tmpdir): assert(pipeline.targets[0].get_kind() == "foo") -@pytest.mark.skipif(not HAVE_ROOT, reason="requires root permissions") @pytest.mark.datafiles(os.path.join(DATA_DIR, 'badversionsource')) def test_badversionsource(datafiles, tmpdir): basedir = os.path.join(datafiles.dirname, datafiles.basename) @@ -53,7 +50,6 @@ def test_badversionsource(datafiles, tmpdir): pipeline = create_pipeline(tmpdir, basedir, 'simple.bst') -@pytest.mark.skipif(not HAVE_ROOT, reason="requires root permissions") @pytest.mark.datafiles(os.path.join(DATA_DIR, 'badversionelement')) def test_badversionelement(datafiles, tmpdir): basedir = os.path.join(datafiles.dirname, datafiles.basename) diff --git a/tests/project/plugins.py b/tests/project/plugins.py index 7932fcd6a..4040137c1 100644 --- a/tests/project/plugins.py +++ b/tests/project/plugins.py @@ -4,9 +4,6 @@ import pytest from buildstream._context import Context from buildstream._project import Project from buildstream._pipeline import Pipeline -from buildstream._platform import Platform - -from tests.testutils.site import HAVE_ROOT DATA_DIR = os.path.join( os.path.dirname(os.path.realpath(__file__)), @@ -18,7 +15,11 @@ def create_pipeline(tmpdir, basedir, target): context = Context([]) project = Project(basedir, context) context.artifactdir = os.path.join(str(tmpdir), 'artifact') - context._platform = Platform.get_platform() + + def dummy_handler(message, context): + pass + + context._set_message_handler(dummy_handler) return Pipeline(context, project, [target], []) @@ -29,7 +30,6 @@ def create_pipeline(tmpdir, basedir, target): # also test that the project's configuration of plugin # paths is actually working. # -@pytest.mark.skipif(not HAVE_ROOT, reason="requires root permissions") @pytest.mark.datafiles(os.path.join(DATA_DIR, 'plugins')) def test_custom_element(datafiles, tmpdir): diff --git a/tests/sources/tar.py b/tests/sources/tar.py index b1859a81a..ca1bef7da 100644 --- a/tests/sources/tar.py +++ b/tests/sources/tar.py @@ -104,7 +104,7 @@ def test_track_warning(cli, tmpdir, datafiles): 'track', 'target.bst' ]) assert result.exit_code == 0 - assert "Potential man-in-the-middle attack!" in result.output + assert "Potential man-in-the-middle attack!" in result.stderr def _list_dir_contents(srcdir): diff --git a/tests/sources/zip.py b/tests/sources/zip.py index 2fd0c04aa..70ad491ff 100644 --- a/tests/sources/zip.py +++ b/tests/sources/zip.py @@ -91,7 +91,7 @@ def test_track_warning(cli, tmpdir, datafiles): 'track', 'target.bst' ]) assert result.exit_code == 0 - assert "Potential man-in-the-middle attack!" in result.output + assert "Potential man-in-the-middle attack!" in result.stderr def _list_dir_contents(srcdir): diff --git a/tests/variables/variables.py b/tests/variables/variables.py index 47b1ff9c9..24f323c69 100644 --- a/tests/variables/variables.py +++ b/tests/variables/variables.py @@ -5,9 +5,6 @@ from buildstream import BuildElement from buildstream._context import Context from buildstream._project import Project from buildstream._pipeline import Pipeline -from buildstream._platform import Platform - -from tests.testutils.site import HAVE_ROOT DATA_DIR = os.path.join( os.path.dirname(os.path.realpath(__file__)), @@ -18,7 +15,11 @@ def create_pipeline(tmpdir, basedir, target): context = Context([]) project = Project(basedir, context) context.artifactdir = os.path.join(str(tmpdir), 'artifact') - context._platform = Platform.get_platform() + + def dummy_handler(message, context): + pass + + context._set_message_handler(dummy_handler) return Pipeline(context, project, [target], []) @@ -41,7 +42,6 @@ def assert_command(datafiles, tmpdir, target, command, expected): ############################################################### # Test proper loading of some default commands from plugins # ############################################################### -@pytest.mark.skipif(not HAVE_ROOT, reason="requires root permissions") @pytest.mark.parametrize("target,command,expected", [ ('autotools.bst', 'install-commands', "make -j1 DESTDIR=\"/buildstream/install\" install"), ('cmake.bst', 'configure-commands', @@ -62,7 +62,6 @@ def test_defaults(datafiles, tmpdir, target, command, expected): ################################################################ # Test overriding of variables to produce different commands # ################################################################ -@pytest.mark.skipif(not HAVE_ROOT, reason="requires root permissions") @pytest.mark.parametrize("target,command,expected", [ ('autotools.bst', 'install-commands', "make -j1 DESTDIR=\"/custom/install/root\" install"), ('cmake.bst', 'configure-commands', |