| 1 |
#!/usr/bin/env cwl-runner |
| 2 |
id: InputSecondaryFileConformanceTest |
| 3 |
class: CommandLineTool |
| 4 |
cwlVersion: v1.2 |
| 5 |
doc: | |
| 6 |
Simple test to confirm the implementation of expressions returning a File within a CommandInputParameter.secondaryFile field. |
| 7 |
|
| 8 |
Use GREP to filter the result from ls to ensure we only get the secondary files in there. |
| 9 |
|
| 10 |
Related links: |
| 11 |
- Issue: https://github.com/common-workflow-language/cwltool/issues/1232 |
| 12 |
- PR: https://github.com/common-workflow-language/cwltool/pull/1233 |
| 13 |
- Discourse: https://cwl.discourse.group/t/ask-cwl-to-rename-a-secondary-file/72 |
| 14 |
|
| 15 |
inputs: |
| 16 |
- id: inputWithSecondary |
| 17 |
type: File |
| 18 |
doc: | |
| 19 |
This input will with a secondary file `.accessory`. You could create these files (and its accessory) with: |
| 20 |
```bash |
| 21 |
touch secondary_file_test.txt |
| 22 |
touch secondary_file_test.txt.accessory |
| 23 |
``` |
| 24 |
secondaryFiles: |
| 25 |
- | |
| 26 |
${ |
| 27 |
function resolveSecondary(base, secPattern) { |
| 28 |
if (secPattern[0] == '^') { |
| 29 |
var spl = base.split('.'); |
| 30 |
var endIndex = spl.length > 1 ? spl.length - 1 : 1; |
| 31 |
return resolveSecondary(spl.slice(undefined, endIndex).join("."), secPattern.slice(1)); |
| 32 |
} |
| 33 |
return base + secPattern; |
| 34 |
} |
| 35 |
return [{ |
| 36 |
"class": "File", |
| 37 |
"location": inputs.accessory.location, |
| 38 |
"basename": resolveSecondary(self.basename, '^.accessory') |
| 39 |
}]; |
| 40 |
} |
| 41 |
- id: accessory |
| 42 |
type: File |
| 43 |
|
| 44 |
|
| 45 |
arguments: |
| 46 |
- "ls" |
| 47 |
- $(inputs.inputWithSecondary.dirname) |
| 48 |
- valueFrom: "|" |
| 49 |
shellQuote: false |
| 50 |
- "grep" |
| 51 |
- "secondary" |
| 52 |
|
| 53 |
outputs: |
| 54 |
- id: output_file |
| 55 |
type: stdout |
| 56 |
stdout: result |
| 57 |
requirements: |
| 58 |
InlineJavascriptRequirement: {} |
| 59 |
ShellCommandRequirement: {} |