Skip to content

Commit 263898e

Browse files
test: check that it can build with CARGO_UNSTABLE_BUILD_STD=std
Regression test for #7
1 parent 823a770 commit 263898e

File tree

2 files changed

+38
-11
lines changed

2 files changed

+38
-11
lines changed

tests/test-argv/Cargo.toml

+1-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ publish = false
88

99
[profile.release]
1010
strip = "symbols"
11-
panic = "abort"
1211

1312
[package.metadata.multivers.x86_64]
14-
cpus = ["generic", "alderlake", "skylake", "sandybridge", "ivybridge"]
13+
cpus = ["x86-64", "x86-64-v2", "x86-64-v3"]

tests/test.rs

+37-9
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,30 @@ use escargot::CargoBuild;
88
use predicates::prelude::*;
99

1010
#[cfg(test)]
11-
fn build_crate(name: &str) -> Command {
11+
fn build_crate(
12+
name: &str,
13+
modify_command_callback: impl FnOnce(&mut std::process::Command),
14+
) -> Command {
1215
let multivers_manifest = Path::new(env!("CARGO_MANIFEST_DIR")).join("Cargo.toml");
1316
let test_manifest = Path::new(env!("CARGO_MANIFEST_DIR"))
1417
.join("tests")
1518
.join(name)
1619
.join("Cargo.toml");
1720

18-
let assert = CargoBuild::new()
21+
let mut command = CargoBuild::new()
1922
.manifest_path(multivers_manifest)
2023
.run()
2124
.unwrap()
22-
.command()
25+
.command();
26+
27+
command
2328
.arg("multivers")
2429
.arg("--manifest-path")
25-
.arg(test_manifest)
26-
.assert()
27-
.success();
30+
.arg(test_manifest);
31+
32+
modify_command_callback(&mut command);
33+
34+
let assert = command.assert().success();
2835

2936
// Until we output json like cargo we need to parse the output manually
3037
let output = assert.get_output();
@@ -41,14 +48,17 @@ fn build_crate(name: &str) -> Command {
4148
/// It should build without a runner since every build leads to the same binary.
4249
#[test]
4350
fn crate_that_does_nothing() {
44-
build_crate("test-nothing").assert().success().stdout("");
51+
build_crate("test-nothing", |_| ())
52+
.assert()
53+
.success()
54+
.stdout("");
4555
}
4656

4757
/// Checks that we can build a crate that prints its argv and that works as expected
4858
#[test]
4959
fn crate_that_prints_argv() {
5060
let expected_args = ["z", "foo2", "''"];
51-
build_crate("test-argv")
61+
build_crate("test-argv", |_| ())
5262
.args(expected_args)
5363
.assert()
5464
.success()
@@ -64,7 +74,7 @@ fn crate_that_prints_argv() {
6474
#[test]
6575
fn crate_within_workspace() {
6676
let expected_args = ["workspace", "abc", "0987"];
67-
build_crate("test-workspace")
77+
build_crate("test-workspace", |_| ())
6878
.args(expected_args)
6979
.assert()
7080
.success()
@@ -73,3 +83,21 @@ fn crate_within_workspace() {
7383
expected_args.join(" ")
7484
)));
7585
}
86+
87+
/// Checks that we can build a crate with `CARGO_UNSTABLE_BUILD_STD=std`.
88+
///
89+
/// Regression test (see #7).
90+
#[test]
91+
fn rebuild_std_env() {
92+
let expected_args = ["z", "foo2", "''"];
93+
build_crate("test-argv", |command| {
94+
command.env("CARGO_UNSTABLE_BUILD_STD", "std");
95+
})
96+
.args(expected_args)
97+
.assert()
98+
.success()
99+
.stdout(predicate::str::ends_with(format!(
100+
"{}\n",
101+
expected_args.join(" ")
102+
)));
103+
}

0 commit comments

Comments
 (0)