Skip to content

Commit bf6aa59

Browse files
committed
Auto merge of #6326 - dwijnand:verify_project_honours_unstable_features, r=alexcrichton
Make verify-project honour unstable features Fixes #6209
2 parents cd43d3a + dc6b5be commit bf6aa59

File tree

5 files changed

+36
-32
lines changed

5 files changed

+36
-32
lines changed

src/bin/cargo/commands/verify_project.rs

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,6 @@ use command_prelude::*;
22

33
use std::collections::HashMap;
44
use std::process;
5-
use std::fs::File;
6-
use std::io::Read;
7-
8-
use toml;
95

106
use cargo::print_json;
117

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

26-
let mut contents = String::new();
27-
let filename = match args.root_manifest(config) {
28-
Ok(filename) => filename,
29-
Err(e) => fail("invalid", &e.to_string()),
30-
};
31-
32-
let file = File::open(&filename);
33-
match file.and_then(|mut f| f.read_to_string(&mut contents)) {
34-
Ok(_) => {}
35-
Err(e) => fail("invalid", &format!("error reading file: {}", e)),
36-
};
37-
if contents.parse::<toml::Value>().is_err() {
38-
fail("invalid", "invalid-format");
22+
if let Err(e) = args.workspace(config) {
23+
fail("invalid", &e.to_string())
3924
}
4025

4126
let mut h = HashMap::new();

tests/testsuite/cargo_command.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -265,12 +265,9 @@ fn cargo_subcommand_args() {
265265
cargo_process("foo bar -v --help")
266266
.env("PATH", &path)
267267
.with_stdout(
268-
if cfg!(windows) { // weird edge-case w/ CWD & (windows vs unix)
269-
format!(r#"[{:?}, "foo", "bar", "-v", "--help"]"#, cargo_foo_bin)
270-
} else {
271-
r#"["[CWD]/cargo-foo/target/debug/cargo-foo", "foo", "bar", "-v", "--help"]"#.to_string()
272-
}
273-
).run();
268+
r#"["[CWD]/cargo-foo/target/debug/cargo-foo[EXE]", "foo", "bar", "-v", "--help"]"#,
269+
)
270+
.run();
274271
}
275272

276273
#[test]

tests/testsuite/support/mod.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1188,8 +1188,10 @@ enum MatchKind {
11881188
/// See `substitute_macros` for a complete list of macros.
11891189
pub fn lines_match(expected: &str, actual: &str) -> bool {
11901190
// Let's not deal with / vs \ (windows...)
1191-
let expected = expected.replace("\\", "/");
1192-
let mut actual: &str = &actual.replace("\\", "/");
1191+
// First replace backslash-escaped backslashes with forward slashes
1192+
// which can occur in, for example, JSON output
1193+
let expected = expected.replace("\\\\", "/").replace("\\", "/");
1194+
let mut actual: &str = &actual.replace("\\\\", "/").replace("\\", "/");
11931195
let expected = substitute_macros(&expected);
11941196
for (i, part) in expected.split("[..]").enumerate() {
11951197
match actual.find(part) {

tests/testsuite/tool_paths.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ fn pathless_tools() {
3333
#[test]
3434
fn absolute_tools() {
3535
let target = rustc_host();
36-
let root = if cfg!(windows) { r#"C:\"# } else { "/" };
3736

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

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

7571
#[test]

tests/testsuite/verify_project.rs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,27 @@ fn cargo_verify_project_cwd() {
4242
.with_stdout(verify_project_success_output())
4343
.run();
4444
}
45+
46+
#[test]
47+
fn cargo_verify_project_honours_unstable_features() {
48+
let p = project()
49+
.file("Cargo.toml", r#"
50+
cargo-features = ["test-dummy-unstable"]
51+
52+
[package]
53+
name = "foo"
54+
version = "0.0.1"
55+
"#)
56+
.file("src/lib.rs", "")
57+
.build();
58+
59+
p.cargo("verify-project")
60+
.masquerade_as_nightly_cargo()
61+
.with_stdout(verify_project_success_output())
62+
.run();
63+
64+
p.cargo("verify-project")
65+
.with_status(1)
66+
.with_stdout(r#"{"invalid":"failed to parse manifest at `[CWD]/Cargo.toml`"}"#)
67+
.run();
68+
}

0 commit comments

Comments
 (0)