Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: migrate dep_info/diagnostics/direct_minimal_versions to snapbox #14143

Merged
merged 3 commits into from
Jun 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 18 additions & 6 deletions tests/testsuite/dep_info.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
//! Tests for dep-info files. This includes the dep-info file Cargo creates in
//! the output directory, and the ones stored in the fingerprint.

#![allow(deprecated)]

use cargo_test_support::compare::assert_e2e;
use cargo_test_support::paths::{self, CargoPathExt};
use cargo_test_support::registry::Package;
Expand Down Expand Up @@ -323,7 +321,11 @@ fn relative_depinfo_paths_ws() {
p.cargo("build -Z binary-dep-depinfo --target")
.arg(&host)
.masquerade_as_nightly_cargo(&["binary-dep-depinfo"])
.with_stderr_contains("[COMPILING] foo [..]")
.with_stderr_data(str![[r#"
...
[COMPILING] foo v0.1.0 ([ROOT]/foo/foo)
...
"#]])
.run();

assert_deps_contains(
Expand Down Expand Up @@ -360,7 +362,10 @@ fn relative_depinfo_paths_ws() {
p.cargo("build -Z binary-dep-depinfo --target")
.arg(&host)
.masquerade_as_nightly_cargo(&["binary-dep-depinfo"])
.with_stderr("[FINISHED] `dev` profile [..]")
.with_stderr_data(str![[r#"
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s

"#]])
.run();
}

Expand Down Expand Up @@ -446,7 +451,11 @@ fn relative_depinfo_paths_no_ws() {

p.cargo("build -Z binary-dep-depinfo")
.masquerade_as_nightly_cargo(&["binary-dep-depinfo"])
.with_stderr_contains("[COMPILING] foo [..]")
.with_stderr_data(str![[r#"
...
[COMPILING] foo v0.1.0 ([ROOT]/foo)
...
"#]])
.run();

assert_deps_contains(
Expand Down Expand Up @@ -482,7 +491,10 @@ fn relative_depinfo_paths_no_ws() {
// Make sure it stays fresh.
p.cargo("build -Z binary-dep-depinfo")
.masquerade_as_nightly_cargo(&["binary-dep-depinfo"])
.with_stderr("[FINISHED] `dev` profile [..]")
.with_stderr_data(str![[r#"
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s

"#]])
.run();
}

Expand Down
12 changes: 5 additions & 7 deletions tests/testsuite/diagnostics.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#![allow(deprecated)]

use cargo_test_support::project;
use cargo_test_support::str;

#[cargo_test]
fn dont_panic_on_render() {
Expand All @@ -20,15 +19,14 @@ edition = "2021"

p.cargo("check")
.with_status(101)
.with_stderr(
"\
error: invalid type: map, expected a sequence
.with_stderr_data(str![[r#"
[ERROR] invalid type: map, expected a sequence
--> Cargo.toml:6:3
|
6 | [[bench.foo]]
| ^^^^^
|
",
)

"#]])
.run();
}
54 changes: 25 additions & 29 deletions tests/testsuite/direct_minimal_versions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@
//!
//! Note: Some tests are located in the resolver-tests package.

#![allow(deprecated)]

use cargo_test_support::project;
use cargo_test_support::registry::Package;
use cargo_test_support::str;

#[cargo_test]
fn simple() {
Expand All @@ -30,13 +29,12 @@ fn simple() {

p.cargo("generate-lockfile -Zdirect-minimal-versions")
.masquerade_as_nightly_cargo(&["direct-minimal-versions"])
.with_stderr(
"\
[UPDATING] [..]
.with_stderr_data(str![[r#"
[UPDATING] `dummy-registry` index
[LOCKING] 2 packages
[ADDING] dep v1.0.0 (latest: v1.1.0)
",
)

"#]])
.run();

let lock = p.read_lockfile();
Expand Down Expand Up @@ -79,20 +77,20 @@ fn mixed_dependencies() {
p.cargo("generate-lockfile -Zdirect-minimal-versions")
.masquerade_as_nightly_cargo(&["direct-minimal-versions"])
.with_status(101)
.with_stderr(
r#"[UPDATING] [..]
.with_stderr_data(str![[r#"
[UPDATING] `dummy-registry` index
[ERROR] failed to select a version for `dep`.
... required by package `foo v0.0.1 ([CWD])`
... required by package `foo v0.0.1 ([ROOT]/foo)`
versions that meet the requirements `^1.1` are: 1.1.0

all possible versions conflict with previously selected packages.

previously selected package `dep v1.0.0`
... which satisfies dependency `dep = "^1.0"` of package `foo v0.0.1 ([CWD])`
... which satisfies dependency `dep = "^1.0"` of package `foo v0.0.1 ([ROOT]/foo)`

failed to select a version for `dep` which could resolve this conflict
"#,
)

"#]])
.run();
}

Expand Down Expand Up @@ -120,13 +118,12 @@ fn yanked() {

p.cargo("generate-lockfile -Zdirect-minimal-versions")
.masquerade_as_nightly_cargo(&["direct-minimal-versions"])
.with_stderr(
"\
[UPDATING] [..]
.with_stderr_data(str![[r#"
[UPDATING] `dummy-registry` index
[LOCKING] 2 packages
[ADDING] dep v1.1.0 (latest: v1.2.0)
",
)

"#]])
.run();

let lock = p.read_lockfile();
Expand Down Expand Up @@ -175,13 +172,12 @@ fn indirect() {

p.cargo("generate-lockfile -Zdirect-minimal-versions")
.masquerade_as_nightly_cargo(&["direct-minimal-versions"])
.with_stderr(
"\
[UPDATING] [..]
.with_stderr_data(str![[r#"
[UPDATING] `dummy-registry` index
[LOCKING] 3 packages
[ADDING] direct v1.0.0 (latest: v1.1.0)
",
)

"#]])
.run();

let lock = p.read_lockfile();
Expand Down Expand Up @@ -240,20 +236,20 @@ fn indirect_conflict() {
p.cargo("generate-lockfile -Zdirect-minimal-versions")
.masquerade_as_nightly_cargo(&["direct-minimal-versions"])
.with_status(101)
.with_stderr(
r#"[UPDATING] [..]
.with_stderr_data(str![[r#"
[UPDATING] `dummy-registry` index
[ERROR] failed to select a version for `indirect`.
... required by package `direct v1.0.0`
... which satisfies dependency `direct = "^1.0"` of package `foo v0.0.1 ([CWD])`
... which satisfies dependency `direct = "^1.0"` of package `foo v0.0.1 ([ROOT]/foo)`
versions that meet the requirements `^2.1` are: 2.2.0, 2.1.0

all possible versions conflict with previously selected packages.

previously selected package `indirect v2.0.0`
... which satisfies dependency `indirect = "^2.0"` of package `foo v0.0.1 ([CWD])`
... which satisfies dependency `indirect = "^2.0"` of package `foo v0.0.1 ([ROOT]/foo)`

failed to select a version for `indirect` which could resolve this conflict
"#,
)

"#]])
.run();
}