Skip to content

Commit

Permalink
Add selective running of tests
Browse files Browse the repository at this point in the history
  • Loading branch information
adamrtalbot committed Aug 18, 2023
1 parent ca5f6e4 commit eff96fb
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 11 deletions.
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,15 @@ nf-canary uses the `--outdir` convention established by [nf-core](https://nf-co.

### Skipping Tests

Each test can be skipped by name with the parameter `--skip`, e.g. `--skip TEST_INPUT`. Multiple can be specified with comma delimited values, e.g. `--skip TEST_CREATE_FILE,TEST_PASS_FILE`. Note, some tests depend on previous tests running so will be skipped if an upstream test does not run (or fails). All tests which are dependent on previous tests are listed here:
Each test can be skipped by name with the parameter `--skip`, e.g. `--skip TEST_INPUT`. Multiple test can be specified with comma delimited values, e.g. `--skip TEST_CREATE_FILE,TEST_PASS_FILE`. Case insensitive.

### Selectively running tests

By default, all tests are ran, however you can selectively run a test with `--run`, e.g. `--run TEST_INPUT`. When using this parameter, _only_ the tests selected will be run. Multiple test can be specified with comma delimited values, e.g. `--run TEST_CREATE_FILE,TEST_PASS_FILE`. Case insensitive.

### Note on test dependency

Note, some tests depend on previous tests running so will be skipped if an upstream test does not run (or fails). All tests which are dependent on previous tests are listed here:

```yaml
TEST_CREATE_FILE:
Expand Down
3 changes: 2 additions & 1 deletion nextflow.config
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
params {
skip = ''
run = null
outdir = null
remoteFile = null
}

process {
container = "docker.io/library/ubuntu:23.10"
errorStrategy = "finish"
when = { !params.skip.split(',').any{ it.toUpperCase().contains(task.process) } }
when = { ( params.run ? params.run.split(',').any{ it.toUpperCase().contains(task.process) } : true && !params.skip.split(',').any{ it.toUpperCase().contains(task.process) } ) }
}
23 changes: 23 additions & 0 deletions tests/main.nf.test
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,29 @@ nextflow_pipeline {

}

<<<<<<< HEAD
=======

test("Should only run one process") {

when {
params {
run = "test_success"
remoteFile = "tests/testfile.txt"
}
}

then {
assert workflow.success
assert workflow.trace.tasks().size() == 1
assert workflow.trace.succeeded().size() == 1
assert workflow.trace.failed().size() == 0
assert snapshot(workflow.out).match()
}

}

>>>>>>> a228794 (Add selective running of tests)
test("Should publish to alternative directory") {

when {
Expand Down
26 changes: 17 additions & 9 deletions tests/main.nf.test.snap
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,23 @@
"Should skip TEST_SUCCESS": {
"content": [
{

}
],
"timestamp": "2023-08-18T10:28:15+0000"
"timestamp": "2023-08-18T10:59:43+0000"
},
"Should skip a process": {
"content": [
{

}
],
"timestamp": "2023-08-18T10:28:15+0000"
"timestamp": "2023-08-18T10:59:43+0000"
},
"Should publish to alternative directory": {
"content": [
{

},
[
[
Expand All @@ -28,14 +28,22 @@
"test.txt:md5,d41d8cd98f00b204e9800998ecf8427e"
]
],
"timestamp": "2023-08-18T10:28:15+0000"
"timestamp": "2023-08-18T10:59:43+0000"
},
"Should only run one process": {
"content": [
{

}
],
"timestamp": "2023-08-18T10:59:43+0000"
},
"Should run without failures": {
"content": [
{

}
],
"timestamp": "2023-08-18T10:28:15+0000"
"timestamp": "2023-08-18T10:59:43+0000"
}
}
}

0 comments on commit eff96fb

Please sign in to comment.