Skip to content

Commit

Permalink
Add test for filename conflict resolution
Browse files Browse the repository at this point in the history
Added a test that verifies that the fix in DataBiosphere#4101 avoids incorrect filename conflict resolution.
  • Loading branch information
gmloose committed Jun 15, 2022
1 parent 9e2ae24 commit c9502a4
Show file tree
Hide file tree
Showing 15 changed files with 50 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/toil/test/cwl/cwlTest.py
Expand Up @@ -996,6 +996,25 @@ def test_log_dir_echo_stderr(self) -> None:
output = open(result).read()
assert output == "hello\n"

def test_filename_conflict_resolution(self):
toil = "toil-cwl-runner"
options = [
f"--outdir={self.out_dir}",
"--clean=always",
]
cwl = os.path.join(
os.path.dirname(__file__), "test_filename_conflict_resolution.cwl"
)
input = os.path.join(os.path.dirname(__file__), "test_filename_conflict_resolution.ms")
output = input + '.sector_*'
cwl_inputs = [
"--msin", input
]
cmd = [toil] + options + [cwl] + cwl_inputs
p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
stdout, stderr = p.communicate()
assert b"Finished toil run successfully" in stderr
assert p.returncode == 0

@needs_cwl
class CWLSmallTests(ToilTest):
Expand Down
31 changes: 31 additions & 0 deletions src/toil/test/cwl/test_filename_conflict_resolution.cwl
@@ -0,0 +1,31 @@
cwlVersion: v1.2
class: CommandLineTool
baseCommand:
- python
- copier.py

requirements:
- class: InlineJavascriptRequirement
- class: InitialWorkDirRequirement
listing:
- entryname: copier.py
entry: |
import os, subprocess, sys
msin = sys.argv[1]
root = os.path.basename(msin) + '.sector'
for i in range(2):
msout = f"{root}_{i}"
print(f"Copying: {msin} -> {msout}")
subprocess.check_call(['cp', '-r', '-L', '--no-preserve=mode', msin, msout])

inputs:
- id: msin
type: Directory
inputBinding:
position: 0

outputs:
- id: msout
type: Directory[]
outputBinding:
glob: ['$(inputs.msin.basename).sector_*']
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.

0 comments on commit c9502a4

Please sign in to comment.