测试
单元测试
单元测试使用 Go 编写,可以用以下命令执行:
go test -v ./...
单元测试不执行实际的虚拟机。
集成测试
集成测试涉及虚拟机的实际执行。
The integration tests are written in BATS (Bash Automated Testing System).
Run the following commands to run the BATS tests:
git submodule update --init --recursive
make bats
The BATS tests are located under hack/bats/tests.
Extra tests
There are also extra tests (hack/bats/extras) that are not automatically
invoked from make bats.
Run the following command to run the extra BATS tests:
./hack/bats/lib/bats-core/bin/bats ./hack/bats/extras
Template-specific tests
Tests that are specific to template files are written in bash and partially in Perl.
Use hack/test-templates.sh
to execute tests, with a virtual machine template file, e.g.,:
./hack/test-templates.sh ./templates/default.yaml
./hack/test-templates.sh ./templates/fedora.yaml
./hack/test-templates.sh ./hack/test-templates/test-misc.yaml
CI
.github/workflows/test.yml
executes the tests on the GitHub Actions with the “Tier 1” templates.
Most tests are executed on Linux runners, as macOS runners are slow and flaky.
关于 macOS 特定功能(例如 vz 和 vmnet)的测试仍在 macOS 运行器上执行。
目前使用 Intel 版本的 macOS,因为 GitHub Actions 上的 ARM 版本 macOS 仍不支持嵌套虚拟化。