Skip to content

Commit 7e0e5a3

Browse files
author
Paolo Tranquilli
committed
Rust: move rust_sysroot_src to its own session fixture
1 parent 4bcc425 commit 7e0e5a3

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

rust/ql/integration-tests/conftest.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,24 @@
44
import pathlib
55

66

7+
@pytest.fixture
78
def cargo(cwd):
89
assert (cwd / "Cargo.toml").exists()
910
(cwd / "rust-project.json").unlink(missing_ok=True)
1011

12+
@pytest.fixture(scope="session")
13+
def rust_sysroot_src() -> str:
14+
rust_sysroot = pathlib.Path(commands.run("rustc --print sysroot", _capture=True))
15+
ret = rust_sysroot.joinpath("lib", "rustlib", "src", "rust", "library")
16+
assert ret.exists()
17+
return str(ret)
1118

1219
@pytest.fixture
13-
def rust_project(cwd):
20+
def rust_project(cwd, rust_sysroot_src):
1421
project_file = cwd / "rust-project.json"
1522
assert project_file.exists()
16-
rust_sysroot = pathlib.Path(commands.run("rustc --print sysroot", _capture=True))
1723
project = json.loads(project_file.read_text())
18-
project["sysroot_src"] = str(rust_sysroot.joinpath("lib", "rustlib", "src", "rust", "library"))
24+
project["sysroot_src"] = rust_sysroot_src
1925
project_file.write_text(json.dumps(project, indent=4))
2026
(cwd / "Cargo.toml").unlink(missing_ok=True)
2127

0 commit comments

Comments
 (0)