Skip to content

Commit 5ef2516

Browse files
authored
Merge pull request #1164 from common-workflow-language/over_env_preservation
Over env preservation
2 parents 0db44e3 + c1df03a commit 5ef2516

File tree

4 files changed

+33
-6
lines changed

4 files changed

+33
-6
lines changed

cwltool/job.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -442,9 +442,9 @@ def run(self,
442442

443443
env = self.environment
444444
vars_to_preserve = runtimeContext.preserve_environment
445-
if runtimeContext.preserve_entire_environment is not None:
445+
if runtimeContext.preserve_entire_environment is not False:
446446
vars_to_preserve = os.environ
447-
if vars_to_preserve is not None:
447+
if vars_to_preserve:
448448
for key, value in os.environ.items():
449449
if key in vars_to_preserve and key not in env:
450450
# On Windows, subprocess env can't handle unicode.

release-test.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export HEAD=${TRAVIS_PULL_REQUEST_SHA:-$(git rev-parse HEAD)}
3737

3838
if [ "${RELEASE_SKIP}" != "head" ]
3939
then
40-
virtualenv testenv1
40+
virtualenv testenv1 -p python3
4141
# First we test the head
4242
# shellcheck source=/dev/null
4343
source testenv1/bin/activate
@@ -58,9 +58,9 @@ then
5858
test_prefix=../ run_tests; popd
5959
fi
6060

61-
virtualenv testenv2
62-
virtualenv testenv3
63-
virtualenv testenv4
61+
virtualenv testenv2 -p python3
62+
virtualenv testenv3 -p python3
63+
virtualenv testenv4 -p python3
6464
rm -Rf testenv[234]/local
6565

6666
# Secondly we test via pip

tests/env.cwl

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
cwlVersion: v1.0
2+
class: CommandLineTool
3+
inputs: []
4+
requirements:
5+
ShellCommandRequirement: {}
6+
baseCommand: echo
7+
arguments:
8+
- valueFrom: >
9+
{\\"env_count\\": \$(env | wc -l)}
10+
shellQuote: False
11+
stdout: cwl.output.json
12+
outputs:
13+
env_count: int

tests/test_examples.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -931,3 +931,17 @@ def test_optional_numeric_output_0():
931931
assert "completed success" in stderr
932932
assert error_code == 0
933933
assert json.loads(stdout)['out'] == 0
934+
935+
@windows_needs_docker
936+
def test_env_filtering():
937+
test_file = "tests/env.cwl"
938+
error_code, stdout, stderr = get_main_output(
939+
[get_data(test_file)])
940+
941+
assert "completed success" in stderr, (error_code, stdout, stderr)
942+
assert error_code == 0, (error_code, stdout, stderr)
943+
if onWindows():
944+
target = 5
945+
else:
946+
target = 4
947+
assert json.loads(stdout)['env_count'] == target, (error_code, stdout, stderr)

0 commit comments

Comments
 (0)