Skip to content

Commit 9e7c68c

Browse files
authored
Merge pull request #1197 from common-workflow-language/better_env_test
attempt to debug test failure on reproducible-builds.org
2 parents 03af16c + 19c55b9 commit 9e7c68c

File tree

6 files changed

+44
-6
lines changed

6 files changed

+44
-6
lines changed

tests/env.cwl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#!/usr/bin/env cwl-runner
12
cwlVersion: v1.0
23
class: CommandLineTool
34
inputs: []

tests/env2.cwl

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

tests/secondary-files-string-v1.cwl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#!/usr/bin/env cwl-runner
12
cwlVersion: v1.0
23
class: CommandLineTool
34
baseCommand:
@@ -16,4 +17,4 @@ outputs:
1617
type: File
1718
secondaryFiles: ^.fastq
1819
outputBinding:
19-
glob: $(inputs.fasta_path.basename)
20+
glob: $(inputs.fasta_path.basename)

tests/test_examples.py

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
from cwltool.resolver import Path
2323
from cwltool.process import CWL_IANA
2424
from cwltool.sandboxjs import JavascriptException
25-
from .util import (get_data, get_main_output, get_windows_safe_factory,
25+
from .util import (get_data, get_main_output, get_windows_safe_factory, subprocess,
2626
needs_docker, working_directory, needs_singularity, temp_dir, windows_needs_docker)
2727

2828
import six
@@ -1011,13 +1011,33 @@ def test_env_filtering(factor):
10111011
commands.extend([get_data(test_file)])
10121012
error_code, stdout, stderr = get_main_output(commands)
10131013

1014+
process = subprocess.Popen(["sh", "-c", r"""getTrueShellExeName() {
1015+
local trueExe nextTarget 2>/dev/null
1016+
trueExe=$(ps -o comm= $$) || return 1
1017+
[ "${trueExe#-}" = "$trueExe" ] || trueExe=${trueExe#-}
1018+
[ "${trueExe#/}" != "$trueExe" ] || trueExe=$([ -n "$ZSH_VERSION" ] && which -p "$trueExe" || which "$trueExe")
1019+
while nextTarget=$(readlink "$trueExe"); do trueExe=$nextTarget; done
1020+
printf '%s\n' "$(basename "$trueExe")"
1021+
} ; getTrueShellExeName"""], stdout=subprocess.PIPE, stderr=subprocess.PIPE, env=None)
1022+
sh_name, sh_name_err = process.communicate()
1023+
sh_name = sh_name.decode('utf-8').strip()
1024+
10141025
assert "completed success" in stderr, (error_code, stdout, stderr)
10151026
assert error_code == 0, (error_code, stdout, stderr)
10161027
if onWindows():
10171028
target = 5
1018-
else:
1029+
elif sh_name == "dash":
10191030
target = 4
1020-
assert json.loads(stdout)['env_count'] == target, (error_code, stdout, stderr)
1031+
else: # bash adds "SHLVL" and "_" environment variables
1032+
target = 6
1033+
result = json.loads(stdout)['env_count']
1034+
details = ''
1035+
if result != target:
1036+
_, details, _ = get_main_output(["--quiet", get_data("tests/env2.cwl")])
1037+
print(sh_name)
1038+
print(sh_name_err)
1039+
print(details)
1040+
assert result == target, (error_code, sh_name, sh_name_err, details, stdout, stderr)
10211041

10221042
@windows_needs_docker
10231043
def test_v1_0_arg_empty_prefix_separate_false():

tests/trs/md5sum-workflow.cwl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#!/usr/bin/env cwl-runner
12
cwlVersion: v1.0
23
class: Workflow
34

@@ -14,4 +15,4 @@ steps:
1415
run: md5sum-tool.cwl
1516
in:
1617
input_file: input_file
17-
out: [output_file]
18+
out: [output_file]

tests/wf/optional-numerical-output-0.cwl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#!/usr/bin/env cwl-runner
12
cwlVersion: v1.0
23
class: CommandLineTool
34
baseCommand:
@@ -13,4 +14,4 @@ outputs:
1314
outputBinding:
1415
glob: "a.txt"
1516
loadContents: true
16-
outputEval: "${\n return parseFloat(self[0].contents);\n}"
17+
outputEval: "${\n return parseFloat(self[0].contents);\n}"

0 commit comments

Comments
 (0)