(session: nox.Session)
| 166 | |
| 167 | @nox.session |
| 168 | def rust(session: nox.Session) -> None: |
| 169 | prof_location = ( |
| 170 | pathlib.Path(".") / ".rust-cov" / str(uuid.uuid4()) |
| 171 | ).absolute() |
| 172 | session.env.update( |
| 173 | { |
| 174 | "RUSTFLAGS": "-Cinstrument-coverage " |
| 175 | + session.env.get("RUSTFLAGS", ""), |
| 176 | "LLVM_PROFILE_FILE": str(prof_location / "cov-%p.profraw"), |
| 177 | } |
| 178 | ) |
| 179 | |
| 180 | install(session, ".") |
| 181 | |
| 182 | with session.chdir("src/rust/"): |
| 183 | session.run("cargo", "fmt", "--all", "--", "--check", external=True) |
| 184 | session.run("cargo", "clippy", "--", "-D", "warnings", external=True) |
| 185 | |
| 186 | build_output = session.run( |
| 187 | "cargo", |
| 188 | "test", |
| 189 | "--no-default-features", |
| 190 | "--all", |
| 191 | "--no-run", |
| 192 | "-q", |
| 193 | "--message-format=json", |
| 194 | external=True, |
| 195 | silent=True, |
| 196 | ) |
| 197 | session.run( |
| 198 | "cargo", "test", "--no-default-features", "--all", external=True |
| 199 | ) |
| 200 | |
| 201 | # It's None on install-only invocations |
| 202 | if build_output is not None: |
| 203 | assert isinstance(build_output, str) |
| 204 | rust_tests = [] |
| 205 | for line in build_output.splitlines(): |
| 206 | data = json.loads(line) |
| 207 | if data.get("profile", {}).get("test", False): |
| 208 | rust_tests.extend(data["filenames"]) |
| 209 | |
| 210 | process_rust_coverage(session, rust_tests, prof_location) |
| 211 | |
| 212 | |
| 213 | LCOV_SOURCEFILE_RE = re.compile( |
nothing calls this directly
no test coverage detected