diff options
author | Tristan Van Berkom <tristan.vanberkom@codethink.co.uk> | 2018-03-06 19:33:22 +0900 |
---|---|---|
committer | Tristan Van Berkom <tristan.vanberkom@codethink.co.uk> | 2018-03-06 19:33:22 +0900 |
commit | 7ed0351a4e15ae6d8fd4d79dded5e9a45548d238 (patch) | |
tree | 7a41763a816dffbdaa5577c9f88bbf75fb34fd4b /tests/integration/shell.py | |
parent | ea74f326fb75c4b4b6378987ede884b47ac9e09c (diff) | |
download | buildstream-7ed0351a4e15ae6d8fd4d79dded5e9a45548d238.tar.gz |
tests/integration/shell.py: Testing new shell environment configuration
Diffstat (limited to 'tests/integration/shell.py')
-rw-r--r-- | tests/integration/shell.py | 44 |
1 files changed, 42 insertions, 2 deletions
diff --git a/tests/integration/shell.py b/tests/integration/shell.py index 55528ab92..49a97a6d0 100644 --- a/tests/integration/shell.py +++ b/tests/integration/shell.py @@ -68,7 +68,7 @@ def test_executable(cli, tmpdir, datafiles): # Test host environment variable inheritance @pytest.mark.parametrize("animal", [("Horse"), ("Pony")]) @pytest.mark.datafiles(DATA_DIR) -def test_inherit(cli, tmpdir, datafiles, animal): +def test_env_inherit(cli, tmpdir, datafiles, animal): project = os.path.join(datafiles.dirname, datafiles.basename) # Set the env var, and expect the same with added newline @@ -85,10 +85,50 @@ def test_inherit(cli, tmpdir, datafiles, animal): assert result.output == expected +# Test shell environment variable explicit assignments +@pytest.mark.parametrize("animal", [("Horse"), ("Pony")]) +@pytest.mark.datafiles(DATA_DIR) +def test_env_assign(cli, tmpdir, datafiles, animal): + project = os.path.join(datafiles.dirname, datafiles.basename) + expected = animal + '\n' + + result = execute_shell(cli, project, ['/bin/sh', '-c', 'echo ${ANIMAL}'], config={ + 'shell': { + 'environment': { + 'ANIMAL': animal + } + } + }) + + assert result.exit_code == 0 + assert result.output == expected + + +# Test shell environment variable explicit assignments with host env var expansion +@pytest.mark.parametrize("animal", [("Horse"), ("Pony")]) +@pytest.mark.datafiles(DATA_DIR) +def test_env_assign_expand_host_environ(cli, tmpdir, datafiles, animal): + project = os.path.join(datafiles.dirname, datafiles.basename) + expected = 'The animal is: {}\n'.format(animal) + + os.environ['BEAST'] = animal + + result = execute_shell(cli, project, ['/bin/sh', '-c', 'echo ${ANIMAL}'], config={ + 'shell': { + 'environment': { + 'ANIMAL': 'The animal is: ${BEAST}' + } + } + }) + + assert result.exit_code == 0 + assert result.output == expected + + # Test that environment variable inheritance is disabled with --isolate @pytest.mark.parametrize("animal", [("Horse"), ("Pony")]) @pytest.mark.datafiles(DATA_DIR) -def test_isolated_no_inherit(cli, tmpdir, datafiles, animal): +def test_env_isolated_no_inherit(cli, tmpdir, datafiles, animal): project = os.path.join(datafiles.dirname, datafiles.basename) # Set the env var, but expect that it is not applied |