Compare commits

...

7 Commits

Author SHA1 Message Date
eth3lbert
1c269381e8
Merge 7d1b785f3e into 9441b91186 2024-06-28 15:48:14 +02:00
bors
9441b91186 Auto merge of #14159 - dieterplex:migrate-git-snapbox, r=weihanglo
test: Migrate git to snapbox

Part of #14039.

There is a case need to modify regex for file size redaction.
2024-06-28 13:05:10 +00:00
d1t2
32cdb261ef
test: Migrate git to snapbox 2024-06-28 17:39:24 +08:00
eth3lbert
7d1b785f3e
test: migrate net_config to snapbox 2024-06-28 06:35:30 +08:00
eth3lbert
08158b4b9d
test: migrate metadata to snapbox 2024-06-28 06:35:30 +08:00
eth3lbert
641cbee769
test: migrate metabuild to snapbox 2024-06-28 06:35:30 +08:00
d1t2
ed027736e7
test: Allow redact file size w/o fraction
`cargo clean` shows file size without fraction in summary when the size
is lower than 1024. And we need to avoid matching things like `%2B%23..`
found in other test cases, the trailing `\s` is added to regex.
2024-06-27 16:58:52 +08:00
5 changed files with 3941 additions and 3563 deletions

View File

@ -171,7 +171,7 @@ fn add_common_redactions(subs: &mut snapbox::Redactions) {
.unwrap();
subs.insert(
"[FILE_SIZE]",
regex!(r"(?<redacted>[0-9]+(\.[0-9]+)([a-zA-Z]i)?)B"),
regex!(r"(?<redacted>[0-9]+(\.[0-9]+)?([a-zA-Z]i)?)B\s"),
)
.unwrap();
subs.insert(

File diff suppressed because it is too large Load Diff

View File

@ -1,10 +1,9 @@
//! Tests for the metabuild feature (declarative build scripts).
#![allow(deprecated)]
use cargo_test_support::prelude::*;
use cargo_test_support::{
basic_lib_manifest, basic_manifest, is_coarse_mtime, project, registry::Package, rustc_host,
Project,
str, Project,
};
use std::str;
@ -28,21 +27,17 @@ fn metabuild_gated() {
p.cargo("check")
.masquerade_as_nightly_cargo(&["metabuild"])
.with_status(101)
.with_stderr(
"\
error: failed to parse manifest at `[..]`
.with_stderr_data(str![[r#"
[ERROR] failed to parse manifest at `[ROOT]/foo/Cargo.toml`
Caused by:
feature `metabuild` is required
The package requires the Cargo feature called `metabuild`, \
but that feature is not stabilized in this version of Cargo (1.[..]).
Consider adding `cargo-features = [\"metabuild\"]` to the top of Cargo.toml \
(above the [package] table) to tell Cargo you are opting in to use this unstable feature.
See https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#metabuild \
for more information about the status of this feature.
",
)
The package requires the Cargo feature called `metabuild`, but that feature is not stabilized in this version of Cargo ([..]).
Consider adding `cargo-features = ["metabuild"]` to the top of Cargo.toml (above the [package] table) to tell Cargo you are opting in to use this unstable feature.
See https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#metabuild for more information about the status of this feature.
"#]])
.run();
}
@ -90,8 +85,11 @@ fn metabuild_basic() {
let p = basic_project();
p.cargo("check -vv")
.masquerade_as_nightly_cargo(&["metabuild"])
.with_stdout_contains("[foo 0.0.1] Hello mb")
.with_stdout_contains("[foo 0.0.1] Hello mb-other")
.with_stdout_data(str![[r#"
[foo 0.0.1] Hello mb
[foo 0.0.1] Hello mb-other
"#]])
.run();
}
@ -124,14 +122,13 @@ fn metabuild_error_both() {
p.cargo("check -vv")
.masquerade_as_nightly_cargo(&["metabuild"])
.with_status(101)
.with_stderr_contains(
"\
error: failed to parse manifest at [..]
.with_stderr_data(str![[r#"
[ERROR] failed to parse manifest at `[ROOT]/foo/Cargo.toml`
Caused by:
cannot specify both `metabuild` and `build`
",
)
"#]])
.run();
}
@ -155,16 +152,17 @@ fn metabuild_missing_dep() {
p.cargo("check -vv")
.masquerade_as_nightly_cargo(&["metabuild"])
.with_status(101)
.with_stderr_contains(
"\
error: failed to parse manifest at [..]
.with_stderr_data(str![[r#"
[ERROR] failed to parse manifest at `[ROOT]/foo/Cargo.toml`
Caused by:
metabuild package `mb` must be specified in `build-dependencies`",
)
metabuild package `mb` must be specified in `build-dependencies`
"#]])
.run();
}
#[allow(deprecated)]
#[cargo_test]
fn metabuild_optional_dep() {
let p = project()
@ -239,10 +237,14 @@ fn metabuild_lib_name() {
p.cargo("check -vv")
.masquerade_as_nightly_cargo(&["metabuild"])
.with_stdout_contains("[foo 0.0.1] Hello mb")
.with_stdout_data(str![[r#"
[foo 0.0.1] Hello mb
"#]])
.run();
}
#[allow(deprecated)]
#[cargo_test]
fn metabuild_fresh() {
if is_coarse_mtime() {
@ -285,13 +287,12 @@ fn metabuild_fresh() {
p.cargo("check -vv")
.masquerade_as_nightly_cargo(&["metabuild"])
.with_stdout_does_not_contain("[foo 0.0.1] Hello mb")
.with_stderr(
"\
[FRESH] mb [..]
[FRESH] foo [..]
[FINISHED] `dev` profile [..]
",
)
.with_stderr_data(str![[r#"
[FRESH] mb v0.5.0 ([ROOT]/foo/mb)
[FRESH] foo v0.0.1 ([ROOT]/foo)
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
"#]])
.run();
}
@ -329,7 +330,10 @@ fn metabuild_links() {
p.cargo("check -vv")
.masquerade_as_nightly_cargo(&["metabuild"])
.with_stdout_contains("[foo 0.0.1] Hello mb")
.with_stdout_data(str![[r#"
[foo 0.0.1] Hello mb
"#]])
.run();
}
@ -374,6 +378,7 @@ fn metabuild_override() {
.run();
}
#[allow(deprecated)]
#[cargo_test]
fn metabuild_workspace() {
let p = project()
@ -473,97 +478,115 @@ fn metabuild_build_plan() {
p.cargo("build --build-plan -Zunstable-options")
.masquerade_as_nightly_cargo(&["metabuild", "build-plan"])
.with_json(
r#"
{
"invocations": [
{
"package_name": "mb",
"package_version": "0.5.0",
"target_kind": ["lib"],
"compile_mode": "build",
"kind": null,
"deps": [],
"outputs": [
"[..]/target/debug/deps/libmb-[..].rlib",
"[..]/target/debug/deps/libmb-[..].rmeta"
],
"links": {},
"program": "rustc",
"args": "{...}",
"env": "{...}",
"cwd": "[..]"
},
{
"package_name": "mb-other",
"package_version": "0.0.1",
"target_kind": ["lib"],
"compile_mode": "build",
"kind": null,
"deps": [],
"outputs": [
"[..]/target/debug/deps/libmb_other-[..].rlib",
"[..]/target/debug/deps/libmb_other-[..].rmeta"
],
"links": {},
"program": "rustc",
"args": "{...}",
"env": "{...}",
"cwd": "[..]"
},
{
"package_name": "foo",
"package_version": "0.0.1",
"target_kind": ["custom-build"],
"compile_mode": "build",
"kind": null,
"deps": [0, 1],
"outputs": "{...}",
"links": "{...}",
"program": "rustc",
"args": "{...}",
"env": "{...}",
"cwd": "[..]"
},
{
"package_name": "foo",
"package_version": "0.0.1",
"target_kind": ["custom-build"],
"compile_mode": "run-custom-build",
"kind": null,
"deps": [2],
"outputs": [],
"links": {},
"program": "[..]/foo/target/debug/build/foo-[..]/metabuild-foo",
"args": [],
"env": "{...}",
"cwd": "[..]"
},
{
"package_name": "foo",
"package_version": "0.0.1",
"target_kind": ["lib"],
"compile_mode": "build",
"kind": null,
"deps": [3],
"outputs": [
"[..]/foo/target/debug/deps/libfoo-[..].rlib",
"[..]/foo/target/debug/deps/libfoo-[..].rmeta"
],
"links": "{...}",
"program": "rustc",
"args": "{...}",
"env": "{...}",
"cwd": "[..]"
}
],
"inputs": [
"[..]/foo/Cargo.toml",
"[..]/foo/mb/Cargo.toml",
"[..]/foo/mb-other/Cargo.toml"
]
}
"#,
.with_stdout_data(
str![[r#"
{
"inputs": [
"[ROOT]/foo/Cargo.toml",
"[ROOT]/foo/mb/Cargo.toml",
"[ROOT]/foo/mb-other/Cargo.toml"
],
"invocations": [
{
"args": "{...}",
"compile_mode": "build",
"cwd": "[ROOT]/foo",
"deps": [],
"env": "{...}",
"kind": null,
"links": {},
"outputs": [
"[ROOT]/foo/target/debug/deps/libmb-[HASH].rlib",
"[ROOT]/foo/target/debug/deps/libmb-[HASH].rmeta"
],
"package_name": "mb",
"package_version": "0.5.0",
"program": "rustc",
"target_kind": [
"lib"
]
},
{
"args": "{...}",
"compile_mode": "build",
"cwd": "[ROOT]/foo",
"deps": [],
"env": "{...}",
"kind": null,
"links": {},
"outputs": [
"[ROOT]/foo/target/debug/deps/libmb_other-[HASH].rlib",
"[ROOT]/foo/target/debug/deps/libmb_other-[HASH].rmeta"
],
"package_name": "mb-other",
"package_version": "0.0.1",
"program": "rustc",
"target_kind": [
"lib"
]
},
{
"args": "{...}",
"compile_mode": "build",
"cwd": "[ROOT]/foo",
"deps": [
0,
1
],
"env": "{...}",
"kind": null,
"links": "{...}",
"outputs": "{...}",
"package_name": "foo",
"package_version": "0.0.1",
"program": "rustc",
"target_kind": [
"custom-build"
]
},
{
"args": "{...}",
"compile_mode": "run-custom-build",
"cwd": "[ROOT]/foo",
"deps": [
2
],
"env": "{...}",
"kind": null,
"links": {},
"outputs": [],
"package_name": "foo",
"package_version": "0.0.1",
"program": "[ROOT]/foo/target/debug/build/foo-[HASH]/metabuild-foo",
"target_kind": [
"custom-build"
]
},
{
"args": "{...}",
"compile_mode": "build",
"cwd": "[ROOT]/foo",
"deps": [
3
],
"env": "{...}",
"kind": null,
"links": "{...}",
"outputs": [
"[ROOT]/foo/target/debug/deps/libfoo-[HASH].rlib",
"[ROOT]/foo/target/debug/deps/libfoo-[HASH].rmeta"
],
"package_name": "foo",
"package_version": "0.0.1",
"program": "rustc",
"target_kind": [
"lib"
]
}
]
}
"#]]
.json(),
)
.run();
@ -642,8 +665,14 @@ fn metabuild_two_versions() {
p.cargo("check -vv --workspace")
.masquerade_as_nightly_cargo(&["metabuild"])
.with_stdout_contains("[member1 0.0.1] Hello mb1 [..]member1")
.with_stdout_contains("[member2 0.0.1] Hello mb2 [..]member2")
.with_stdout_data(
str![[r#"
[member2 0.0.1] Hello mb2 [ROOT]/ws/member2
[member1 0.0.1] Hello mb1 [ROOT]/ws/member1
"#]]
.unordered(),
)
.run();
assert_eq!(
@ -697,12 +726,16 @@ fn metabuild_external_dependency() {
p.cargo("check -vv")
.masquerade_as_nightly_cargo(&["metabuild"])
.with_stdout_contains("[dep 1.0.0] Hello mb")
.with_stdout_data(str![[r#"
[dep 1.0.0] Hello mb
"#]])
.run();
assert_eq!(p.glob("target/.metabuild/metabuild-dep-*.rs").count(), 1);
}
#[allow(deprecated)]
#[cargo_test]
fn metabuild_json_artifact() {
let p = basic_project();
@ -749,6 +782,7 @@ fn metabuild_json_artifact() {
.run();
}
#[allow(deprecated)]
#[cargo_test]
fn metabuild_failed_build_json() {
let p = basic_project();

File diff suppressed because it is too large Load Diff

View File

@ -1,8 +1,7 @@
//! Tests for network configuration.
#![allow(deprecated)]
use cargo_test_support::project;
use cargo_test_support::str;
#[cargo_test]
fn net_retry_loads_from_config() {
@ -33,10 +32,11 @@ fn net_retry_loads_from_config() {
p.cargo("check -v")
.with_status(101)
.with_stderr_contains(
"[WARNING] spurious network error \
(1 tries remaining): [..]",
)
.with_stderr_data(str![[r#"
...
[WARNING] spurious network error (1 tries remaining): [7] Couldn't connect to server (Failed to connect to 127.0.0.1 port 11 after [..] ms: Couldn't connect to server)[..]
...
"#]])
.run();
}
@ -67,10 +67,11 @@ fn net_retry_git_outputs_warning() {
p.cargo("check -v -j 1")
.with_status(101)
.with_stderr_contains(
"[WARNING] spurious network error \
(2 tries remaining): [..]",
)
.with_stderr_contains("[WARNING] spurious network error (1 tries remaining): [..]")
.with_stderr_data(str![[r#"
...
[WARNING] spurious network error (2 tries remaining): [7] Couldn't connect to server (Failed to connect to 127.0.0.1 port 11 after [..] ms: Couldn't connect to server)[..]
[WARNING] spurious network error (1 tries remaining): [7] Couldn't connect to server (Failed to connect to 127.0.0.1 port 11 after [..] ms: Couldn't connect to server)[..]
...
"#]])
.run();
}