summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2018-01-02 16:59:45 +0900
committerTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2018-01-02 17:38:55 +0900
commit6f0b620f2473c33cc610130ed29382d9e4c63fb2 (patch)
treedc471ed53d92c8206f10932ebfa13f5b8fd16699
parented9a94a4c8a524c6fe41397ac490b8b0a747ba90 (diff)
downloadbuildstream-6f0b620f2473c33cc610130ed29382d9e4c63fb2.tar.gz
tests/sources/local.py: Testing failures to create staging directories
Seems that local.py is an appropriate plugin to use for testing errors which originate from the abstract Source class. This test checks that we raise the appropriate error in the case that we attempt to stage to a directory that is a regular file.
-rw-r--r--tests/sources/local.py11
-rw-r--r--tests/sources/local/file-exists/files/file.txt1
-rw-r--r--tests/sources/local/file-exists/project.conf2
-rw-r--r--tests/sources/local/file-exists/target.bst14
4 files changed, 28 insertions, 0 deletions
diff --git a/tests/sources/local.py b/tests/sources/local.py
index 9cb76bc87..4fe941b35 100644
--- a/tests/sources/local.py
+++ b/tests/sources/local.py
@@ -53,3 +53,14 @@ def test_stage_directory(cli, tmpdir, datafiles):
# Check that the checkout contains the expected file and directory and other file
assert(os.path.exists(os.path.join(checkoutdir, 'file.txt')))
assert(os.path.exists(os.path.join(checkoutdir, 'subdir', 'anotherfile.txt')))
+
+
+@pytest.mark.datafiles(os.path.join(DATA_DIR, 'file-exists'))
+def test_stage_file_exists(cli, tmpdir, datafiles):
+ project = os.path.join(datafiles.dirname, datafiles.basename)
+ checkoutdir = os.path.join(str(tmpdir), "checkout")
+
+ # Build, checkout
+ result = cli.run(project=project, args=['build', 'target.bst'])
+ result.assert_main_error(ErrorDomain.PIPELINE, None)
+ result.assert_task_error(ErrorDomain.SOURCE, 'ensure-stage-dir-fail')
diff --git a/tests/sources/local/file-exists/files/file.txt b/tests/sources/local/file-exists/files/file.txt
new file mode 100644
index 000000000..5cbed1a2f
--- /dev/null
+++ b/tests/sources/local/file-exists/files/file.txt
@@ -0,0 +1 @@
+I'm a text file
diff --git a/tests/sources/local/file-exists/project.conf b/tests/sources/local/file-exists/project.conf
new file mode 100644
index 000000000..afa0f5475
--- /dev/null
+++ b/tests/sources/local/file-exists/project.conf
@@ -0,0 +1,2 @@
+# Basic project
+name: foo
diff --git a/tests/sources/local/file-exists/target.bst b/tests/sources/local/file-exists/target.bst
new file mode 100644
index 000000000..9e36fa41b
--- /dev/null
+++ b/tests/sources/local/file-exists/target.bst
@@ -0,0 +1,14 @@
+kind: import
+description: |
+
+ This is the regular file staged twice, second time we stage into a subdir
+ of the staging area. The subdir we specify is the file we already staged,
+ provoking a plausible error where the user tries to stage something
+ unreasonable.
+
+sources:
+- kind: local
+ path: files/file.txt
+- kind: local
+ path: files/file.txt
+ directory: file.txt