(session: nox.Session)
| 233 | @nox.session |
| 234 | @nox.session(name="rust-noclippy") |
| 235 | def rust(session: nox.Session) -> None: |
| 236 | prof_location = ( |
| 237 | pathlib.Path(".") / ".rust-cov" / str(uuid.uuid4()) |
| 238 | ).absolute() |
| 239 | rustflags = os.environ.get("RUSTFLAGS", "") |
| 240 | assert rustflags is not None |
| 241 | session.env.update( |
| 242 | { |
| 243 | "RUSTFLAGS": f"-Cinstrument-coverage {rustflags}", |
| 244 | "LLVM_PROFILE_FILE": str(prof_location / "cov-%p.profraw"), |
| 245 | } |
| 246 | ) |
| 247 | |
| 248 | # TODO: Ideally there'd be a pip flag to install just our dependencies, |
| 249 | # but not install us. |
| 250 | pyproject_data = load_pyproject_toml() |
| 251 | install(session, *pyproject_data["build-system"]["requires"]) |
| 252 | |
| 253 | session.run("cargo", "fmt", "--all", "--", "--check", external=True) |
| 254 | if session.name != "rust-noclippy": |
| 255 | session.run( |
| 256 | "cargo", |
| 257 | "clippy", |
| 258 | "--all", |
| 259 | "--", |
| 260 | "-D", |
| 261 | "warnings", |
| 262 | external=True, |
| 263 | ) |
| 264 | |
| 265 | build_output = session.run( |
| 266 | "cargo", |
| 267 | "test", |
| 268 | "--all", |
| 269 | "--no-run", |
| 270 | "-q", |
| 271 | "--message-format=json", |
| 272 | external=True, |
| 273 | silent=True, |
| 274 | ) |
| 275 | session.run("cargo", "test", "--all", external=True) |
| 276 | |
| 277 | # It's None on install-only invocations |
| 278 | if build_output is not None: |
| 279 | assert isinstance(build_output, str) |
| 280 | rust_tests = [] |
| 281 | for line in build_output.splitlines(): |
| 282 | data = json.loads(line) |
| 283 | if data.get("profile", {}).get("test", False): |
| 284 | rust_tests.extend(data["filenames"]) |
| 285 | |
| 286 | process_rust_coverage(session, rust_tests, prof_location) |
| 287 | |
| 288 | |
| 289 | @nox.session |
nothing calls this directly
no test coverage detected