Skip to content
This repository was archived by the owner on Apr 5, 2024. It is now read-only.

Commit 8bcd30a

Browse files
committed
Auto merge of #291 - dario23:debug-rmpv-ci, r=JohnTitor
Add host link path in `rustc` invocations to reenable rmpv testcase
2 parents 40325ee + b62a2c6 commit 8bcd30a

File tree

2 files changed

+49
-27
lines changed

2 files changed

+49
-27
lines changed

src/bin/cargo-semver.rs

Lines changed: 44 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,11 @@ fn run(config: &cargo::Config, matches: &getopts::Matches) -> Result<()> {
130130
let mut child = Command::new("rust-semver-public");
131131
child
132132
.arg("--crate-type=lib")
133-
.args(&["--extern", &*format!("new={}", current_rlib.display())])
134-
.args(&[format!("-L{}", current_deps_output.display())]);
133+
.args(&["--extern", &*format!("new={}", current_rlib.display())]);
134+
135+
for link_path in current_deps_output {
136+
child.args(&[format!("-L{}", link_path.display())]);
137+
}
135138

136139
if let Some(target) = matches.opt_str("target") {
137140
child.args(&["--target", &target]);
@@ -195,13 +198,16 @@ fn run(config: &cargo::Config, matches: &getopts::Matches) -> Result<()> {
195198
stable.rlib_and_dep_output(config, &name, false, matches)?;
196199

197200
if matches.opt_present("d") {
198-
println!(
199-
"--extern old={} -L{} --extern new={} -L{}",
200-
stable_rlib.display(),
201-
stable_deps_output.display(),
202-
current_rlib.display(),
203-
current_deps_output.display()
204-
);
201+
print!("--extern old={} ", stable_rlib.display());
202+
for link_path in stable_deps_output {
203+
print!("-L {} ", link_path.display());
204+
}
205+
print!("--extern new={}", current_rlib.display());
206+
for link_path in current_deps_output {
207+
print!("-L {} ", link_path.display());
208+
}
209+
println!();
210+
205211
return Ok(());
206212
}
207213

@@ -210,10 +216,14 @@ fn run(config: &cargo::Config, matches: &getopts::Matches) -> Result<()> {
210216
let mut child = Command::new("rust-semverver");
211217
child
212218
.arg("--crate-type=lib")
213-
.args(&["--extern", &*format!("old={}", stable_rlib.display())])
214-
.args(&[format!("-L{}", stable_deps_output.display())])
215-
.args(&["--extern", &*format!("new={}", current_rlib.display())])
216-
.args(&[format!("-L{}", current_deps_output.display())]);
219+
.args(&["--extern", &*format!("old={}", stable_rlib.display())]);
220+
for link_path in stable_deps_output {
221+
child.args(&[format!("-L{}", link_path.display())]);
222+
}
223+
child.args(&["--extern", &*format!("new={}", current_rlib.display())]);
224+
for link_path in current_deps_output {
225+
child.args(&[format!("-L{}", link_path.display())]);
226+
}
217227

218228
if let Some(target) = matches.opt_str("target") {
219229
child.args(&["--target", &target]);
@@ -235,6 +245,8 @@ fn run(config: &cargo::Config, matches: &getopts::Matches) -> Result<()> {
235245
},
236246
);
237247

248+
debug!("rust-semverver invocation: {:?}", child);
249+
238250
let mut child = child
239251
.spawn()
240252
.map_err(|e| anyhow::Error::msg(format!("could not spawn rustc: {}", e)))?;
@@ -474,7 +486,7 @@ impl<'a> WorkInfo<'a> {
474486
name: &str,
475487
current: bool,
476488
matches: &getopts::Matches,
477-
) -> Result<(PathBuf, PathBuf)> {
489+
) -> Result<(PathBuf, Vec<PathBuf>)> {
478490
// We don't need codegen-ready artifacts (which .rlib files are) so
479491
// settle for .rmeta files, which result from `cargo check` mode
480492
let mode = cargo::core::compiler::CompileMode::Check { test: false };
@@ -531,18 +543,29 @@ impl<'a> WorkInfo<'a> {
531543
let build_plan: BuildPlan = serde_json::from_slice(&plan_output)
532544
.map_err(|_| anyhow::anyhow!("Can't read build plan"))?;
533545

534-
// TODO: handle multiple outputs gracefully
535-
for i in &build_plan.invocations {
546+
debug!("{:?}", &build_plan.invocations);
547+
let paths = build_plan.invocations.iter().find_map(|i| {
536548
if let Some(kind) = i.target_kind.get(0) {
537549
if kind.contains("lib") && i.package_name == name {
538-
let deps_output = &compilation.deps_output[&compile_kind];
539-
540-
return Ok((i.outputs[0].clone(), deps_output.clone()));
550+
let rlib_path = i.outputs[0].clone();
551+
let mut link_paths = vec![
552+
compilation.deps_output[&compile_kind].clone(),
553+
compilation.deps_output[&cargo::core::compiler::CompileKind::Host].clone(),
554+
];
555+
// if host and `compile_kind` are the same, only return once
556+
link_paths.dedup();
557+
return Some((rlib_path, link_paths));
541558
}
542559
}
543-
}
544560

545-
Err(anyhow::Error::msg("lost build artifact".to_owned()))
561+
None
562+
});
563+
564+
if let Some(paths) = paths {
565+
Ok(paths)
566+
} else {
567+
Err(anyhow::Error::msg("lost build artifact".to_owned()))
568+
}
546569
}
547570
}
548571

tests/full.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,6 @@ mod full {
1010
};
1111

1212
fn test_full(crate_name: &str, old_version: &str, new_version: &str, expected_result: bool) {
13-
// FIXME: CI started to fail since 2022-04-25, ignore the rmpv test on CI for now.
14-
if crate_name == "rmpv" && env::var_os("CI").unwrap_or_default() == "true" {
15-
return;
16-
}
17-
1813
// Add target dir to PATH so cargo-semver will call the right rust-semverver
1914
if let Some(path) = env::var_os("PATH") {
2015
let mut paths = env::split_paths(&path).collect::<Vec<_>>();
@@ -94,14 +89,18 @@ mod full {
9489
.expect("could not read line from rust-semverver output")
9590
.trim_end();
9691

92+
let has_expected_line = stdout.lines().any(|l| l.starts_with("version bump"));
93+
9794
stdout
9895
.lines()
9996
.chain(stderr.lines())
10097
.map(|l| l.trim_end())
10198
.skip_while(|line|
10299
// skip everything before the first important bit of info
103100
!line.starts_with("version bump") &&
104-
// ...unless debugging is enabled
101+
// ...if we know it's in there at all
102+
has_expected_line &&
103+
// ...unless debugging is enabled, then always show
105104
!log_enabled!(Level::Debug))
106105
.map(|line| {
107106
// sanitize paths for reproducibility

0 commit comments

Comments
 (0)