Skip to content

Commit 0feff3d

Browse files
committed
Auto merge of #14079 - dieterplex:snapboxport4co, r=weihanglo
test: Migrate tests/testsuite/co*.rs to snapbox Migrating files: - tests/testsuite/collisions.rs - `with_stderr_does_not_contain` in test `collision_doc_host_target_feature_split` - tests/testsuite/concurrent.rs - tests/testsuite/config.rs - tests/testsuite/config_cli.rs - tests/testsuite/config_include.rs - tests/testsuite/corrupt_git.rs Testing with command `SNAPSHOTS=overwrite cargo test collisions::` or so. Part of #14039
2 parents 6a43035 + bd451d0 commit 0feff3d

File tree

6 files changed

+127
-116
lines changed

6 files changed

+127
-116
lines changed

tests/testsuite/collisions.rs

Lines changed: 98 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
//! Ideally these should never happen, but I don't think we'll ever be able to
44
//! prevent all collisions.
55
6-
#![allow(deprecated)]
7-
6+
use cargo_test_support::prelude::*;
87
use cargo_test_support::registry::Package;
8+
use cargo_test_support::str;
99
use cargo_test_support::{basic_manifest, cross_compile, project};
1010
use std::env;
1111

@@ -52,13 +52,15 @@ fn collision_dylib() {
5252
// `j=1` is required because on Windows you'll get an error due to
5353
// two processes writing to the file at the same time.
5454
p.cargo("build -j=1")
55-
.with_stderr_contains(&format!("\
55+
.with_stderr_data(&format!("\
56+
...
5657
[WARNING] output filename collision.
57-
The lib target `a` in package `b v1.0.0 ([..]/foo/b)` has the same output filename as the lib target `a` in package `a v1.0.0 ([..]/foo/a)`.
58-
Colliding filename is: [..]/foo/target/debug/deps/{}a{}
58+
The lib target `a` in package `b v1.0.0 ([ROOT]/foo/b)` has the same output filename as the lib target `a` in package `a v1.0.0 ([ROOT]/foo/a)`.
59+
Colliding filename is: [ROOT]/foo/target/debug/deps/{}a{}
5960
The targets should have unique names.
6061
Consider changing their names to be unique or compiling them separately.
6162
This may become a hard error in the future; see <https://github.com/rust-lang/cargo/issues/6313>.
63+
...
6264
", env::consts::DLL_PREFIX, env::consts::DLL_SUFFIX))
6365
.run();
6466
}
@@ -83,14 +85,17 @@ fn collision_example() {
8385
// `j=1` is required because on Windows you'll get an error due to
8486
// two processes writing to the file at the same time.
8587
p.cargo("build --examples -j=1")
86-
.with_stderr_contains("\
88+
.with_stderr_data(str![[r#"
89+
...
8790
[WARNING] output filename collision.
88-
The example target `ex1` in package `b v1.0.0 ([..]/foo/b)` has the same output filename as the example target `ex1` in package `a v1.0.0 ([..]/foo/a)`.
89-
Colliding filename is: [..]/foo/target/debug/examples/ex1[EXE]
91+
The example target `ex1` in package `b v1.0.0 ([ROOT]/foo/b)` has the same output filename as the example target `ex1` in package `a v1.0.0 ([ROOT]/foo/a)`.
92+
Colliding filename is: [ROOT]/foo/target/debug/examples/ex1[EXE]
9093
The targets should have unique names.
9194
Consider changing their names to be unique or compiling them separately.
9295
This may become a hard error in the future; see <https://github.com/rust-lang/cargo/issues/6313>.
93-
")
96+
...
97+
98+
"#]])
9499
.run();
95100
}
96101

@@ -112,14 +117,16 @@ fn collision_export() {
112117
// same time.
113118
p.cargo("build -j1 --artifact-dir=out -Z unstable-options --bins --examples")
114119
.masquerade_as_nightly_cargo(&["artifact-dir"])
115-
.with_stderr_contains("\
120+
.with_stderr_data(str![[r#"
116121
[WARNING] `--artifact-dir` filename collision.
117-
The example target `foo` in package `foo v1.0.0 ([..]/foo)` has the same output filename as the bin target `foo` in package `foo v1.0.0 ([..]/foo)`.
118-
Colliding filename is: [..]/foo/out/foo[EXE]
122+
The example target `foo` in package `foo v1.0.0 ([ROOT]/foo)` has the same output filename as the bin target `foo` in package `foo v1.0.0 ([ROOT]/foo)`.
123+
Colliding filename is: [ROOT]/foo/out/foo[EXE]
119124
The exported filenames should be unique.
120125
Consider changing their names to be unique or compiling them separately.
121126
This may become a hard error in the future; see <https://github.com/rust-lang/cargo/issues/6313>.
122-
")
127+
...
128+
129+
"#]])
123130
.run();
124131
}
125132

@@ -155,17 +162,17 @@ fn collision_doc() {
155162
.build();
156163

157164
p.cargo("doc -j=1")
158-
.with_stderr_contains(
159-
"\
165+
.with_stderr_data(str![[r#"
166+
...
160167
[WARNING] output filename collision.
161-
The lib target `foo` in package `foo2 v0.1.0 ([..]/foo/foo2)` has the same output \
162-
filename as the lib target `foo` in package `foo v0.1.0 ([..]/foo)`.
163-
Colliding filename is: [..]/foo/target/doc/foo/index.html
168+
The lib target `foo` in package `foo2 v0.1.0 ([ROOT]/foo/foo2)` has the same output filename as the lib target `foo` in package `foo v0.1.0 ([ROOT]/foo)`.
169+
Colliding filename is: [ROOT]/foo/target/doc/foo/index.html
164170
The targets should have unique names.
165171
This is a known bug where multiple crates with the same name use
166172
the same path; see <https://github.com/rust-lang/cargo/issues/6313>.
167-
",
168-
)
173+
...
174+
175+
"#]])
169176
.run();
170177
}
171178

@@ -196,27 +203,30 @@ fn collision_doc_multiple_versions() {
196203

197204
// Should only document bar 2.0, should not document old-dep.
198205
p.cargo("doc")
199-
.with_stderr_unordered(
200-
"\
201-
[UPDATING] [..]
206+
.with_stderr_data(
207+
str![[r#"
208+
[UPDATING] `dummy-registry` index
202209
[LOCKING] 4 packages to latest compatible versions
203210
[ADDING] bar v1.0.0 (latest: v2.0.0)
204211
[DOWNLOADING] crates ...
205-
[DOWNLOADED] bar v2.0.0 [..]
206-
[DOWNLOADED] bar v1.0.0 [..]
207-
[DOWNLOADED] old-dep v1.0.0 [..]
212+
[DOWNLOADED] bar v2.0.0 (registry `dummy-registry`)
213+
[DOWNLOADED] bar v1.0.0 (registry `dummy-registry`)
214+
[DOWNLOADED] old-dep v1.0.0 (registry `dummy-registry`)
208215
[CHECKING] old-dep v1.0.0
209216
[CHECKING] bar v2.0.0
210217
[CHECKING] bar v1.0.0
211218
[DOCUMENTING] bar v2.0.0
212-
[FINISHED] [..]
213-
[DOCUMENTING] foo v0.1.0 [..]
214-
[GENERATED] [CWD]/target/doc/foo/index.html
215-
",
219+
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
220+
[DOCUMENTING] foo v0.1.0 ([ROOT]/foo)
221+
[GENERATED] [ROOT]/foo/target/doc/foo/index.html
222+
223+
"#]]
224+
.unordered(),
216225
)
217226
.run();
218227
}
219228

229+
#[allow(deprecated)]
220230
#[cargo_test]
221231
fn collision_doc_host_target_feature_split() {
222232
// Same dependency built twice due to different features.
@@ -371,35 +381,39 @@ fn collision_doc_profile_split() {
371381
// This is unordered because in rare cases `pm` may start
372382
// building in-between the two `common`.
373383
p.cargo("build -v")
374-
.with_stderr_unordered(
375-
"\
376-
[UPDATING] [..]
384+
.with_stderr_data(
385+
str![[r#"
386+
[UPDATING] `dummy-registry` index
377387
[LOCKING] 3 packages to latest compatible versions
378388
[DOWNLOADING] crates ...
379-
[DOWNLOADED] common v1.0.0 [..]
389+
[DOWNLOADED] common v1.0.0 (registry `dummy-registry`)
380390
[COMPILING] common v1.0.0
381391
[RUNNING] `rustc --crate-name common [..]
382392
[RUNNING] `rustc --crate-name common [..]
383-
[COMPILING] pm v0.1.0 [..]
393+
[COMPILING] pm v0.1.0 ([ROOT]/foo/pm)
384394
[RUNNING] `rustc --crate-name pm [..]
385-
[COMPILING] foo v0.1.0 [..]
395+
[COMPILING] foo v0.1.0 ([ROOT]/foo)
386396
[RUNNING] `rustc --crate-name foo [..]
387-
[FINISHED] [..]
388-
",
397+
[FINISHED] `dev` profile [optimized + debuginfo] target(s) in [ELAPSED]s
398+
399+
"#]]
400+
.unordered(),
389401
)
390402
.run();
391403

392404
// Should only document common once, no warnings.
393405
p.cargo("doc")
394-
.with_stderr_unordered(
395-
"\
406+
.with_stderr_data(
407+
str![[r#"
396408
[CHECKING] common v1.0.0
397409
[DOCUMENTING] common v1.0.0
398-
[DOCUMENTING] pm v0.1.0 [..]
399-
[DOCUMENTING] foo v0.1.0 [..]
400-
[FINISHED] [..]
401-
[GENERATED] [CWD]/target/doc/foo/index.html
402-
",
410+
[DOCUMENTING] pm v0.1.0 ([ROOT]/foo/pm)
411+
[DOCUMENTING] foo v0.1.0 ([ROOT]/foo)
412+
[FINISHED] `dev` profile [optimized + debuginfo] target(s) in [ELAPSED]s
413+
[GENERATED] [ROOT]/foo/target/doc/foo/index.html
414+
415+
"#]]
416+
.unordered(),
403417
)
404418
.run();
405419
}
@@ -428,27 +442,28 @@ fn collision_doc_sources() {
428442
.build();
429443

430444
p.cargo("doc -j=1")
431-
.with_stderr_unordered(
432-
"\
433-
[UPDATING] [..]
445+
.with_stderr_data(
446+
str![[r#"
447+
[UPDATING] `dummy-registry` index
434448
[LOCKING] 3 packages to latest compatible versions
435449
[DOWNLOADING] crates ...
436-
[DOWNLOADED] bar v1.0.0 [..]
450+
[DOWNLOADED] bar v1.0.0 (registry `dummy-registry`)
437451
[WARNING] output filename collision.
438-
The lib target `bar` in package `bar v1.0.0` has the same output filename as \
439-
the lib target `bar` in package `bar v1.0.0 ([..]/foo/bar)`.
440-
Colliding filename is: [..]/foo/target/doc/bar/index.html
452+
The lib target `bar` in package `bar v1.0.0` has the same output filename as the lib target `bar` in package `bar v1.0.0 ([ROOT]/foo/bar)`.
453+
Colliding filename is: [ROOT]/foo/target/doc/bar/index.html
441454
The targets should have unique names.
442455
This is a known bug where multiple crates with the same name use
443456
the same path; see <https://github.com/rust-lang/cargo/issues/6313>.
444-
[CHECKING] bar v1.0.0 [..]
445-
[DOCUMENTING] bar v1.0.0 [..]
457+
[CHECKING] bar v1.0.0 ([ROOT]/foo/bar)
458+
[DOCUMENTING] bar v1.0.0 ([ROOT]/foo/bar)
446459
[DOCUMENTING] bar v1.0.0
447460
[CHECKING] bar v1.0.0
448-
[DOCUMENTING] foo v0.1.0 [..]
449-
[FINISHED] [..]
450-
[GENERATED] [CWD]/target/doc/foo/index.html
451-
",
461+
[DOCUMENTING] foo v0.1.0 ([ROOT]/foo)
462+
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
463+
[GENERATED] [ROOT]/foo/target/doc/foo/index.html
464+
465+
"#]]
466+
.unordered(),
452467
)
453468
.run();
454469
}
@@ -484,23 +499,25 @@ fn collision_doc_target() {
484499

485500
p.cargo("doc --target")
486501
.arg(cross_compile::alternate())
487-
.with_stderr_unordered(
488-
"\
489-
[UPDATING] [..]
502+
.with_stderr_data(
503+
str![[r#"
504+
[UPDATING] `dummy-registry` index
490505
[LOCKING] 4 packages to latest compatible versions
491506
[ADDING] bar v1.0.0 (latest: v2.0.0)
492507
[DOWNLOADING] crates ...
493-
[DOWNLOADED] orphaned v1.0.0 [..]
494-
[DOWNLOADED] bar v2.0.0 [..]
495-
[DOWNLOADED] bar v1.0.0 [..]
508+
[DOWNLOADED] orphaned v1.0.0 (registry `dummy-registry`)
509+
[DOWNLOADED] bar v2.0.0 (registry `dummy-registry`)
510+
[DOWNLOADED] bar v1.0.0 (registry `dummy-registry`)
496511
[CHECKING] orphaned v1.0.0
497512
[DOCUMENTING] bar v2.0.0
498513
[CHECKING] bar v2.0.0
499514
[CHECKING] bar v1.0.0
500-
[DOCUMENTING] foo v0.1.0 [..]
501-
[FINISHED] [..]
502-
[GENERATED] [CWD]/target/[..]/doc/foo/index.html
503-
",
515+
[DOCUMENTING] foo v0.1.0 ([ROOT]/foo)
516+
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
517+
[GENERATED] [ROOT]/foo/target/[ALT_TARGET]/doc/foo/index.html
518+
519+
"#]]
520+
.unordered(),
504521
)
505522
.run();
506523
}
@@ -553,24 +570,25 @@ fn collision_with_root() {
553570
.build();
554571

555572
p.cargo("doc -j=1")
556-
.with_stderr_unordered("\
557-
[UPDATING] [..]
573+
.with_stderr_data(str![[r#"
574+
[UPDATING] `dummy-registry` index
558575
[LOCKING] 3 packages to latest compatible versions
559576
[DOWNLOADING] crates ...
560-
[DOWNLOADED] foo-macro v1.0.0 [..]
561-
warning: output filename collision.
562-
The lib target `foo_macro` in package `foo-macro v1.0.0` has the same output filename as the lib target `foo_macro` in package `foo-macro v1.0.0 [..]`.
563-
Colliding filename is: [CWD]/target/doc/foo_macro/index.html
577+
[DOWNLOADED] foo-macro v1.0.0 (registry `dummy-registry`)
578+
[WARNING] output filename collision.
579+
The lib target `foo_macro` in package `foo-macro v1.0.0` has the same output filename as the lib target `foo_macro` in package `foo-macro v1.0.0 ([ROOT]/foo/foo-macro)`.
580+
Colliding filename is: [ROOT]/foo/target/doc/foo_macro/index.html
564581
The targets should have unique names.
565582
This is a known bug where multiple crates with the same name use
566583
the same path; see <https://github.com/rust-lang/cargo/issues/6313>.
567584
[CHECKING] foo-macro v1.0.0
568585
[DOCUMENTING] foo-macro v1.0.0
569-
[CHECKING] abc v1.0.0 [..]
570-
[DOCUMENTING] foo-macro v1.0.0 [..]
571-
[DOCUMENTING] abc v1.0.0 [..]
572-
[FINISHED] [..]
573-
[GENERATED] [CWD]/target/doc/abc/index.html and 1 other file
574-
")
586+
[CHECKING] abc v1.0.0 ([ROOT]/foo/abc)
587+
[DOCUMENTING] foo-macro v1.0.0 ([ROOT]/foo/foo-macro)
588+
[DOCUMENTING] abc v1.0.0 ([ROOT]/foo/abc)
589+
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
590+
[GENERATED] [ROOT]/foo/target/doc/abc/index.html and 1 other file
591+
592+
"#]].unordered())
575593
.run();
576594
}

tests/testsuite/concurrent.rs

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
//! Tests for running multiple `cargo` processes at the same time.
22
3-
#![allow(deprecated)]
4-
53
use std::fs;
64
use std::net::TcpListener;
75
use std::process::Stdio;
@@ -13,6 +11,7 @@ use cargo_test_support::cargo_process;
1311
use cargo_test_support::git;
1412
use cargo_test_support::install::{assert_has_installed_exe, cargo_home};
1513
use cargo_test_support::registry::Package;
14+
use cargo_test_support::str;
1615
use cargo_test_support::{basic_manifest, execs, project, slow_cpu_multiplier};
1716

1817
fn pkg(name: &str, vers: &str) {
@@ -433,20 +432,20 @@ fn debug_release_ok() {
433432
let a = a.join().unwrap();
434433

435434
execs()
436-
.with_stderr_contains(
437-
"\
438-
[COMPILING] foo v0.0.1 [..]
439-
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..]
440-
",
441-
)
435+
.with_stderr_data(str![[r#"
436+
...
437+
[COMPILING] foo v0.0.1 ([ROOT]/foo)
438+
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
439+
440+
"#]])
442441
.run_output(&a);
443442
execs()
444-
.with_stderr_contains(
445-
"\
446-
[COMPILING] foo v0.0.1 [..]
447-
[FINISHED] `release` profile [optimized] target(s) in [..]
448-
",
449-
)
443+
.with_stderr_data(str![[r#"
444+
...
445+
[COMPILING] foo v0.0.1 ([ROOT]/foo)
446+
[FINISHED] `release` profile [optimized] target(s) in [ELAPSED]s
447+
448+
"#]])
450449
.run_output(&b);
451450
}
452451

tests/testsuite/config.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
//! Tests for config settings.
22
3-
#![allow(deprecated)]
4-
53
use cargo::core::features::{GitFeatures, GitoxideFeatures};
64
use cargo::core::{PackageIdSpec, Shell};
75
use cargo::util::context::{
@@ -1616,7 +1614,10 @@ fn cargo_target_empty_env() {
16161614

16171615
project.cargo("check")
16181616
.env("CARGO_TARGET_DIR", "")
1619-
.with_stderr("error: the target directory is set to an empty string in the `CARGO_TARGET_DIR` environment variable")
1617+
.with_stderr_data(str![[r#"
1618+
[ERROR] the target directory is set to an empty string in the `CARGO_TARGET_DIR` environment variable
1619+
1620+
"#]])
16201621
.with_status(101)
16211622
.run()
16221623
}

tests/testsuite/config_cli.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
//! Tests for the --config CLI option.
22
3-
#![allow(deprecated)]
4-
53
use super::config::{
64
assert_error, read_output, write_config_at, write_config_toml, GlobalContextBuilder,
75
};

0 commit comments

Comments
 (0)