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 edition/error to snapbox #14175

Merged
merged 2 commits into from
Jul 2, 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
62 changes: 26 additions & 36 deletions tests/testsuite/edition.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
//! Tests for edition setting.

#![allow(deprecated)]

use cargo::core::Edition;
use cargo_test_support::{basic_lib_manifest, project};
use cargo_test_support::{basic_lib_manifest, project, str};

#[cargo_test]
fn edition_works_for_build_script() {
Expand Down Expand Up @@ -66,21 +64,17 @@ fn edition_unstable_gated() {

p.cargo("check")
.with_status(101)
.with_stderr(&format!(
.with_stderr_data(format!(
"\
[ERROR] failed to parse manifest at `[..]/foo/Cargo.toml`
[ERROR] failed to parse manifest at `[ROOT]/foo/Cargo.toml`

Caused by:
feature `edition{next}` is required

The package requires the Cargo feature called `edition{next}`, \
but that feature is not stabilized in this version of Cargo (1.[..]).
The package requires the Cargo feature called `edition{next}`, but that feature is not stabilized in this version of Cargo (1.[..]).
Consider trying a newer version of Cargo (this may require the nightly release).
See https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#edition-{next} \
for more information about the status of this feature.
",
next = next
))
See https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#edition-{next} for more information about the status of this feature.
"))
.run();
}

Expand Down Expand Up @@ -116,12 +110,11 @@ fn edition_unstable() {

p.cargo("check")
.masquerade_as_nightly_cargo(&["always_nightly"])
.with_stderr(
"\
[CHECKING] foo [..]
[FINISHED] [..]
",
)
.with_stderr_data(str![[r#"
[CHECKING] foo v0.1.0 ([ROOT]/foo)
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s

"#]])
.run();
}

Expand All @@ -140,14 +133,13 @@ fn unset_edition_with_unset_rust_version() {
.build();

p.cargo("check -v")
.with_stderr(
"\
.with_stderr_data(str![[r#"
[WARNING] no edition set: defaulting to the 2015 edition while the latest is 2021
[CHECKING] foo [..]
[CHECKING] foo v0.1.0 ([ROOT]/foo)
[RUNNING] `rustc [..] --edition=2015 [..]`
[FINISHED] [..]
",
)
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s

"#]])
.run();
}

Expand All @@ -167,13 +159,12 @@ fn unset_edition_works_with_no_newer_compatible_edition() {
.build();

p.cargo("check -v")
.with_stderr(
"\
[CHECKING] foo [..]
.with_stderr_data(str![[r#"
[CHECKING] foo v0.1.0 ([ROOT]/foo)
[RUNNING] `rustc [..] --edition=2015 [..]`
[FINISHED] [..]
",
)
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s

"#]])
.run();
}

Expand All @@ -193,13 +184,12 @@ fn unset_edition_works_on_old_msrv() {
.build();

p.cargo("check -v")
.with_stderr(
"\
.with_stderr_data(str![[r#"
[WARNING] no edition set: defaulting to the 2015 edition while 2018 is compatible with `rust-version`
[CHECKING] foo [..]
[CHECKING] foo v0.1.0 ([ROOT]/foo)
[RUNNING] `rustc [..] --edition=2015 [..]`
[FINISHED] [..]
",
)
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s

"#]])
.run();
}
9 changes: 4 additions & 5 deletions tests/testsuite/error.rs
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
//! General error tests that don't belong anywhere else.

#![allow(deprecated)]

use cargo_test_support::cargo_process;

#[cargo_test]
fn internal_error() {
cargo_process("init")
.env("__CARGO_TEST_INTERNAL_ERROR", "1")
.with_status(101)
.with_stderr(
.with_stderr_data(format!(
"\
[ERROR] internal error test
[NOTE] this is an unexpected cargo internal error
[NOTE] we would appreciate a bug report: https://github.com/rust-lang/cargo/issues/
[NOTE] cargo [..]
[NOTE] cargo {}
",
)
cargo::version()
))
.run();
}