-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Testing
Servo has a test suite which runs on every reviewed pull request, via bors-servo and the buildbot. It uses Mozilla's Mach system to run the tests.
You can run the test suite yourself through these ./mach
commands:
-
./mach test-unit
: Runs unit tests (functions tagged with#[test]
) inside Servo and its dependencies. May also run ref or content tests depending on your platform. -
./mach test-wpt
: Runs the web platform tests on Servo. -
./mach test-scripts
: Run tests for Servo's python support scripts. -
./mach test-tidy
: Run lints against your local changes.
- Write wpt/css tests
- Write unit tests: these are common Rust programs under
tests/unit
, and are organized to reflect thecomponents
tree. You can follow the existing structure and Rust testing guide
In some tests (e.g. wpt tests), you need to use a hostfile to translate testing domain names to real IPs. For example, translating wpt1.testserver.com
to 127.0.0.1
. But you may not have the permission to change the system hostfile in a shared server. Instead, you can assign a temporary hostfile using the HOST_FILE
environment variable.
First, create a hostfile, say /tmp/hostfile.txt
, in the following format ip<single space>hostname<new line>
. For example:
127.0.0.1 wpt1.testserver.com
127.0.0.1 wpt2.testserver.com
Then, set the HOST_FILE
environment variable as the absolute path to the hostfile.
export HOST_FILE=/tmp/hostfile.txt
Now, if you open http://wpt1.testserver.com in servo, you will go to http://127.0.0.1 directly.