Skip to content
This repository has been archived by the owner on Jul 24, 2024. It is now read-only.

Commit

Permalink
tests: add instruction how to use go test.
Browse files Browse the repository at this point in the history
  • Loading branch information
kennytm committed Mar 10, 2021
1 parent 3e92adc commit f0d6646
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 3 deletions.
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,11 @@ build_for_integration_test:
) || (make failpoint-disable && exit 1)
@make failpoint-disable

test: export ARGS=$$($(PACKAGES))
test:
$(PREPARE_MOD)
@make failpoint-enable
$(GOTEST) $(RACEFLAG) -tags br_test,leak $$($(PACKAGES)) || ( make failpoint-disable && exit 1 )
$(GOTEST) $(RACEFLAG) -tags br_test,leak $(ARGS) || ( make failpoint-disable && exit 1 )
@make failpoint-disable

testcover: tools
Expand Down
33 changes: 31 additions & 2 deletions tests/README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,38 @@
This folder contains all tests which relies on external processes such as TiDB.
# Unit tests

Unit tests (the `*_test.go` files inside the source directory) should *never* rely on external
programs.

Run `make test` to execute all unit tests.

To run a specific test, pass `ARGS` into `make test` like

```sh
make test ARGS='github.com/pingcap/br/pkg/cdclog --test.v --check.v --check.f TestColumn'
# ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# which package to test more extra test flags
```

You can also run unit tests directly via `go test` like:

```sh
make failpoint-enable

go test -tags br_test github.com/pingcap/br/pkg/cdclog --test.v --check.v --check.f TestColumn
# ^~~~~~~~~~~~~

make failpoint-disable
```

but note that:

* the build-tag `br_test` must be enabled (this workarounds the lack of test-dependencies in go.mod)
* failpoints must be toggled manually

# Integration tests

This folder contains all tests which relies on external processes such as TiDB.

## Preparations

1. The following 9 executables must be copied or linked into these locations:
Expand Down Expand Up @@ -39,7 +69,6 @@ If you have docker installed, you can skip step 1 and step 2 by running

## Running

Run `make test` to execute the unit tests.
Run `make integration_test` to execute the integration tests. This command will

1. Build `br`
Expand Down

0 comments on commit f0d6646

Please sign in to comment.