diff --git a/src/bin/cargo/commands/verify_project.rs b/src/bin/cargo/commands/verify_project.rs index eea65c77598..b7887591bd8 100644 --- a/src/bin/cargo/commands/verify_project.rs +++ b/src/bin/cargo/commands/verify_project.rs @@ -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; @@ -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::().is_err() { - fail("invalid", "invalid-format"); + if let Err(e) = args.workspace(config) { + fail("invalid", &e.to_string()) } let mut h = HashMap::new(); diff --git a/tests/testsuite/cargo_command.rs b/tests/testsuite/cargo_command.rs index 8e0b6e19f15..793ed50299c 100644 --- a/tests/testsuite/cargo_command.rs +++ b/tests/testsuite/cargo_command.rs @@ -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] diff --git a/tests/testsuite/support/mod.rs b/tests/testsuite/support/mod.rs index 06b7c6c3df9..9c8fbec795c 100644 --- a/tests/testsuite/support/mod.rs +++ b/tests/testsuite/support/mod.rs @@ -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) { diff --git a/tests/testsuite/tool_paths.rs b/tests/testsuite/tool_paths.rs index 5bd256715d6..d952991f322 100644 --- a/tests/testsuite/tool_paths.rs +++ b/tests/testsuite/tool_paths.rs @@ -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) { @@ -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] diff --git a/tests/testsuite/verify_project.rs b/tests/testsuite/verify_project.rs index d368b7c9fb4..060e3e3df52 100644 --- a/tests/testsuite/verify_project.rs +++ b/tests/testsuite/verify_project.rs @@ -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(); +}