Skip to content

Commit b68c578

Browse files
matthijskooijmanMassimiliano Pippi
authored and
Massimiliano Pippi
committed
[skip changelog] Allow running specific unit tests (arduino#466)
This also adds some documentation showing how this works.
1 parent 22cf574 commit b68c578

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

CONTRIBUTING.md

+20
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,26 @@ see following paragraph):
5959
```shell
6060
task test-integration
6161
```
62+
### Running only some tests
63+
By default, all tests from all go packages are run. To run only unit
64+
tests from one or more specific packages, you can set the TARGETS
65+
environment variable, e.g.:
66+
67+
TARGETS=./arduino/cores/packagemanager task test-unit
68+
69+
Alternatively, to run only some specific test(s), you can specify a regex
70+
to match against the test function name:
71+
72+
TEST_REGEX='^TestTryBuild.*' task test-unit
73+
74+
Both can be combined as well, typically to run only a specific test:
75+
76+
TEST_REGEX='^TestFindBoardWithFQBN$' TARGETS=./arduino/cores/packagemanager task test-unit
77+
78+
For integration test, the same options are supported. Note that when not
79+
specified, `TEST_REGEX` defaults to "Integration" to select only
80+
integration tests, so if you specify a broader regex, this could cause
81+
non-integration tests to be run as well.
6282

6383
### Integration tests
6484

Taskfile.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@ tasks:
2121
test-unit:
2222
desc: Run unit tests only
2323
cmds:
24-
- go test -short {{ default "-v" .GOFLAGS }} -coverprofile=coverage_unit.txt {{ default .DEFAULT_TARGETS .TARGETS }} {{.TEST_LDFLAGS}}
24+
- go test -short -run '{{ default ".*" .TEST_REGEX }}' {{ default "-v" .GOFLAGS }} -coverprofile=coverage_unit.txt {{ default .DEFAULT_TARGETS .TARGETS }} {{.TEST_LDFLAGS}}
2525

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

3232
test-legacy:

0 commit comments

Comments
 (0)