Skip to content

Commit

Permalink
[skip changelog] Allow running specific unit tests (#466)
Browse files Browse the repository at this point in the history
This also adds some documentation showing how this works.
  • Loading branch information
matthijskooijman authored and Massimiliano Pippi committed Nov 5, 2019
1 parent 22cf574 commit b68c578
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
20 changes: 20 additions & 0 deletions CONTRIBUTING.md
Expand Up @@ -59,6 +59,26 @@ see following paragraph):
```shell
task test-integration
```
### Running only some tests
By default, all tests from all go packages are run. To run only unit
tests from one or more specific packages, you can set the TARGETS
environment variable, e.g.:

TARGETS=./arduino/cores/packagemanager task test-unit

Alternatively, to run only some specific test(s), you can specify a regex
to match against the test function name:

TEST_REGEX='^TestTryBuild.*' task test-unit

Both can be combined as well, typically to run only a specific test:

TEST_REGEX='^TestFindBoardWithFQBN$' TARGETS=./arduino/cores/packagemanager task test-unit

For integration test, the same options are supported. Note that when not
specified, `TEST_REGEX` defaults to "Integration" to select only
integration tests, so if you specify a broader regex, this could cause
non-integration tests to be run as well.

### Integration tests

Expand Down
4 changes: 2 additions & 2 deletions Taskfile.yml
Expand Up @@ -21,12 +21,12 @@ tasks:
test-unit:
desc: Run unit tests only
cmds:
- go test -short {{ default "-v" .GOFLAGS }} -coverprofile=coverage_unit.txt {{ default .DEFAULT_TARGETS .TARGETS }} {{.TEST_LDFLAGS}}
- go test -short -run '{{ default ".*" .TEST_REGEX }}' {{ default "-v" .GOFLAGS }} -coverprofile=coverage_unit.txt {{ default .DEFAULT_TARGETS .TARGETS }} {{.TEST_LDFLAGS}}

test-integration:
desc: Run integration tests only
cmds:
- go test -run Integration {{ default "-v" .GOFLAGS }} -coverprofile=coverage_integ.txt {{ default .DEFAULT_TARGETS .TARGETS }} {{.TEST_LDFLAGS}}
- go test -run '{{ default "Integration" .TEST_REGEX }}' {{ default "-v" .GOFLAGS }} -coverprofile=coverage_integ.txt {{ default .DEFAULT_TARGETS .TARGETS }} {{.TEST_LDFLAGS}}
- pytest test

test-legacy:
Expand Down

0 comments on commit b68c578

Please sign in to comment.