summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTristan van Berkom <tristan@codethink.co.uk>2020-09-12 17:26:29 +0900
committerTristan van Berkom <tristan@codethink.co.uk>2020-09-15 16:11:31 +0900
commitf145c87cad12bde43a110c3a0c47effd54f0dffe (patch)
treec68dd01b61400b045b25e34a33ab4cd1a80754a6
parent2de37e91599ed42482922c13b2405f75ce46e428 (diff)
downloadbuildstream-tristan/multi-location-overlaps.tar.gz
tests/frontend/overlaps.py: Test CoreWarnings.UNSTAGED_FILEStristan/multi-location-overlaps
-rw-r--r--tests/frontend/overlaps.py18
-rw-r--r--tests/frontend/overlaps/directory-file.bst9
-rw-r--r--tests/frontend/overlaps/directory-file/directory-file1
-rw-r--r--tests/frontend/overlaps/unstaged.bst4
-rw-r--r--tests/frontend/overlaps/with-directory.bst7
-rw-r--r--tests/frontend/overlaps/with-directory/directory-file/file1
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