The Servo Browser Engine -- A Learner's Notebook

Testing and Debugging

Logging

To enbale debug log (debug!() in the code), run with the following environment variable:

RUST_LOG=debug ./mach run

And you can set the log level for individual modules like this:

RUST_LOG=script=debug ./mach run //sets log_level=debug for script module

To redirect the logs to a file:

RUST_LOG=script=debug ./mach run > /tmp/servo.log 2>&1

For more information on how to use RUST_LOG, see http://doc.rust-lang.org/log/env_logger/index.html

Debugger

./mach run --debug

will start the debugger (gdb by default), you can then run

r http://www.mozill.org

to start the program

Alternatively, use the --debugger option to specify the debugger you want, for example

./mach run --debug --debugger ddd

Testing

Test commands are implemented in python/servo/testing_commands.py, you can dig into the code if the -h help page is not enough.

reftest

TODO:intro Reftests has manifests (e.g. test/ref/basic.list), which specifies if the rendered results should be euqal (==) or not (!=). You can check if two different CSS style does generate the same result, like in filter_opacity_a.html, it uses filter: opacity(...) to compare with filter_opacity_ref.html's opacity: ....

Another way is to check a CSS property does take effect. For example, box_shadow_blur_a.html uses blurring, where shadow_blur_ref.html does not. So ther are expected to differ.

To run all reftests, use

./mach test-ref

To run a reftests with a particular pattern in its name, use

./mach test-ref --name <pattern>

e.g.

./mach test-ref --name box_shadow_blur #run the box_shadow_blur test
./mach test-ref --name box_shadow #run all box_shadow_* tests