Skip to content

Commit 74a0f7d

Browse files
committed
Base cfg printing off the program instead of allowing separate executables
1 parent f53f3f6 commit 74a0f7d

File tree

4 files changed

+11
-12
lines changed

4 files changed

+11
-12
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2424
* `Config::output_conflict_handling` does not contain the bless command message anymore, it is instead available separately as `Config::bless_command`
2525
* Updating `cargo_metadata` to `0.18`
2626
* Updated `spanned` to `0.1.5`, giving more precise spans for more iterator operations
27+
* `Config::cfgs` is now `Config::program::cfg_flag`
2728

2829
### Removed
2930

src/cmd.rs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ pub struct CommandBuilder {
2020
/// Environment variables passed to the binary that is executed.
2121
/// The environment variable is removed if the second tuple field is `None`
2222
pub envs: Vec<(OsString, Option<OsString>)>,
23+
/// A flag to add in order to make the command print the cfgs it supports
24+
pub cfg_flag: Option<OsString>,
2325
}
2426

2527
impl CommandBuilder {
@@ -31,6 +33,7 @@ impl CommandBuilder {
3133
out_dir_flag: Some("--target-dir".into()),
3234
input_file_flag: Some("--manifest-path".into()),
3335
envs: vec![],
36+
cfg_flag: None,
3437
}
3538
}
3639

@@ -45,14 +48,7 @@ impl CommandBuilder {
4548
out_dir_flag: Some("--out-dir".into()),
4649
input_file_flag: None,
4750
envs: vec![],
48-
}
49-
}
50-
51-
/// Same as [`CommandBuilder::rustc`], but with arguments for obtaining the cfgs.
52-
pub fn cfgs() -> Self {
53-
Self {
54-
args: vec!["--print".into(), "cfg".into()],
55-
..Self::rustc()
51+
cfg_flag: Some("--print=cfg".into()),
5652
}
5753
}
5854

@@ -65,6 +61,7 @@ impl CommandBuilder {
6561
out_dir_flag: None,
6662
input_file_flag: None,
6763
envs: vec![],
64+
cfg_flag: None,
6865
}
6966
}
7067

src/config.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@ pub struct Config {
2727
pub root_dir: PathBuf,
2828
/// The binary to actually execute.
2929
pub program: CommandBuilder,
30-
/// The command to run to obtain the cfgs that the output is supposed to
31-
pub cfgs: CommandBuilder,
3230
/// What to do in case the stdout/stderr output differs from the expected one.
3331
pub output_conflict_handling: OutputConflictHandling,
3432
/// The recommended command to bless failing tests.
@@ -85,7 +83,6 @@ impl Config {
8583
target: None,
8684
root_dir: root_dir.into(),
8785
program: CommandBuilder::rustc(),
88-
cfgs: CommandBuilder::cfgs(),
8986
output_conflict_handling: OutputConflictHandling::Bless,
9087
bless_command: None,
9188
dependencies_crate_manifest_path: None,

src/dependencies.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,11 @@ pub struct Dependencies {
2424
}
2525

2626
fn cfgs(config: &Config) -> Result<Vec<Cfg>> {
27-
let mut cmd = config.cfgs.build(&config.out_dir);
27+
let Some(cfg) = &config.program.cfg_flag else {
28+
return Ok(vec![]);
29+
};
30+
let mut cmd = config.program.build(&config.out_dir);
31+
cmd.arg(cfg);
2832
cmd.arg("--target").arg(config.target.as_ref().unwrap());
2933
let output = cmd.output()?;
3034
let stdout = String::from_utf8(output.stdout)?;

0 commit comments

Comments
 (0)