You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@buildstream.apache.org by no...@apache.org on 2020/12/29 12:26:04 UTC

[buildstream] 09/09: tests/frontend/overlaps.py: Test CoreWarnings.UNSTAGED_FILES

This is an automated email from the ASF dual-hosted git repository.

not-in-ldap pushed a commit to branch tristan/multi-location-overlaps
in repository https://gitbox.apache.org/repos/asf/buildstream.git

commit f145c87cad12bde43a110c3a0c47effd54f0dffe
Author: Tristan van Berkom <tr...@codethink.co.uk>
AuthorDate: Sat Sep 12 17:26:29 2020 +0900

    tests/frontend/overlaps.py: Test CoreWarnings.UNSTAGED_FILES
---
 tests/frontend/overlaps.py                             | 18 ++++++++++++++++--
 tests/frontend/overlaps/directory-file.bst             |  9 +++++++++
 tests/frontend/overlaps/directory-file/directory-file  |  1 +
 tests/frontend/overlaps/unstaged.bst                   |  4 ++++
 tests/frontend/overlaps/with-directory.bst             |  7 +++++++
 .../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 1bf22ab7..77e9a82 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 0000000..ab3e98a
--- /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 0000000..f73f309
--- /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 0000000..974bc3f
--- /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 0000000..3963258
--- /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 0000000..f73f309
--- /dev/null
+++ b/tests/frontend/overlaps/with-directory/directory-file/file
@@ -0,0 +1 @@
+file