diff --git a/rust/ql/integration-tests/conftest.py b/rust/ql/integration-tests/conftest.py index 11eefe7e265..a1fbcf4e18d 100644 --- a/rust/ql/integration-tests/conftest.py +++ b/rust/ql/integration-tests/conftest.py @@ -4,18 +4,24 @@ import commands import pathlib +@pytest.fixture def cargo(cwd): assert (cwd / "Cargo.toml").exists() (cwd / "rust-project.json").unlink(missing_ok=True) +@pytest.fixture(scope="session") +def rust_sysroot_src() -> str: + rust_sysroot = pathlib.Path(commands.run("rustc --print sysroot", _capture=True)) + ret = rust_sysroot.joinpath("lib", "rustlib", "src", "rust", "library") + assert ret.exists() + return str(ret) @pytest.fixture -def rust_project(cwd): +def rust_project(cwd, rust_sysroot_src): project_file = cwd / "rust-project.json" assert project_file.exists() - rust_sysroot = pathlib.Path(commands.run("rustc --print sysroot", _capture=True)) project = json.loads(project_file.read_text()) - project["sysroot_src"] = str(rust_sysroot.joinpath("lib", "rustlib", "src", "rust", "library")) + project["sysroot_src"] = rust_sysroot_src project_file.write_text(json.dumps(project, indent=4)) (cwd / "Cargo.toml").unlink(missing_ok=True)