Skip to content

Commit 5694e7c

Browse files
committed
Auto merge of #7695 - giraffate:add_and_update_tests_for_jobs_of_cargo_build, r=ehuss
Add and move tests for jobs of `cargo build` A test when argument is negative is added. In addition, `default_cargo_config_jobs` and `good_cargo_config_jobs` is moved from `testsuite/bad_config.rs` to `testsuite/build.rs` because these tests are not for `bad config`.
2 parents c8595e8 + 4956d3e commit 5694e7c

File tree

2 files changed

+37
-30
lines changed

2 files changed

+37
-30
lines changed

tests/testsuite/bad_config.rs

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -162,36 +162,6 @@ invalid value: integer `-1`, expected u32
162162
.run();
163163
}
164164

165-
#[cargo_test]
166-
fn default_cargo_config_jobs() {
167-
let p = project()
168-
.file("src/lib.rs", "")
169-
.file(
170-
".cargo/config",
171-
r#"
172-
[build]
173-
jobs = 1
174-
"#,
175-
)
176-
.build();
177-
p.cargo("build -v").run();
178-
}
179-
180-
#[cargo_test]
181-
fn good_cargo_config_jobs() {
182-
let p = project()
183-
.file("src/lib.rs", "")
184-
.file(
185-
".cargo/config",
186-
r#"
187-
[build]
188-
jobs = 4
189-
"#,
190-
)
191-
.build();
192-
p.cargo("build -v").run();
193-
}
194-
195165
#[cargo_test]
196166
fn invalid_global_config() {
197167
let p = project()

tests/testsuite/build.rs

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4297,13 +4297,50 @@ required by package `bar v0.1.0 ([..]/foo)`
42974297
.run();
42984298
}
42994299

4300+
#[cargo_test]
4301+
fn default_cargo_config_jobs() {
4302+
let p = project()
4303+
.file("src/lib.rs", "")
4304+
.file(
4305+
".cargo/config",
4306+
r#"
4307+
[build]
4308+
jobs = 1
4309+
"#,
4310+
)
4311+
.build();
4312+
p.cargo("build -v").run();
4313+
}
4314+
4315+
#[cargo_test]
4316+
fn good_cargo_config_jobs() {
4317+
let p = project()
4318+
.file("src/lib.rs", "")
4319+
.file(
4320+
".cargo/config",
4321+
r#"
4322+
[build]
4323+
jobs = 4
4324+
"#,
4325+
)
4326+
.build();
4327+
p.cargo("build -v").run();
4328+
}
4329+
43004330
#[cargo_test]
43014331
fn invalid_jobs() {
43024332
let p = project()
43034333
.file("Cargo.toml", &basic_bin_manifest("foo"))
43044334
.file("src/foo.rs", &main_file(r#""i am foo""#, &[]))
43054335
.build();
43064336

4337+
p.cargo("build --jobs -1")
4338+
.with_status(1)
4339+
.with_stderr_contains(
4340+
"error: Found argument '-1' which wasn't expected, or isn't valid in this context",
4341+
)
4342+
.run();
4343+
43074344
p.cargo("build --jobs over9000")
43084345
.with_status(1)
43094346
.with_stderr("error: Invalid value: could not parse `over9000` as a number")

0 commit comments

Comments
 (0)