diff options
author | Tristan van Berkom <tristan@codethink.co.uk> | 2020-09-12 17:26:29 +0900 |
---|---|---|
committer | Tristan van Berkom <tristan@codethink.co.uk> | 2020-09-18 12:36:34 +0900 |
commit | 7320a6f58b7542deb2b0c3f27e387fabf6b8d8e7 (patch) | |
tree | 37153ed49d724f925ddf2ea0c472a54780a0f7fc /tests | |
parent | be51483d65e68ee6f6d06a70cd1f3e66af579309 (diff) | |
download | buildstream-7320a6f58b7542deb2b0c3f27e387fabf6b8d8e7.tar.gz |
tests/frontend/overlaps.py: Test CoreWarnings.UNSTAGED_FILES
Diffstat (limited to 'tests')
-rw-r--r-- | tests/frontend/overlaps.py | 18 | ||||
-rw-r--r-- | tests/frontend/overlaps/directory-file.bst | 9 | ||||
-rw-r--r-- | tests/frontend/overlaps/directory-file/directory-file | 1 | ||||
-rw-r--r-- | tests/frontend/overlaps/unstaged.bst | 4 | ||||
-rw-r--r-- | tests/frontend/overlaps/with-directory.bst | 7 | ||||
-rw-r--r-- | tests/frontend/overlaps/with-directory/directory-file/file | 1 |
6 files changed, 38 insertions, 2 deletions
diff --git a/tests/frontend/overlaps.py b/tests/frontend/overlaps.py index 1bf22ab7f..77e9a82c9 100644 --- a/tests/frontend/overlaps.py +++ b/tests/frontend/overlaps.py @@ -13,15 +13,29 @@ from tests.testutils import generate_junction DATA_DIR = os.path.join(os.path.dirname(os.path.realpath(__file__)), "overlaps") -def gen_project(project_dir, fail_on_overlap, *, project_name="test"): +def gen_project(project_dir, fatal_warnings, *, project_name="test"): template = {"name": project_name, "min-version": "2.0"} - template["fatal-warnings"] = [CoreWarnings.OVERLAPS] if fail_on_overlap else [] + template["fatal-warnings"] = [CoreWarnings.OVERLAPS, CoreWarnings.UNSTAGED_FILES] if fatal_warnings else [] projectfile = os.path.join(project_dir, "project.conf") _yaml.roundtrip_dump(template, projectfile) @pytest.mark.datafiles(DATA_DIR) @pytest.mark.parametrize("error", [False, True], ids=["warning", "error"]) +def test_unstaged_files(cli, datafiles, error): + project_dir = str(datafiles) + gen_project(project_dir, error) + result = cli.run(project=project_dir, silent=True, args=["build", "unstaged.bst"]) + if error: + result.assert_main_error(ErrorDomain.STREAM, None) + result.assert_task_error(ErrorDomain.PLUGIN, CoreWarnings.UNSTAGED_FILES) + else: + result.assert_success() + assert "WARNING [unstaged-files]" in result.stderr + + +@pytest.mark.datafiles(DATA_DIR) +@pytest.mark.parametrize("error", [False, True], ids=["warning", "error"]) def test_overlaps(cli, datafiles, error): project_dir = str(datafiles) gen_project(project_dir, error) diff --git a/tests/frontend/overlaps/directory-file.bst b/tests/frontend/overlaps/directory-file.bst new file mode 100644 index 000000000..ab3e98a62 --- /dev/null +++ b/tests/frontend/overlaps/directory-file.bst @@ -0,0 +1,9 @@ +kind: import +config: + source: / + target: / +depends: +- with-directory.bst +sources: +- kind: local + path: "directory-file" diff --git a/tests/frontend/overlaps/directory-file/directory-file b/tests/frontend/overlaps/directory-file/directory-file new file mode 100644 index 000000000..f73f3093f --- /dev/null +++ b/tests/frontend/overlaps/directory-file/directory-file @@ -0,0 +1 @@ +file diff --git a/tests/frontend/overlaps/unstaged.bst b/tests/frontend/overlaps/unstaged.bst new file mode 100644 index 000000000..974bc3fe4 --- /dev/null +++ b/tests/frontend/overlaps/unstaged.bst @@ -0,0 +1,4 @@ +kind: compose + +build-depends: +- directory-file.bst diff --git a/tests/frontend/overlaps/with-directory.bst b/tests/frontend/overlaps/with-directory.bst new file mode 100644 index 000000000..39632580e --- /dev/null +++ b/tests/frontend/overlaps/with-directory.bst @@ -0,0 +1,7 @@ +kind: import +config: + source: / + target: / +sources: +- kind: local + path: "with-directory" diff --git a/tests/frontend/overlaps/with-directory/directory-file/file b/tests/frontend/overlaps/with-directory/directory-file/file new file mode 100644 index 000000000..f73f3093f --- /dev/null +++ b/tests/frontend/overlaps/with-directory/directory-file/file @@ -0,0 +1 @@ +file |