summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2018-01-02 17:37:19 +0900
committerTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2018-01-02 17:38:55 +0900
commit5084e66277d57398d9feb4f161fa8e114968cbe1 (patch)
tree88ccd386d8e4075d6e29373df8b4d539209db865
parent6f0b620f2473c33cc610130ed29382d9e4c63fb2 (diff)
downloadbuildstream-5084e66277d57398d9feb4f161fa8e114968cbe1.tar.gz
tests/sources/local.py: Adding test for staging a symlink.
This has remained without test coverage mostly due to upstream pytest-datafiles bug https://github.com/omarkohl/pytest-datafiles/issues/1
-rw-r--r--tests/sources/local.py26
-rw-r--r--tests/sources/local/symlink/files/file.txt1
-rw-r--r--tests/sources/local/symlink/project.conf2
-rw-r--r--tests/sources/local/symlink/target.bst5
4 files changed, 34 insertions, 0 deletions
diff --git a/tests/sources/local.py b/tests/sources/local.py
index 4fe941b35..bfddf6881 100644
--- a/tests/sources/local.py
+++ b/tests/sources/local.py
@@ -55,6 +55,32 @@ def test_stage_directory(cli, tmpdir, datafiles):
assert(os.path.exists(os.path.join(checkoutdir, 'subdir', 'anotherfile.txt')))
+@pytest.mark.datafiles(os.path.join(DATA_DIR, 'symlink'))
+def test_stage_symlink(cli, tmpdir, datafiles):
+
+ project = os.path.join(datafiles.dirname, datafiles.basename)
+ checkoutdir = os.path.join(str(tmpdir), "checkout")
+
+ # Workaround datafiles bug:
+ #
+ # https://github.com/omarkohl/pytest-datafiles/issues/1
+ #
+ # Create the symlink by hand.
+ symlink = os.path.join(project, 'files', 'symlink-to-file.txt')
+ os.symlink('file.txt', symlink)
+
+ # Build, checkout
+ result = cli.run(project=project, args=['build', 'target.bst'])
+ result.assert_success()
+ result = cli.run(project=project, args=['checkout', 'target.bst', checkoutdir])
+ result.assert_success()
+
+ # 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, 'symlink-to-file.txt')))
+ assert(os.path.islink(os.path.join(checkoutdir, 'symlink-to-file.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)
diff --git a/tests/sources/local/symlink/files/file.txt b/tests/sources/local/symlink/files/file.txt
new file mode 100644
index 000000000..5cbed1a2f
--- /dev/null
+++ b/tests/sources/local/symlink/files/file.txt
@@ -0,0 +1 @@
+I'm a text file
diff --git a/tests/sources/local/symlink/project.conf b/tests/sources/local/symlink/project.conf
new file mode 100644
index 000000000..afa0f5475
--- /dev/null
+++ b/tests/sources/local/symlink/project.conf
@@ -0,0 +1,2 @@
+# Basic project
+name: foo
diff --git a/tests/sources/local/symlink/target.bst b/tests/sources/local/symlink/target.bst
new file mode 100644
index 000000000..a4e51e82a
--- /dev/null
+++ b/tests/sources/local/symlink/target.bst
@@ -0,0 +1,5 @@
+kind: import
+description: This is the pony
+sources:
+- kind: local
+ path: files