diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 1c65e30f2f6..cb90e3998ae 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -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 diff --git a/Taskfile.yml b/Taskfile.yml index 86f4f2b218a..325172222d5 100755 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -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: