Skip to content

Commit 82030f2

Browse files
authored
Rollup merge of rust-lang#124613 - GuillaumeGomez:fmt-run-make, r=onur-ozkan
Allow fmt to run on rmake.rs test files As discussed with `@jieyouxu,` `rmake.rs` from the `run-make` testsuite would benefit from being formatted as well. Only thing needed to be done for it to work: allow support for `!` in our `rustfmt.toml` file parsing. r? `@onur-ozkan`
2 parents c27d3d5 + 8f47f97 commit 82030f2

File tree

10 files changed

+43
-70
lines changed

10 files changed

+43
-70
lines changed

rustfmt.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ ignore = [
1313

1414
# tests for now are not formatted, as they are sometimes pretty-printing constrained
1515
# (and generally rustfmt can move around comments in UI-testing incompatible ways)
16-
"/tests/",
16+
"!/tests/run-make/*/rmake.rs",
1717

1818
# do not format submodules
1919
# FIXME: sync submodule list with tidy/bootstrap/etc

src/bootstrap/src/core/build_steps/format.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,11 @@ pub fn format(build: &Builder<'_>, check: bool, paths: &[PathBuf]) {
115115
let rustfmt_config: RustfmtConfig = t!(toml::from_str(&rustfmt_config));
116116
let mut fmt_override = ignore::overrides::OverrideBuilder::new(&build.src);
117117
for ignore in rustfmt_config.ignore {
118-
fmt_override.add(&format!("!{ignore}")).expect(&ignore);
118+
if let Some(ignore) = ignore.strip_prefix('!') {
119+
fmt_override.add(ignore).expect(ignore);
120+
} else {
121+
fmt_override.add(&format!("!{ignore}")).expect(&ignore);
122+
}
119123
}
120124
let git_available = match Command::new("git")
121125
.arg("--version")

tests/run-make/CURRENT_RUSTC_VERSION/rmake.rs

+2-6
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,15 @@
55

66
use std::path::PathBuf;
77

8-
use run_make_support::{rustc, aux_build};
8+
use run_make_support::{aux_build, rustc};
99

1010
fn main() {
1111
aux_build().input("stable.rs").emit("metadata").run();
1212

1313
let mut stable_path = PathBuf::from(env!("TMPDIR"));
1414
stable_path.push("libstable.rmeta");
1515

16-
let output = rustc()
17-
.input("main.rs")
18-
.emit("metadata")
19-
.extern_("stable", &stable_path)
20-
.output();
16+
let output = rustc().input("main.rs").emit("metadata").extern_("stable", &stable_path).output();
2117

2218
let stderr = String::from_utf8_lossy(&output.stderr);
2319
let version = include_str!(concat!(env!("S"), "/src/version"));

tests/run-make/compiler-builtins/rmake.rs

+16-16
Original file line numberDiff line numberDiff line change
@@ -49,22 +49,22 @@ fn main() {
4949
let bootstrap_cargo = std::env::var("BOOTSTRAP_CARGO").unwrap();
5050
let mut cmd = std::process::Command::new(bootstrap_cargo);
5151
cmd.args([
52-
"build",
53-
"--manifest-path",
54-
manifest_path.to_str().unwrap(),
55-
"-Zbuild-std=core",
56-
"--target",
57-
&target,
58-
])
59-
.env_clear()
60-
.env("PATH", path)
61-
.env("RUSTC", rustc)
62-
.env("RUSTFLAGS", "-Copt-level=0 -Cdebug-assertions=yes")
63-
.env("CARGO_TARGET_DIR", &target_dir)
64-
.env("RUSTC_BOOTSTRAP", "1")
65-
// Visual Studio 2022 requires that the LIB env var be set so it can
66-
// find the Windows SDK.
67-
.env("LIB", std::env::var("LIB").unwrap_or_default());
52+
"build",
53+
"--manifest-path",
54+
manifest_path.to_str().unwrap(),
55+
"-Zbuild-std=core",
56+
"--target",
57+
&target,
58+
])
59+
.env_clear()
60+
.env("PATH", path)
61+
.env("RUSTC", rustc)
62+
.env("RUSTFLAGS", "-Copt-level=0 -Cdebug-assertions=yes")
63+
.env("CARGO_TARGET_DIR", &target_dir)
64+
.env("RUSTC_BOOTSTRAP", "1")
65+
// Visual Studio 2022 requires that the LIB env var be set so it can
66+
// find the Windows SDK.
67+
.env("LIB", std::env::var("LIB").unwrap_or_default());
6868
set_host_rpath(&mut cmd);
6969

7070
let status = cmd.status().unwrap();

tests/run-make/exit-code/rmake.rs

+7-23
Original file line numberDiff line numberDiff line change
@@ -3,39 +3,23 @@
33
use run_make_support::{rustc, rustdoc, tmp_dir};
44

55
fn main() {
6-
rustc()
7-
.arg("success.rs")
8-
.run();
6+
rustc().arg("success.rs").run();
97

10-
rustc()
11-
.arg("--invalid-arg-foo")
12-
.run_fail_assert_exit_code(1);
8+
rustc().arg("--invalid-arg-foo").run_fail_assert_exit_code(1);
139

14-
rustc()
15-
.arg("compile-error.rs")
16-
.run_fail_assert_exit_code(1);
10+
rustc().arg("compile-error.rs").run_fail_assert_exit_code(1);
1711

1812
rustc()
1913
.env("RUSTC_ICE", "0")
2014
.arg("-Ztreat-err-as-bug")
2115
.arg("compile-error.rs")
2216
.run_fail_assert_exit_code(101);
2317

24-
rustdoc()
25-
.arg("success.rs")
26-
.arg("-o")
27-
.arg(tmp_dir().join("exit-code"))
28-
.run();
18+
rustdoc().arg("success.rs").arg("-o").arg(tmp_dir().join("exit-code")).run();
2919

30-
rustdoc()
31-
.arg("--invalid-arg-foo")
32-
.run_fail_assert_exit_code(1);
20+
rustdoc().arg("--invalid-arg-foo").run_fail_assert_exit_code(1);
3321

34-
rustdoc()
35-
.arg("compile-error.rs")
36-
.run_fail_assert_exit_code(1);
22+
rustdoc().arg("compile-error.rs").run_fail_assert_exit_code(1);
3723

38-
rustdoc()
39-
.arg("lint-failure.rs")
40-
.run_fail_assert_exit_code(1);
24+
rustdoc().arg("lint-failure.rs").run_fail_assert_exit_code(1);
4125
}

tests/run-make/print-native-static-libs/rmake.rs

+7-9
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,11 @@
1414

1515
use std::io::BufRead;
1616

17-
use run_make_support::{rustc, is_msvc};
17+
use run_make_support::{is_msvc, rustc};
1818

1919
fn main() {
2020
// build supporting crate
21-
rustc()
22-
.input("bar.rs")
23-
.crate_type("rlib")
24-
.arg("-lbar_cli")
25-
.run();
21+
rustc().input("bar.rs").crate_type("rlib").arg("-lbar_cli").run();
2622

2723
// build main crate as staticlib
2824
let output = rustc()
@@ -37,7 +33,9 @@ fn main() {
3733
for l in output.stderr.lines() {
3834
let l = l.expect("utf-8 string");
3935

40-
let Some(args) = l.strip_prefix("note: native-static-libs:") else { continue; };
36+
let Some(args) = l.strip_prefix("note: native-static-libs:") else {
37+
continue;
38+
};
4139
assert!(!found_note);
4240
found_note = true;
4341

@@ -53,11 +51,11 @@ fn main() {
5351
);
5452
let found = $args.contains(&&*lib);
5553
assert!(found, "unable to find lib `{}` in those linker args: {:?}", lib, $args);
56-
}}
54+
}};
5755
}
5856

