mirror of
https://github.com/github/codeql.git
synced 2025-12-16 08:43:11 +01:00
Rust: move rust_sysroot_src to its own session fixture
This commit is contained in:
@@ -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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user