From fc08da9e25cc448e05885972177ad6a734e5b349 Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Tue, 26 Feb 2019 11:50:18 +0100 Subject: [PATCH 01/10] Fix exit code of rust-semverver in tests --- src/bin/rust_semverver.rs | 1 - tests/cases/regions/stdout | 18 ++++++- tests/examples.rs | 105 ++++++++++++++++++------------------- 3 files changed, 69 insertions(+), 55 deletions(-) diff --git a/src/bin/rust_semverver.rs b/src/bin/rust_semverver.rs index 22a4c076..8a342adb 100644 --- a/src/bin/rust_semverver.rs +++ b/src/bin/rust_semverver.rs @@ -1,5 +1,4 @@ #![feature(rustc_private)] -#![feature(try_from)] extern crate getopts; extern crate rustc; diff --git a/tests/cases/regions/stdout b/tests/cases/regions/stdout index 4abe1dd6..d012a211 100644 --- a/tests/cases/regions/stdout +++ b/tests/cases/regions/stdout @@ -31,5 +31,21 @@ error: breaking changes in `def` | = warning: type error: expected reference, found bool (breaking) -error: aborting due to 4 previous errors +error: breaking changes in `efg` + --> $REPO_PATH/tests/cases/regions/new.rs:17:1 + | +17 | pub fn efg(_: &str) { } + | ^^^^^^^^^^^^^^^^^^^^^^^ + | + = warning: type error: expected bound lifetime parameterBrAnon(0), found concrete lifetime (breaking) + +error: breaking changes in `fgh` + --> $REPO_PATH/tests/cases/regions/new.rs:19:1 + | +19 | pub fn fgh(_: &'static str) { } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = warning: type error: expected bound lifetime parameterBrAnon(0), found concrete lifetime (breaking) + +error: aborting due to 6 previous errors diff --git a/tests/examples.rs b/tests/examples.rs index d4a72fdb..9dc94e8a 100644 --- a/tests/examples.rs +++ b/tests/examples.rs @@ -5,9 +5,7 @@ mod features { process::{Command, Stdio}, }; - fn test_example(path: &Path, out_file: &Path) { - let mut success = true; - + fn test_example(path: &Path, out_file: &Path, expected_result: bool) { let old_rlib = path.join("libold.rlib").to_str().unwrap().to_owned(); let new_rlib = path.join("libnew.rlib").to_str().unwrap().to_owned(); @@ -29,8 +27,8 @@ mod features { cmd.args(target_args); } - success &= cmd.status().expect("could not run rustc").success(); - assert!(success, "couldn't compile old"); + let rustc_old_result = cmd.status().expect("could not run rustc on old").success(); + assert!(rustc_old_result, "couldn't compile old"); let mut cmd = Command::new("rustc"); cmd.args(&["--crate-type=lib", "-o", &new_rlib]) @@ -42,9 +40,8 @@ mod features { cmd.args(target_args); } - success &= cmd.status().expect("could not run rustc").success(); - - assert!(success, "couldn't compile new"); + let rustc_new_result = cmd.status().expect("could not run rustc on new").success(); + assert!(rustc_new_result, "couldn't compile new"); let mut cmd = Command::new( Path::new(".") @@ -81,12 +78,11 @@ mod features { cmd.env("RUST_SEMVER_API_GUIDELINES", "true"); } - success &= cmd - .status() - .expect("could not run rust-semverver") - .success(); - - assert!(success, "rust-semverver"); + let rustsemverver_result = cmd.status().expect("could not run rust-semverver").success(); + assert_eq!( + rustsemverver_result, expected_result, + "rust-semverver returned an unexpected result" + ); { // replace root path with with $REPO_PATH @@ -122,7 +118,7 @@ mod features { } } - success &= Command::new("git") + let git_result = Command::new("git") .args(&[ "diff", "--ignore-space-at-eol", @@ -134,7 +130,7 @@ mod features { .expect("could not run git diff") .success(); - assert!(success, "git"); + assert!(git_result, "git reports a diff"); Command::new("rm") .args(&[&old_rlib, &new_rlib]) @@ -143,54 +139,57 @@ mod features { } macro_rules! test { - ($name:ident) => { + ($name:ident => $result:literal) => { #[test] fn $name() { let path = Path::new("tests").join("cases").join(stringify!($name)); - test_example(&path, &path.join("stdout")); + test_example(&path, &path.join("stdout"), $result); if path.join("stdout_api_guidelines").exists() { eprintln!("api-guidelines"); - test_example(&path, &path.join("stdout_api_guidelines")); + test_example(&path, &path.join("stdout_api_guidelines"), $result); } } }; - ($($name:ident),*) => { - $(test!($name);)* - } + ($($name:ident => $result:literal),*) => { + $(test!($name => $result);)* + }; + ($($name:ident => $result:literal,)*) => { + $(test!($name => $result);)* + }; } test! { - addition, - addition_path, - addition_use, - bounds, - circular, - consts, - enums, - func, - func_local_items, - infer, - infer_regress, - inherent_impls, - issue_34, - issue_50, - kind_change, - macros, - max_priv, - mix, - pathologic_paths, - pub_use, - regions, - removal, - removal_path, - removal_use, - sealed_traits, - structs, - swap, - traits, - trait_impls, - trait_objects, - ty_alias + addition => true, + addition_path => true, + addition_use => false, + bounds => false, + circular => true, + consts => false, + enums => false, + func => false, + func_local_items => true, + infer => true, + infer_regress => false, + inherent_impls => false, + issue_34 => true, + issue_50 => true, + kind_change => false, + macros => false, + max_priv => true, + mix => false, + pathologic_paths => true, + pub_use => true, + regions => false, + removal => false, + removal_path => false, + removal_use => false, + sealed_traits => true, + structs => false, + swap => true, + traits => false, + trait_impls => false, + trait_objects => true, + ty_alias => false, } } From 5a8c55198a3f242dafc958e4aae82af0960b97b7 Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Tue, 26 Feb 2019 13:13:25 +0100 Subject: [PATCH 02/10] Correctly propagate rustc-semverver error in cargo-semver --- src/bin/cargo_semver.rs | 8 ++++-- tests/examples.rs | 4 +-- tests/full.rs | 34 ++++++++++++++--------- tests/full_cases/libc-0.2.28-0.2.31.linux | 2 ++ tests/full_cases/libc-0.2.28-0.2.31.osx | 2 ++ 5 files changed, 33 insertions(+), 17 deletions(-) diff --git a/src/bin/cargo_semver.rs b/src/bin/cargo_semver.rs index 52ace312..e86a14fd 100644 --- a/src/bin/cargo_semver.rs +++ b/src/bin/cargo_semver.rs @@ -182,11 +182,15 @@ fn run(config: &cargo::Config, matches: &getopts::Matches, explain: bool) -> Res return Err(failure::err_msg("could not pipe to rustc (wtf?)".to_owned()).into()); } - child + let exit_status = child .wait() .map_err(|e| failure::err_msg(format!("failed to wait for rustc: {}", e)))?; - Ok(()) + if exit_status.success() { + Ok(()) + } else { + Err(failure::err_msg("rustc-semverver errored".to_owned())) + } } /// CLI utils diff --git a/tests/examples.rs b/tests/examples.rs index 9dc94e8a..36a90351 100644 --- a/tests/examples.rs +++ b/tests/examples.rs @@ -81,7 +81,7 @@ mod features { let rustsemverver_result = cmd.status().expect("could not run rust-semverver").success(); assert_eq!( rustsemverver_result, expected_result, - "rust-semverver returned an unexpected result" + "rust-semverver returned an unexpected exit status" ); { @@ -130,7 +130,7 @@ mod features { .expect("could not run git diff") .success(); - assert!(git_result, "git reports a diff"); + assert!(git_result, "git reports unexpected diff"); Command::new("rm") .args(&[&old_rlib, &new_rlib]) diff --git a/tests/full.rs b/tests/full.rs index 0df8d3db..a02ed259 100644 --- a/tests/full.rs +++ b/tests/full.rs @@ -6,9 +6,12 @@ mod full { process::{Command, Stdio}, }; - fn test_full(crate_name: &str, old_version: &str, new_version: &str) { - let mut success = true; - + fn test_full( + crate_name: &str, + old_version: &str, + new_version: &str, + expected_result: bool + ) { let prog = format!( r#" # wait for the actual output @@ -90,7 +93,7 @@ mod full { let old_version = format!("{}:{}", crate_name, old_version); let new_version = format!("{}:{}", crate_name, new_version); - success &= { + let cargo_semver_result = { let mut cmd = Command::new("./target/debug/cargo-semver"); cmd.args(&["-S", &old_version, "-C", &new_version]) .env("RUST_BACKTRACE", "full") @@ -105,36 +108,41 @@ mod full { cmd.status().expect("could not run cargo semver").success() }; - assert!(success, "cargo semver"); + assert_eq!( + cargo_semver_result, expected_result, + "cargo semver returned an unexpected exit status" + ); - success &= awk_child + let awk_result = awk_child .wait() .expect("could not wait for awk child") .success(); - assert!(success, "awk"); + assert!(awk_result, "awk"); - success &= Command::new("git") + let git_result = Command::new("git") .args(&["diff", "--ignore-space-at-eol", "--exit-code", out_file]) .env("PAGER", "") .status() .expect("could not run git diff") .success(); - assert!(success, "git"); + assert!(git_result, "git reports unexpected diff"); } macro_rules! full_test { - ($name:ident, $crate_name:expr, $old_version:expr, $new_version:expr) => { + ($name:ident, $crate_name:expr, + $old_version:expr, $new_version:expr, + $result:literal) => { #[test] fn $name() { - test_full($crate_name, $old_version, $new_version); + test_full($crate_name, $old_version, $new_version, $result); } }; } - full_test!(log, "log", "0.3.4", "0.3.8"); - full_test!(libc, "libc", "0.2.28", "0.2.31"); + full_test!(log, "log", "0.3.4", "0.3.8", true); + full_test!(libc, "libc", "0.2.28", "0.2.31", false); // full_test!(mozjs, "mozjs", "0.2.0", "0.3.0"); // full_test!(rand, "rand", "0.3.10", "0.3.16"); // full_test!(serde_pre, "serde", "0.7.0", "1.0.0"); diff --git a/tests/full_cases/libc-0.2.28-0.2.31.linux b/tests/full_cases/libc-0.2.28-0.2.31.linux index 04597882..0bc8c77f 100644 --- a/tests/full_cases/libc-0.2.28-0.2.31.linux +++ b/tests/full_cases/libc-0.2.28-0.2.31.linux @@ -867,3 +867,5 @@ note: added path (technically breaking) error: aborting due to 11 previous errors +error: rustc-semverver errored + diff --git a/tests/full_cases/libc-0.2.28-0.2.31.osx b/tests/full_cases/libc-0.2.28-0.2.31.osx index 69569916..fe2489ca 100644 --- a/tests/full_cases/libc-0.2.28-0.2.31.osx +++ b/tests/full_cases/libc-0.2.28-0.2.31.osx @@ -2369,3 +2369,5 @@ note: added path (technically breaking) error: aborting due to previous error +error: rustc-semverver errored + From d6f928159ebf9b732fba2aab35f9ba681748e1c6 Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Tue, 26 Feb 2019 13:13:35 +0100 Subject: [PATCH 03/10] Formatting --- src/bin/cargo_semver.rs | 11 ++++++----- tests/examples.rs | 5 ++++- tests/full.rs | 7 +------ 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/src/bin/cargo_semver.rs b/src/bin/cargo_semver.rs index e86a14fd..01dec35d 100644 --- a/src/bin/cargo_semver.rs +++ b/src/bin/cargo_semver.rs @@ -11,9 +11,9 @@ use cargo::core::{Package, PackageId, PackageSet, Source, SourceId, SourceMap, W use log::debug; use std::{ env, + fs::File, io::BufReader, io::Write, - fs::File, path::{Path, PathBuf}, process::{Command, Stdio}, }; @@ -390,8 +390,10 @@ impl<'a> WorkInfo<'a> { opts.build_config.build_plan = true; // TODO: this is where we could insert feature flag builds (or using the CLI mechanisms) - env::set_var("RUSTFLAGS", - format!("-C metadata={}", if current { "new" } else { "old" })); + env::set_var( + "RUSTFLAGS", + format!("-C metadata={}", if current { "new" } else { "old" }), + ); let mut outdir = env::temp_dir(); outdir.push(&format!("cargo_semver_{}_{}", name, current)); @@ -410,8 +412,7 @@ impl<'a> WorkInfo<'a> { let compilation = cargo::ops::compile(&self.workspace, &opts)?; env::remove_var("RUSTFLAGS"); - let build_plan: BuildPlan = - serde_json::from_reader(BufReader::new(File::open(&outdir)?))?; + let build_plan: BuildPlan = serde_json::from_reader(BufReader::new(File::open(&outdir)?))?; // TODO: handle multiple outputs gracefully for i in &build_plan.invocations { diff --git a/tests/examples.rs b/tests/examples.rs index 36a90351..d9911ae2 100644 --- a/tests/examples.rs +++ b/tests/examples.rs @@ -78,7 +78,10 @@ mod features { cmd.env("RUST_SEMVER_API_GUIDELINES", "true"); } - let rustsemverver_result = cmd.status().expect("could not run rust-semverver").success(); + let rustsemverver_result = cmd + .status() + .expect("could not run rust-semverver") + .success(); assert_eq!( rustsemverver_result, expected_result, "rust-semverver returned an unexpected exit status" diff --git a/tests/full.rs b/tests/full.rs index a02ed259..a65e8c5a 100644 --- a/tests/full.rs +++ b/tests/full.rs @@ -6,12 +6,7 @@ mod full { process::{Command, Stdio}, }; - fn test_full( - crate_name: &str, - old_version: &str, - new_version: &str, - expected_result: bool - ) { + fn test_full(crate_name: &str, old_version: &str, new_version: &str, expected_result: bool) { let prog = format!( r#" # wait for the actual output From eff2d7db61fab4b17f31d48b1c40d9390f1ae758 Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Tue, 26 Feb 2019 13:21:29 +0100 Subject: [PATCH 04/10] Fix clippy issues --- src/bin/cargo_semver.rs | 6 +++--- src/changes.rs | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/bin/cargo_semver.rs b/src/bin/cargo_semver.rs index 01dec35d..c768db4e 100644 --- a/src/bin/cargo_semver.rs +++ b/src/bin/cargo_semver.rs @@ -179,7 +179,9 @@ fn run(config: &cargo::Config, matches: &getopts::Matches, explain: bool) -> Res extern crate new;" ))?; } else { - return Err(failure::err_msg("could not pipe to rustc (wtf?)".to_owned()).into()); + return Err(failure::err_msg( + "could not pipe to rustc (wtf?)".to_owned(), + )); } let exit_status = child @@ -438,7 +440,6 @@ pub fn find_on_crates_io(crate_name: &str) -> Result { "failed to retrieve search results from the registry: {}", e )) - .into() }) .and_then(|(mut crates, _)| { crates @@ -446,7 +447,6 @@ pub fn find_on_crates_io(crate_name: &str) -> Result { .find(|krate| krate.name == crate_name) .ok_or_else(|| { failure::err_msg(format!("failed to find a matching crate `{}`", crate_name)) - .into() }) }) } diff --git a/src/changes.rs b/src/changes.rs index 92e83954..6f1b3a4f 100644 --- a/src/changes.rs +++ b/src/changes.rs @@ -875,7 +875,7 @@ impl<'tcx> ChangeSet<'tcx> { pub fn trait_item_breaking(&self, old: DefId) -> bool { self.changes .get(&old) - .map_or(false, |change| change.trait_item_breaking()) + .map_or(false, Change::trait_item_breaking) } /// Format the contents of a change set for user output. From d43085349fbe8e25df3948021d0513a1cbd5516a Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Tue, 26 Feb 2019 14:29:58 +0100 Subject: [PATCH 05/10] Fix whitespace in test file --- tests/full_cases/libc-0.2.28-0.2.31.osx | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/full_cases/libc-0.2.28-0.2.31.osx b/tests/full_cases/libc-0.2.28-0.2.31.osx index fe2489ca..7cd9606a 100644 --- a/tests/full_cases/libc-0.2.28-0.2.31.osx +++ b/tests/full_cases/libc-0.2.28-0.2.31.osx @@ -2370,4 +2370,3 @@ note: added path (technically breaking) error: aborting due to previous error error: rustc-semverver errored - From b7e9ebd126ee25c5345b3e70e618fe9835f3b093 Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Tue, 26 Feb 2019 14:32:16 +0100 Subject: [PATCH 06/10] Add support for libraries with build.rs --- ci/run.sh | 3 +++ src/bin/cargo_semver.rs | 8 ++++++++ tests/full.rs | 8 +++++--- tests/full_cases/libc-0.2.47-0.2.48.osx | 1 + 4 files changed, 17 insertions(+), 3 deletions(-) create mode 100644 tests/full_cases/libc-0.2.47-0.2.48.osx diff --git a/ci/run.sh b/ci/run.sh index fc50ec13..b8d42439 100755 --- a/ci/run.sh +++ b/ci/run.sh @@ -2,6 +2,9 @@ set -ex +# Note: this is required for correctness, +# otherwise executing multiple "full" tests in parallel +# of the same library can alter results. export RUST_TEST_THREADS=1 export RUST_BACKTRACE=full #export RUST_TEST_NOCAPTURE=1 diff --git a/src/bin/cargo_semver.rs b/src/bin/cargo_semver.rs index c768db4e..c6fbf20f 100644 --- a/src/bin/cargo_semver.rs +++ b/src/bin/cargo_semver.rs @@ -419,6 +419,14 @@ impl<'a> WorkInfo<'a> { // TODO: handle multiple outputs gracefully for i in &build_plan.invocations { if i.package_name == name { + // FIXME: this is a hack to avoid picking up output artifacts of + // build scrits and build programs (no outputs): + let build_script = + i.outputs.iter().any(|v| v.to_str().unwrap().contains("build_script")); + let build_program = i.outputs.is_empty(); + if build_script || build_program { + continue; + } return Ok((i.outputs[0].clone(), compilation.deps_output)); } } diff --git a/tests/full.rs b/tests/full.rs index a65e8c5a..70180b20 100644 --- a/tests/full.rs +++ b/tests/full.rs @@ -46,7 +46,7 @@ mod full { }; let out_file: PathBuf = format!("{}.{}", out_file.display(), file_ext).into(); - assert!(out_file.exists()); + assert!(out_file.exists(), "file `{}` does not exist", out_file.display()); if let Some(path) = env::var_os("PATH") { let mut paths = env::split_paths(&path).collect::>(); @@ -94,7 +94,8 @@ mod full { .env("RUST_BACKTRACE", "full") .stdin(Stdio::null()) .stdout(out_pipe) - .stderr(err_pipe); + .stderr(err_pipe) + ; if let Ok(target) = std::env::var("TEST_TARGET") { cmd.args(&["--target", &target]); @@ -137,7 +138,8 @@ mod full { } full_test!(log, "log", "0.3.4", "0.3.8", true); - full_test!(libc, "libc", "0.2.28", "0.2.31", false); + full_test!(libc0, "libc", "0.2.28", "0.2.31", false); + full_test!(libc1, "libc", "0.2.47", "0.2.48", true); // full_test!(mozjs, "mozjs", "0.2.0", "0.3.0"); // full_test!(rand, "rand", "0.3.10", "0.3.16"); // full_test!(serde_pre, "serde", "0.7.0", "1.0.0"); diff --git a/tests/full_cases/libc-0.2.47-0.2.48.osx b/tests/full_cases/libc-0.2.47-0.2.48.osx new file mode 100644 index 00000000..0588e910 --- /dev/null +++ b/tests/full_cases/libc-0.2.47-0.2.48.osx @@ -0,0 +1 @@ +version bump: 0.2.47 -> (patch) -> 0.2.48 From 0b3e046d76b8cf3907d9390a3d889d4fc6cd0ee8 Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Tue, 26 Feb 2019 15:38:19 +0100 Subject: [PATCH 07/10] Formatting --- tests/full.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tests/full.rs b/tests/full.rs index 70180b20..3a264fc0 100644 --- a/tests/full.rs +++ b/tests/full.rs @@ -46,7 +46,11 @@ mod full { }; let out_file: PathBuf = format!("{}.{}", out_file.display(), file_ext).into(); - assert!(out_file.exists(), "file `{}` does not exist", out_file.display()); + assert!( + out_file.exists(), + "file `{}` does not exist", + out_file.display() + ); if let Some(path) = env::var_os("PATH") { let mut paths = env::split_paths(&path).collect::>(); @@ -94,8 +98,7 @@ mod full { .env("RUST_BACKTRACE", "full") .stdin(Stdio::null()) .stdout(out_pipe) - .stderr(err_pipe) - ; + .stderr(err_pipe); if let Ok(target) = std::env::var("TEST_TARGET") { cmd.args(&["--target", &target]); From 6ee972f423e2454cef1559b4aab4c9e8c7f92aec Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Tue, 26 Feb 2019 15:38:30 +0100 Subject: [PATCH 08/10] Properly forward a requested target --- src/bin/cargo_semver.rs | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/bin/cargo_semver.rs b/src/bin/cargo_semver.rs index c6fbf20f..fd20931b 100644 --- a/src/bin/cargo_semver.rs +++ b/src/bin/cargo_semver.rs @@ -120,8 +120,10 @@ fn run(config: &cargo::Config, matches: &getopts::Matches, explain: bool) -> Res (work_info, stable_crate.max_version.clone()) }; - let (current_rlib, current_deps_output) = current.rlib_and_dep_output(config, &name, true)?; - let (stable_rlib, stable_deps_output) = stable.rlib_and_dep_output(config, &name, false)?; + let (current_rlib, current_deps_output) = + current.rlib_and_dep_output(config, &name, true, matches)?; + let (stable_rlib, stable_deps_output) = + stable.rlib_and_dep_output(config, &name, false, matches)?; println!("current_rlib: {:?}", current_rlib); println!("stable_rlib: {:?}", stable_rlib); @@ -385,11 +387,17 @@ impl<'a> WorkInfo<'a> { config: &'a cargo::Config, name: &str, current: bool, + matches: &getopts::Matches, ) -> Result<(PathBuf, PathBuf)> { let mut opts = cargo::ops::CompileOptions::new(config, cargo::core::compiler::CompileMode::Build)?; // we need the build plan to find our build artifacts opts.build_config.build_plan = true; + + if let Some(target) = matches.opt_str("target") { + opts.build_config.requested_target = Some(target); + } + // TODO: this is where we could insert feature flag builds (or using the CLI mechanisms) env::set_var( @@ -421,8 +429,10 @@ impl<'a> WorkInfo<'a> { if i.package_name == name { // FIXME: this is a hack to avoid picking up output artifacts of // build scrits and build programs (no outputs): - let build_script = - i.outputs.iter().any(|v| v.to_str().unwrap().contains("build_script")); + let build_script = i + .outputs + .iter() + .any(|v| v.to_str().unwrap().contains("build_script")); let build_program = i.outputs.is_empty(); if build_script || build_program { continue; From 4ee87d5755f9b307b2cae64c6285158e964267cf Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Tue, 26 Feb 2019 15:49:04 +0100 Subject: [PATCH 09/10] Add support for --no-default-features to cargo-semver --- src/bin/cargo_semver.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/bin/cargo_semver.rs b/src/bin/cargo_semver.rs index fd20931b..289b2572 100644 --- a/src/bin/cargo_semver.rs +++ b/src/bin/cargo_semver.rs @@ -153,6 +153,10 @@ fn run(config: &cargo::Config, matches: &getopts::Matches, explain: bool) -> Res child.args(&["--target", &target]); } + if !matches.opt_present("no-default-features") { + child.args(&["--cfg", "feature=\"default\""]); + } + let child = child .arg("-") .stdin(Stdio::piped()) @@ -215,6 +219,11 @@ mod cli { "api-guidelines", "report only changes that are breaking according to the API-guidelines", ); + opts.optflag( + "", + "no-default-features", + "Do not activate the `default` feature", + ); opts.optopt( "s", "stable-path", @@ -397,6 +406,7 @@ impl<'a> WorkInfo<'a> { if let Some(target) = matches.opt_str("target") { opts.build_config.requested_target = Some(target); } + opts.no_default_features = matches.opt_present("no-default-features"); // TODO: this is where we could insert feature flag builds (or using the CLI mechanisms) From 8bbf05b895942c35b12c0284aab133cd136301b3 Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Wed, 27 Feb 2019 10:24:18 +0100 Subject: [PATCH 10/10] Filter outputs by lib target_kind --- src/bin/cargo_semver.rs | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/src/bin/cargo_semver.rs b/src/bin/cargo_semver.rs index 289b2572..71d54a38 100644 --- a/src/bin/cargo_semver.rs +++ b/src/bin/cargo_semver.rs @@ -23,6 +23,7 @@ pub type Result = cargo::util::CargoResult; #[derive(Debug, Deserialize)] struct Invocation { package_name: String, + target_kind: Vec, outputs: Vec, } @@ -436,18 +437,10 @@ impl<'a> WorkInfo<'a> { // TODO: handle multiple outputs gracefully for i in &build_plan.invocations { - if i.package_name == name { - // FIXME: this is a hack to avoid picking up output artifacts of - // build scrits and build programs (no outputs): - let build_script = i - .outputs - .iter() - .any(|v| v.to_str().unwrap().contains("build_script")); - let build_program = i.outputs.is_empty(); - if build_script || build_program { - continue; + if let Some(kind) = i.target_kind.get(0) { + if kind.contains("lib") && i.package_name == name { + return Ok((i.outputs[0].clone(), compilation.deps_output)); } - return Ok((i.outputs[0].clone(), compilation.deps_output)); } }