Skip to content

Commit 104ab6c

Browse files
committed
Make verify-project honour unstable features
1 parent b3d0b2e commit 104ab6c

File tree

2 files changed

+26
-17
lines changed

2 files changed

+26
-17
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/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)