Skip to content

Commit b099886

Browse files
lf-ehuss
authored andcommitted
Restore the tests that could be reused
1 parent 67abe0f commit b099886

File tree

3 files changed

+55
-0
lines changed

3 files changed

+55
-0
lines changed

src/cargo/ops/cargo_new.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,14 @@ impl NewOptions {
126126

127127
#[derive(Deserialize)]
128128
struct CargoNewConfig {
129+
#[deprecated = "cargo-new no longer supports adding the authors field"]
130+
#[allow(dead_code)]
131+
name: Option<String>,
132+
133+
#[deprecated = "cargo-new no longer supports adding the authors field"]
134+
#[allow(dead_code)]
135+
email: Option<String>,
136+
129137
#[serde(rename = "vcs")]
130138
version_control: Option<VersionControl>,
131139
}

tests/testsuite/bad_config.rs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,30 @@ Caused by:
8787
.run();
8888
}
8989

90+
#[cargo_test]
91+
fn bad4() {
92+
let p = project()
93+
.file(
94+
".cargo/config",
95+
r#"
96+
[cargo-new]
97+
vcs = false
98+
"#,
99+
)
100+
.build();
101+
p.cargo("new -v foo")
102+
.with_status(101)
103+
.with_stderr(
104+
"\
105+
[ERROR] Failed to create package `foo` at `[..]`
106+
107+
Caused by:
108+
error in [..]config: `cargo-new.vcs` expected a string, but found a boolean
109+
",
110+
)
111+
.run();
112+
}
113+
90114
#[cargo_test]
91115
fn bad6() {
92116
let p = project()

tests/testsuite/cargo_command.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,29 @@ fn displays_subcommand_on_error() {
245245
.run();
246246
}
247247

248+
#[cargo_test]
249+
fn override_cargo_home() {
250+
let root = paths::root();
251+
let my_home = root.join("my_home");
252+
fs::create_dir(&my_home).unwrap();
253+
fs::write(
254+
&my_home.join("config"),
255+
r#"
256+
[cargo-new]
257+
vcs = "none"
258+
"#,
259+
)
260+
.unwrap();
261+
262+
cargo_process("new foo").env("CARGO_HOME", &my_home).run();
263+
264+
assert!(!paths::root().join("foo/.git").is_dir());
265+
266+
cargo_process("new foo2").run();
267+
268+
assert!(paths::root().join("foo2/.git").is_dir());
269+
}
270+
248271
#[cargo_test]
249272
fn cargo_subcommand_env() {
250273
let src = format!(

0 commit comments

Comments
 (0)