|
| 1 | +[tasks.clean] |
| 2 | +command = "cargo" |
| 3 | +args = ["clean"] |
| 4 | +workspace = false |
| 5 | + |
| 6 | +[tasks.install-grcov] |
| 7 | +command = "cargo" |
| 8 | +args = ["install", "grcov"] |
| 9 | +workspace = false |
| 10 | + |
| 11 | +[tasks.install-llvm] |
| 12 | +command = "rustup" |
| 13 | +args = ["component", "add", "llvm-tools-preview"] |
| 14 | +workspace = false |
| 15 | + |
| 16 | +# This actually runs the tests and generates the .profraw file. |
| 17 | +[tasks.coverage-run-tests] |
| 18 | +workspace = false |
| 19 | +command = "cargo" |
| 20 | +args = ["test", "--all-features"] |
| 21 | +# toolchain = "nightly" |
| 22 | +env = { RUSTFLAGS = "-Cinstrument-coverage", RUSTDOCFLAGS = "-Cinstrument-coverage", LLVM_PROFILE_FILE = "llvm_profile-%p-%m.profraw" } |
| 23 | + |
| 24 | +# After generating the .profraw, this step creates the html report. |
| 25 | +# Important! Keep in grcov flags in sync with Makefile.internal.toml. |
| 26 | +[tasks.coverage-run-grcov] |
| 27 | +workspace = false |
| 28 | +command = "grcov" |
| 29 | +args = [ |
| 30 | + ".", |
| 31 | + "--binary-path", "target/debug/deps/", |
| 32 | + "--source-dir", ".", |
| 33 | + "--branch", # Enables parsing branch coverage information |
| 34 | + "--ignore-not-existing", |
| 35 | + "--ignore", "fluent-testing/*", # Test-only fixtures. |
| 36 | + "--ignore", "fluent-syntax/src/bin/*", # Small binary utility that doesn't require testing. |
| 37 | + "--output-type", "html", |
| 38 | + "--output-path", "coverage", |
| 39 | + "--excl-start", "^#\\[cfg\\(test\\)\\]|^// coverage\\(off\\)", |
| 40 | + "--excl-br-start", "^#\\[cfg\\(test\\)\\]|^// coverage\\(off\\)", |
| 41 | + "--excl-stop", "^// coverage\\(on\\)", |
| 42 | + "--excl-br-stop", "^// coverage\\(on\\)", |
| 43 | + "--excl-line", "\\#\\[derive\\(|// cov\\(skip\\)", |
| 44 | + "--excl-br-line", "\\#\\[derive\\(|// cov\\(skip\\)", |
| 45 | +] |
| 46 | +env = { LLVM_PROFILE_FILE = "llvm_profile-%p-%m.profraw" } |
| 47 | + |
| 48 | +# Cleans up all of the .profraw files left over after running -C instrument-coverage |
| 49 | +[tasks.coverage-clean-profraw] |
| 50 | +workspace = false |
| 51 | +command = "find" |
| 52 | +args = [ |
| 53 | + ".", |
| 54 | + "-name", "*.profraw", |
| 55 | + "-maxdepth", "2", |
| 56 | + "-delete" |
| 57 | +] |
| 58 | + |
| 59 | +# Notify the user the report is ready. |
| 60 | +[tasks.coverage-notify-completed] |
| 61 | +workspace = false |
| 62 | +command = "echo" |
| 63 | +args = ["\nThe coverage report is ready:\n./coverage\n"] |
0 commit comments