Building and developing MUSE2
Background: The Rust programming language
MUSE2 is written using Rust, which is a high-performance, compiled language. If you have used other compiled languages, such as C++, many of the concepts will be familiar. One feature which distinguishes it from other languages like C and C++, however, is that undefined behaviour, such as memory safety bugs, are not possible, provided you keep to the safe subset of the language. This means you can have the performance benefits of using a low-level language like C, with the safety guarantees and much of the convenience of a higher-level language like Python.
There is much high quality documentation available for learning Rust, but it is probably best to start with The Rust Programming Language book, which is freely available online.
Building MUSE2
To build the project, run:
cargo build
Note that if you just want to build-test the project (i.e. check for errors and warnings) without
building an executable, you can use the cargo check command, which is much faster.
To run MUSE2 with the “simple” example, you can run:
cargo run run examples/simple
(Note the two runs. The first is for cargo and the second is passed as an argument to the built
muse2 program.)
Tests can be run with:
cargo test
More information is available in the official cargo book.
Checking test coverage
We use Codecov to check whether pull requests introduce code without tests.
To check coverage locally (i.e. to make sure newly written code has tests), we recommend using cargo-llvm-cov.
It can be installed with:
cargo install cargo-llvm-cov
Once installed, you can use it like so:
cargo llvm-cov --open
Alternatively, you can use Just:
just coverage --open
This will generate a report in HTML format showing which lines are not currently covered by tests and open it in your default browser.