Skip to content

Commit 98cc18f

Browse files
Firestar99LegNeato
authored andcommitted
difftest: forward use-installed-tools
1 parent 02fea9c commit 98cc18f

File tree

5 files changed

+49
-675
lines changed

5 files changed

+49
-675
lines changed

tests/difftests/bin/Cargo.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@ edition.workspace = true
66
license.workspace = true
77
repository.workspace = true
88

9+
# See rustc_codegen_spirv/Cargo.toml for details on these features
10+
[features]
11+
default = ["use-compiled-tools"]
12+
use-installed-tools = []
13+
use-compiled-tools = []
14+
915
[dependencies]
1016
anyhow = "1.0"
1117
tracing = "0.1"

tests/difftests/bin/src/main.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,11 @@ fn main() -> Result<()> {
7272
// We build first to ensure that the tests are compiled before running them and to
7373
// passthrough stdout and stderr from cargo to help debugging.
7474
let mut cmd = Command::new("cargo");
75-
let cmd = cmd
76-
.arg("build")
77-
.arg("--release")
78-
.current_dir(&base)
79-
.stderr(std::process::Stdio::inherit())
80-
.stdout(std::process::Stdio::inherit());
75+
let cmd = cmd.arg("build").arg("--release");
76+
runner::forward_features(cmd);
77+
cmd.current_dir(&base)
78+
.stderr(process::Stdio::inherit())
79+
.stdout(process::Stdio::inherit());
8180
tracing::debug!("Running cargo command: {:?}", cmd);
8281

8382
let output = cmd.output().expect("build output");

tests/difftests/bin/src/runner.rs

Lines changed: 28 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -135,25 +135,22 @@ impl Runner {
135135
trace!("Config file created at {}", config_file.path().display());
136136

137137
let mut cmd = Command::new("cargo");
138-
let cmd = cmd
139-
.arg("run")
140-
.arg("--release")
141-
.arg("--manifest-path")
142-
.arg(
143-
manifest_path
144-
.to_str()
145-
.ok_or_else(|| RunnerError::Manifest {
146-
path: manifest_path.clone(),
147-
})?,
148-
)
149-
.arg(
150-
config_file
151-
.path()
152-
.to_str()
153-
.ok_or_else(|| RunnerError::Config {
154-
msg: "Invalid config file path".into(),
155-
})?,
156-
);
138+
cmd.arg("run").arg("--release").arg("--manifest-path").arg(
139+
manifest_path
140+
.to_str()
141+
.ok_or_else(|| RunnerError::Manifest {
142+
path: manifest_path.clone(),
143+
})?,
144+
);
145+
forward_features(&mut cmd);
146+
cmd.arg("--").arg(
147+
config_file
148+
.path()
149+
.to_str()
150+
.ok_or_else(|| RunnerError::Config {
151+
msg: "Invalid config file path".into(),
152+
})?,
153+
);
157154
debug!("Running cargo command: {:?}", cmd);
158155

159156
let output = cmd
@@ -331,6 +328,18 @@ impl Runner {
331328
}
332329
}
333330

331+
pub fn forward_features(cmd: &mut Command) {
332+
cmd.arg("--features");
333+
#[cfg(feature = "use-compiled-tools")]
334+
{
335+
cmd.arg("difftest/use-compiled-tools");
336+
}
337+
#[cfg(feature = "use-installed-tools")]
338+
{
339+
cmd.arg("difftest/use-installed-tools");
340+
}
341+
}
342+
334343
#[cfg(test)]
335344
mod tests {
336345
use super::*;

tests/difftests/lib/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ repository.workspace = true
88

99
# See rustc_codegen_spirv/Cargo.toml for details on these features
1010
[features]
11-
default = ["use-compiled-tools"]
1211
use-installed-tools = [
1312
"spirv-builder/use-installed-tools"
1413
]

0 commit comments

Comments
 (0)