Getting Started with Contributing - mongodb/jasper GitHub Wiki

All of the building/testing/linting is done using a Makefile.

Testing

Run tests for a single package:

make test-<package_path>

where package_path is the dash-separated path to the package. For example, if you want to test the options package, you would run:

make test-options

If you want to test the executor package located at internal/executor, you would run:

make test-internal-executor

A special case is the root package, which is called jasper. To test the root package, you would run:

make test-jasper

Run all tests:

make test

Options

Options to control how the tests execute use environment variables, which can be prepended to the make command.

RUN_TEST

Filter the name of the tests you want to run according to a pattern.

This is the same as the go test -run flag.

Example:

RUN_TEST=TestProcessImplementations make test-jasper

RUN_COUNT

Run the tests the specified number of times. This can be especially useful if you want to force a test whose result has been cached to re-run. For example, if you do not make a code change in between test runs, it will returned the cached result.

This is the same as the go test -count flag (documentation is in go help testflag).

Example:

RUN_COUNT=10 make test-options

DISABLE_COVERAGE

Disable code coverage analysis.

Example:

DISABLE_COVERAGE=1 make test-jasper

RACE_DETECTOR

Enable the race detector.

This is the same as the go test -race flag.

Example:

RACE_DETECTOR=1 make test-jasper

SKIP_LONG

Skip all tests that have been marked as long tests.

This is the same as the go test -short flag (documentation is in go help testflag).

Example:

SKIP_LONG=1 make test-jasper

Linting

Linting follows the same syntax as testing, except that it is prefixed with lint- instead of test-. For example, to lint the root package, you would run:

make lint-jasper

All linting is done using golangci-lint.

Benchmarking

Run the benchmarks:

make benchmarks

Building

Check compilation:

make compile

Build the Jasper CLI:

make cli

If you want to build for a different platform, you can specify environment variables. For example, to build for Linux AMD64:

GOOS=linux GOARCH=amd64 make cli