Skip to content

Commit e4ebce6

Browse files
committed
Document how to write a new conformance test
and better explain the format of that file and better how to invoke ./run-tests.sh
1 parent 5f27e23 commit e4ebce6

File tree

1 file changed

+127
-9
lines changed

1 file changed

+127
-9
lines changed

CONFORMANCE_TESTS.md

Lines changed: 127 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,35 +15,153 @@ All tests passed
1515

1616
## Options
1717

18-
RUNNER=other-cwl-runner
18+
`RUNNER=other-cwl-runner`
1919

2020
The CWL implementation to be tested.
2121

22-
-nN
22+
### Test Selection
2323

24-
Run a single specific test number N.
24+
`--tags`
2525

26-
EXTRA=--parallel
26+
A comma separated list of [tags](#tags-for-conformance-tests); only tests with these tags will be tested.
27+
`--tags shell_command` will run all tests with `shell_command` in their `tags` list.
2728

28-
Extra options to pass to the CWL runner
29+
`-n{test_range}`
2930

30-
For example, to run conformance test 15 against the "cwltool"
31-
reference implementation with `--parallel`:
31+
Run only the specific test numbers. `{test_range}` is a comma separated list of
32+
single test numbers and/or numeric ranges.
33+
`-n5-7,15` == only runs the 5th, 6th, 7th, and 15th tests.
34+
35+
`-N{test_range}`
36+
37+
Like the lowercase `-n` option, except that the specified tests will not be run.
38+
Can be mixed with the other test selectors: `-n5-7,15 -N6` == only runs the 5th, 7th, and 15th tests, skipping the 6th test.
39+
40+
`-s{test_names}`
41+
42+
Run the specific tests according to their `label`s. `{test_names}` is a comma separated list of
43+
test labels. `-scl_optional_bindings_provided,stdout_redirect_docker,expression_any_null`
44+
achieves the same effect as `-n5-7,15 -N6` and it will still work if the tests are re-ordered.
45+
46+
`-S{test_names}`
47+
48+
Excludes specific tests according to their `label`s. `{test_names}` is a comma separated list of
49+
test labels. `--tags shell_command -Sstderr_redirect_shortcut` will run all test with `expression_tool`
50+
in their `tags` list except the test with the label `stderr_redirect_shortcut`.
51+
52+
### Misc
53+
54+
`EXTRA="--parallel --singularity"`
55+
56+
Extra options to pass to the CWL runner (check your runner for exact options)
57+
58+
`-j=4`
59+
60+
The number of different tests to run at the same time
61+
62+
`--junit-xml=FILENAME`
63+
64+
Store results in JUnit XML format using the given FILENAME.
65+
66+
`--classname=CLASSNAME`
67+
68+
In the JUnit XML, tag the results with the given CLASSNAME.
69+
Can be useful when multiple test runs are combined to document the differences in `EXTRA=`.
70+
71+
---
72+
73+
For example, to run conformance test 15,16,17, and 20 against the "cwltool"
74+
reference implementation using the `podman` container engine
75+
and parallel execution of workflow steps
3276

3377
```bash
34-
$ ./run_test.sh RUNNER=cwltool -n15 EXTRA=--parallel
78+
$ ./run_test.sh RUNNER=cwltool -n15-17,20 EXTRA="--parallel --podman"
3579
Test [15/49]
80+
Test [16/49]
81+
Test [17/49]
82+
Test [20/49]
3683
All tests passed
3784
```
3885

39-
## Notes
86+
## OS X / macOS Notes
4087

4188
_NOTE_: For running on OSX systems, you'll need to install coreutils via brew. This will add to your
4289
system some needed GNU-like tools like `greadlink`.
4390

4491
1. If you haven't already, install [brew](http://brew.sh/) package manager in your mac
4592
2. Run `brew install coreutils`
4693

94+
## Format of the conformance test file
95+
96+
Conformance tests consist of input CWL descriptions plus an input CWL object
97+
and the expected outputs (or `should_fail: true` if the test is deliberately broken)
98+
99+
They are stored in [`conformance_tests.yaml`](https://github.com/common-workflow-language/cwl-v1.2/blob/main/conformance_tests.yaml)
100+
(or a file `$import`ed into that one)
101+
102+
You can examine [the formal schema of this file](https://github.com/common-workflow-language/cwltest/blob/main/cwltest/cwltest-schema.yml),
103+
or just continue reading here for an explanation.
104+
105+
The conformance test file is a YAML document: a list of key-value pairs.
106+
107+
We will use this single entry to explain the format
108+
``` yaml
109+
- doc: Test command line with optional input (missing)
110+
label: cl_optional_inputs_missing
111+
tool: tests/cat1-testcli.cwl
112+
job: tests/cat-job.json
113+
output:
114+
args: [cat, hello.txt]
115+
tags: [ required, command_line_tool ]
116+
```
117+
- `doc`: A sentence that explain what is being tested. Will be printed at test execution time. Should be unique.
118+
- `label`: a short list of underscore (`_`) separated words that succinctly identifies and explains the test.
119+
- `tool` the path to the CWL description to run
120+
- `job`: the CWL input object in YAML/JSON format. If there are no inputs then use `tests/empty.json`.
121+
- `output` [the CWL output object expected.](#output-matching)
122+
- `tags`: a yaml list of tag names, see [the list of canonical tags below](#tags-for-conformance-tests).
123+
124+
Because this is a `schema-salad` processed document, `$import` can be used to organize the tests into separate files.
125+
126+
Currently, the main file is too big (over 3400 lines); we are slowly re-organizing it.
127+
128+
Eventually it would be good to organize the tests so that the test for each optional feature and other logical groups of tests are in their own separate file;
129+
with the supporting CWL documents and their inputs in separate sub-folders of `tests` as well.
130+
131+
Example: [`- $import: tests/string-interpolation/test-index.yaml`](https://github.com/common-workflow-language/cwl-v1.2/blob/5f27e234b4ca88ed1280dedf9e3391a01de12912/conformance_tests.yaml#L3395)
132+
adds all the entries in [`tests/string-interpolation/test-index.yaml`](https://github.com/common-workflow-language/cwl-v1.2/blob/main/tests/string-interpolation/test-index.yaml)
133+
as entries in the main conformance test file.
134+
135+
## Output matching
136+
137+
In each test entry there is an `output` field that contains a mapping of the expected outputs names and their values.
138+
139+
If a particular value could vary and it doesn't matter to the proper functioning of the test, then it can be represented by the special token `Any`.
140+
141+
At any level, if there is an extra field, then that will be considered an error.
142+
An exception to this is `class: File` and `class: Directory` objects, the `cwl-runner` under test can add additional fields here.
143+
Likewise, if you don't want to test some aspect of a `class: File` or `class: Directory` object (like `nameext`) you can just omit it.
144+
145+
[According to the CWL standards](https://www.commonwl.org/v1.2/CommandLineTool.html#File), the format of the `location` field in
146+
`class: File` and `class: Directory` is implementation specific and we should not be testing them.
147+
Please remember to use `location: any` for them.
148+
149+
Currently, we do [test the contents of the location field in some older tests, but we should stop](https://github.com/common-workflow-language/common-workflow-language/issues/930)
150+
If you are editing those old tests, you may be interested in some special processing for `class: File` and `class: Directory` output objects:
151+
any `location` value specified will succeed if there is either an exact match to the real output, or it matches the end of the real output.
152+
Additionally, for `class: Directory` the location reported by the actual execution will have any trailing forward slash (`/`) trimmed off before comparison.
153+
154+
## Writing a new conformance test
155+
156+
To add a new conformance test:
157+
1. Ensure the CWL description you have tests the desired feature or aspect.
158+
2. Run your test using the CWL reference runner (`cwltool`) or another CWL runner
159+
that shows the correct behavior to collect the output, or confirm that validation/execution fails as expected
160+
3. Add the CWL description and output object to the subdirectory `tests` in this repository.
161+
4. Fill out a new entry in [conformance_tests.yaml](conformance_tests.yaml) following the [format of the conformance test file](#format-of-the-conformance-test-file)
162+
5. Send a pull request to [current staging branch for the next revision of the CWL standards](https://github.com/common-workflow-language/cwl-v1.2/tree/1.2.1_proposed)
163+
with your changes
164+
47165
## Tags for conformance tests
48166

49167
Each test in the [conformance_tests.yaml](conformance_tests.yaml) should be tagged with one or more tags.

0 commit comments

Comments
 (0)