5957
assert_contains_lib!("glib-2.0" in args); // in bar.rs
60-
assert_contains_lib!("systemd" in args); // in foo.rs
58+
assert_contains_lib!("systemd" in args); // in foo.rs
6159
assert_contains_lib!("bar_cli" in args);
6260
assert_contains_lib!("foo_cli" in args);
6361

tests/run-make/print-to-output/rmake.rs

+1-5
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,7 @@ struct Option<'a> {
1313

1414
fn main() {
1515
// Printed from CodegenBackend trait impl in rustc_codegen_llvm/src/lib.rs
16-
check(Option {
17-
target: &target(),
18-
option: "relocation-models",
19-
includes: &["dynamic-no-pic"],
20-
});
16+
check(Option { target: &target(), option: "relocation-models", includes: &["dynamic-no-pic"] });
2117

2218
// Printed by compiler/rustc_codegen_llvm/src/llvm_util.rs
2319
check(Option {

tests/run-make/wasm-custom-sections-opt/rmake.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//@ only-wasm32-wasip1
22

3-
use run_make_support::{tmp_dir, wasmparser, rustc};
3+
use run_make_support::{rustc, tmp_dir, wasmparser};
44
use std::collections::HashMap;
55
use std::path::Path;
66

tests/run-make/wasm-export-all-symbols/rmake.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//@ only-wasm32-wasip1
22

3-
use run_make_support::{tmp_dir, wasmparser, rustc};
3+
use run_make_support::{rustc, tmp_dir, wasmparser};
44
use std::collections::HashMap;
55
use std::path::Path;
66
use wasmparser::ExternalKind::*;

tests/run-make/wasm-import-module/rmake.rs

+2-7
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,12 @@
11
//@ only-wasm32-wasip1
22

3-
use run_make_support::{tmp_dir, wasmparser, rustc};
3+
use run_make_support::{rustc, tmp_dir, wasmparser};
44
use std::collections::HashMap;
55
use wasmparser::TypeRef::Func;
66

77
fn main() {
88
rustc().input("foo.rs").target("wasm32-wasip1").run();
9-
rustc()
10-
.input("bar.rs")
11-
.target("wasm32-wasip1")
12-
.arg("-Clto")
13-
.opt()
14-
.run();
9+
rustc().input("bar.rs").target("wasm32-wasip1").arg("-Clto").opt().run();
1510

1611
let file = std::fs::read(&tmp_dir().join("bar.wasm")).unwrap();
1712

0 commit comments

Comments
 (0)