Skip to content

Commit

Permalink
Auto merge of #6326 - dwijnand:verify_project_honours_unstable_featur…
Browse files Browse the repository at this point in the history
…es, r=alexcrichton

Make verify-project honour unstable features

Fixes #6209
  • Loading branch information
bors committed Nov 19, 2018
2 parents cd43d3a + dc6b5be commit bf6aa59
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 32 deletions.
19 changes: 2 additions & 17 deletions src/bin/cargo/commands/verify_project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@ use command_prelude::*;

use std::collections::HashMap;
use std::process;
use std::fs::File;
use std::io::Read;

use toml;

use cargo::print_json;

Expand All @@ -23,19 +19,8 @@ pub fn exec(config: &mut Config, args: &ArgMatches) -> CliResult {
process::exit(1)
}

let mut contents = String::new();
let filename = match args.root_manifest(config) {
Ok(filename) => filename,
Err(e) => fail("invalid", &e.to_string()),
};

let file = File::open(&filename);
match file.and_then(|mut f| f.read_to_string(&mut contents)) {
Ok(_) => {}
Err(e) => fail("invalid", &format!("error reading file: {}", e)),
};
if contents.parse::<toml::Value>().is_err() {
fail("invalid", "invalid-format");
if let Err(e) = args.workspace(config) {
fail("invalid", &e.to_string())
}

let mut h = HashMap::new();
Expand Down
9 changes: 3 additions & 6 deletions tests/testsuite/cargo_command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -265,12 +265,9 @@ fn cargo_subcommand_args() {
cargo_process("foo bar -v --help")
.env("PATH", &path)
.with_stdout(
if cfg!(windows) { // weird edge-case w/ CWD & (windows vs unix)
format!(r#"[{:?}, "foo", "bar", "-v", "--help"]"#, cargo_foo_bin)
} else {
r#"["[CWD]/cargo-foo/target/debug/cargo-foo", "foo", "bar", "-v", "--help"]"#.to_string()
}
).run();
r#"["[CWD]/cargo-foo/target/debug/cargo-foo[EXE]", "foo", "bar", "-v", "--help"]"#,
)
.run();
}

#[test]
Expand Down
6 changes: 4 additions & 2 deletions tests/testsuite/support/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1188,8 +1188,10 @@ enum MatchKind {
/// See `substitute_macros` for a complete list of macros.
pub fn lines_match(expected: &str, actual: &str) -> bool {
// Let's not deal with / vs \ (windows...)
let expected = expected.replace("\\", "/");
let mut actual: &str = &actual.replace("\\", "/");
// First replace backslash-escaped backslashes with forward slashes
// which can occur in, for example, JSON output
let expected = expected.replace("\\\\", "/").replace("\\", "/");
let mut actual: &str = &actual.replace("\\\\", "/").replace("\\", "/");
let expected = substitute_macros(&expected);
for (i, part) in expected.split("[..]").enumerate() {
match actual.find(part) {
Expand Down
10 changes: 3 additions & 7 deletions tests/testsuite/tool_paths.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ fn pathless_tools() {
#[test]
fn absolute_tools() {
let target = rustc_host();
let root = if cfg!(windows) { r#"C:\"# } else { "/" };

// Escaped as they appear within a TOML config file
let config = if cfg!(windows) {
Expand Down Expand Up @@ -62,14 +61,11 @@ fn absolute_tools() {
),
).build();

foo.cargo("build --verbose").with_stderr(&format!(
"\
foo.cargo("build --verbose").with_stderr("\
[COMPILING] foo v0.5.0 ([CWD])
[RUNNING] `rustc [..] -C ar={root}bogus/nonexistent-ar -C linker={root}bogus/nonexistent-linker [..]`
[RUNNING] `rustc [..] -C ar=[ROOT]bogus/nonexistent-ar -C linker=[ROOT]bogus/nonexistent-linker [..]`
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
",
root = root,
)).run();
").run();
}

#[test]
Expand Down
24 changes: 24 additions & 0 deletions tests/testsuite/verify_project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,27 @@ fn cargo_verify_project_cwd() {
.with_stdout(verify_project_success_output())
.run();
}

#[test]
fn cargo_verify_project_honours_unstable_features() {
let p = project()
.file("Cargo.toml", r#"
cargo-features = ["test-dummy-unstable"]
[package]
name = "foo"
version = "0.0.1"
"#)
.file("src/lib.rs", "")
.build();

p.cargo("verify-project")
.masquerade_as_nightly_cargo()
.with_stdout(verify_project_success_output())
.run();

p.cargo("verify-project")
.with_status(1)
.with_stdout(r#"{"invalid":"failed to parse manifest at `[CWD]/Cargo.toml`"}"#)
.run();
}

0 comments on commit bf6aa59

Please sign in to comment.