summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2018-02-23 21:26:46 +0900
committerTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2018-02-24 18:29:57 +0900
commit29009193c05b1bd408f49fa3d0a7ba7bf5cefbe9 (patch)
tree536c267337b64642fb27f7f558d54830d39e0e4f
parent94e54fbdc60e2f0000e640e4410611580a86ec46 (diff)
downloadbuildstream-29009193c05b1bd408f49fa3d0a7ba7bf5cefbe9.tar.gz
tests/integration/shell.py: Added tests for inheriting environment variables
-rw-r--r--tests/integration/project/project.conf7
-rw-r--r--tests/integration/shell.py20
2 files changed, 27 insertions, 0 deletions
diff --git a/tests/integration/project/project.conf b/tests/integration/project/project.conf
index a677129fb..6a2c149bf 100644
--- a/tests/integration/project/project.conf
+++ b/tests/integration/project/project.conf
@@ -14,3 +14,10 @@ split-rules:
test:
- |
/tests/*
+
+# Allow inheriting a host environment variable
+# in `bst shell` for the shell test
+#
+shell:
+ inherit-environment:
+ - ANIMAL
diff --git a/tests/integration/shell.py b/tests/integration/shell.py
index 7e9c5afd3..341ad7e3d 100644
--- a/tests/integration/shell.py
+++ b/tests/integration/shell.py
@@ -55,6 +55,26 @@ def test_executable(cli, tmpdir, datafiles):
assert result.output == "Horseys!\n"
+# Test host environment variable inheritance
+@pytest.mark.parametrize("animal", [("Horse"), ("Pony")])
+@pytest.mark.datafiles(DATA_DIR)
+def test_inherit(cli, tmpdir, datafiles, animal):
+ project = os.path.join(datafiles.dirname, datafiles.basename)
+
+ # Set the env var, and expect the same with added newline
+ os.environ['ANIMAL'] = animal
+ expected = animal + '\n'
+
+ # Dont use the execute_shell() with shlex, that screws with the args
+ result = cli.run(project=project, args=['build', 'base.bst'])
+ assert result.exit_code == 0
+
+ return cli.run(project=project,
+ args=['shell', 'base.bst', '--', 'echo', '${ANIMAL}'])
+ assert result.exit_code == 0
+ assert result.output == expected
+
+
# Test running an executable in a runtime with no shell (i.e., no
# /bin/sh)
@pytest.mark.datafiles(DATA_DIR)