Skip to content

Commit 2134921

Browse files
Allow fmt to run on rmake.rs test files
1 parent c1ee38b commit 2134921

File tree

10 files changed

+45
-69
lines changed

10 files changed

+45
-69
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

+7
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,13 @@ 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+
// If the path starts with `!`, it means we don't want it to be ignored,
119+
// hence why we remove the prepending `!` character.
120+
//
121+
// Otherwise, we tell the `ignore` crate that the path should be ignored
122+
// by prepending it with a `!`.
123+
//
124+
// Keep in mind that the `ignore` crate follows the gitignore syntax.
118125
if let Some(ignore) = ignore.strip_prefix('!') {
119126
fmt_override.add(ignore).expect(ignore);
120127
} else {

tests/run-make/CURRENT_RUSTC_VERSION/rmake.rs

+2-6
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,15 @@ extern crate run_make_support;
77

88
use std::path::PathBuf;
99

10-
use run_make_support::{rustc, aux_build};
10+
use run_make_support::{aux_build, rustc};
1111

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

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

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

2420
let stderr = String::from_utf8_lossy(&output.stderr);
2521
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
@@ -51,22 +51,22 @@ fn main() {
5151
let bootstrap_cargo = std::env::var("BOOTSTRAP_CARGO").unwrap();
5252
let mut cmd = std::process::Command::new(bootstrap_cargo);
5353
cmd.args([
54-
"build",
55-
"--manifest-path",
56-
manifest_path.to_str().unwrap(),
57-
"-Zbuild-std=core",
58-
"--target",
59-
&target,
60-
])
61-
.env_clear()
62-
.env("PATH", path)
63-
.env("RUSTC", rustc)
64-
.env("RUSTFLAGS", "-Copt-level=0 -Cdebug-assertions=yes")
65-
.env("CARGO_TARGET_DIR", &target_dir)
66-
.env("RUSTC_BOOTSTRAP", "1")
67-
// Visual Studio 2022 requires that the LIB env var be set so it can
68-
// find the Windows SDK.
69-
.env("LIB", std::env::var("LIB").unwrap_or_default());
54+
"build",
55+
"--manifest-path",
56+
manifest_path.to_str().unwrap(),
57+
"-Zbuild-std=core",
58+
"--target",
59+
&target,
60+
])
61+
.env_clear()
62+
.env("PATH", path)
63+
.env("RUSTC", rustc)
64+
.env("RUSTFLAGS", "-Copt-level=0 -Cdebug-assertions=yes")
65+
.env("CARGO_TARGET_DIR", &target_dir)
66+
.env("RUSTC_BOOTSTRAP", "1")
67+
// Visual Studio 2022 requires that the LIB env var be set so it can
68+
// find the Windows SDK.
69+
.env("LIB", std::env::var("LIB").unwrap_or_default());
7070
set_host_rpath(&mut cmd);
7171

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

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

+7-23
Original file line numberDiff line numberDiff line change
@@ -5,39 +5,23 @@ extern crate run_make_support;
55
use run_make_support::{rustc, rustdoc, tmp_dir};
66

77
fn main() {
8-
rustc()
9-
.arg("success.rs")
10-
.run();
8+
rustc().arg("success.rs").run();
119

12-
rustc()
13-
.arg("--invalid-arg-foo")
14-
.run_fail_assert_exit_code(1);
10+
rustc().arg("--invalid-arg-foo").run_fail_assert_exit_code(1);
1511

16-
rustc()
17-
.arg("compile-error.rs")
18-
.run_fail_assert_exit_code(1);
12+
rustc().arg("compile-error.rs").run_fail_assert_exit_code(1);
1913

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

26-
rustdoc()
27-
.arg("success.rs")
28-
.arg("-o")
29-
.arg(tmp_dir().join("exit-code"))
30-
.run();
20+
rustdoc().arg("success.rs").arg("-o").arg(tmp_dir().join("exit-code")).run();
3121

32-
rustdoc()
33-
.arg("--invalid-arg-foo")
34-
.run_fail_assert_exit_code(1);
22+
rustdoc().arg("--invalid-arg-foo").run_fail_assert_exit_code(1);
3523

36-
rustdoc()
37-
.arg("compile-error.rs")
38-
.run_fail_assert_exit_code(1);
24+
rustdoc().arg("compile-error.rs").run_fail_assert_exit_code(1);
3925

40-
rustdoc()
41-
.arg("lint-failure.rs")
42-
.run_fail_assert_exit_code(1);
26+
rustdoc().arg("lint-failure.rs").run_fail_assert_exit_code(1);
4327
}

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

+7-9
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,11 @@ extern crate run_make_support;
1616

1717
use std::io::BufRead;
1818

19-
use run_make_support::{rustc, is_msvc};
19+
use run_make_support::{is_msvc, rustc};
2020

2121
fn main() {
2222
// build supporting crate
23-
rustc()
24-
.input("bar.rs")
25-
.crate_type("rlib")
26-
.arg("-lbar_cli")
27-
.run();
23+
rustc().input("bar.rs").crate_type("rlib").arg("-lbar_cli").run();
2824

2925
// build main crate as staticlib
3026
let output = rustc()
@@ -39,7 +35,9 @@ fn main() {
3935
for l in output.stderr.lines() {
4036
let l = l.expect("utf-8 string");
4137

42-
let Some(args) = l.strip_prefix("note: native-static-libs:") else { continue; };
38+
let Some(args) = l.strip_prefix("note: native-static-libs:") else {
39+
continue;
40+
};
4341
assert!(!found_note);
4442
found_note = true;
4543

@@ -55,11 +53,11 @@ fn main() {
5553
);
5654
let found = $args.contains(&&*lib);
5755
assert!(found, "unable to find lib `{}` in those linker args: {:?}", lib, $args);
58-
}}
56+
}};
5957
}
6058

6159
assert_contains_lib!("glib-2.0" in args); // in bar.rs
62-
assert_contains_lib!("systemd" in args); // in foo.rs
60+
assert_contains_lib!("systemd" in args); // in foo.rs
6361
assert_contains_lib!("bar_cli" in args);
6462
assert_contains_lib!("foo_cli" in args);
6563

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

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

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

2420
// Printed by compiler/rustc_codegen_llvm/src/llvm_util.rs
2521
check(Option {

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//@ only-wasm32-wasip1
22
extern crate run_make_support;
33

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

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
extern crate run_make_support;
44

5-
use run_make_support::{tmp_dir, wasmparser, rustc};
5+
use run_make_support::{rustc, tmp_dir, wasmparser};
66
use std::collections::HashMap;
77
use std::path::Path;
88
use wasmparser::ExternalKind::*;

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

+2-7
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,13 @@
22

33
extern crate run_make_support;
44

5-
use run_make_support::{tmp_dir, wasmparser, rustc};
5+
use run_make_support::{rustc, tmp_dir, wasmparser};
66
use std::collections::HashMap;
77
use wasmparser::TypeRef::Func;
88

99
fn main() {
1010
rustc().input("foo.rs").target("wasm32-wasip1").run();
11-
rustc()
12-
.input("bar.rs")
13-
.target("wasm32-wasip1")
14-
.arg("-Clto")
15-
.opt()
16-
.run();
11+
rustc().input("bar.rs").target("wasm32-wasip1").arg("-Clto").opt().run();
1712

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

0 commit comments

Comments
 (0)