To run the test suite:
make test
Note that by default the tests are run using go test
with the following configuration:
-race ./{cmd,pkg}/...
To run a specific test use the -run
flag (exposed by go test
) and also provide the path to the directory where the test files reside (replace ...
and <path>
with appropriate values):
make test TEST_ARGS="-run <...> <path>"
Example:
make test TEST_ARGS="-run TestBackendCreate ./pkg/backend/..."
Some integration tests aren't run outside of the CI environment, to enable these tests locally you'll need to set a specific environment variable relevant to the test.
The available environment variables are:
TEST_COMPUTE_INIT
: runsTestInit
.TEST_COMPUTE_BUILD
: runsTestBuildRust
,TestBuildAssemblyScript
andTestBuildJavaScript
.TEST_COMPUTE_BUILD_RUST
: runsTestBuildRust
.TEST_COMPUTE_BUILD_ASSEMBLYSCRIPT
: runsTestBuildAssemblyScript
.TEST_COMPUTE_BUILD_JAVASCRIPT
: runsTestBuildJavaScript
.TEST_COMPUTE_DEPLOY
: runsTestDeploy
.
Example:
TEST_COMPUTE_BUILD_RUST=1 make test TEST_ARGS="-run TestBuildRust/fastly_crate_prerelease ./pkg/compute/..."
When running the tests locally, if you don't have the relevant language ecosystems set-up properly then the tests will fail to run and you'll need to review the code to see what the remediation steps are, as that output doesn't get shown when running the test suite.
NOTE: you might notice a discrepancy between CI and your local environment which is caused by the difference in Rust toolchain versions as defined in .github/workflows/pr_test.yml which specifies the version required to be tested for in CI. Running
rustup toolchain install <version>
andrustup target add wasm32-wasi --toolchain <version>
will resolve any failing integration tests you may be running locally.
To the run the full test suite:
TEST_COMPUTE_INIT=1 TEST_COMPUTE_BUILD=1 TEST_COMPUTE_DEPLOY=1 TEST_COMMAND=gotest make all
NOTE:
TEST_COMMAND
is optional and allows the use of https://github.com/rakyll/gotest to improve test output.