Rollup merge of #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`
This commit is contained in:
Matthias Krüger 2024-05-03 15:26:11 +02:00 committed by GitHub
commit 82030f2dd4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
10 changed files with 43 additions and 70 deletions

View File

@ -13,7 +13,7 @@ ignore = [
# tests for now are not formatted, as they are sometimes pretty-printing constrained
# (and generally rustfmt can move around comments in UI-testing incompatible ways)
"/tests/",
"!/tests/run-make/*/rmake.rs",
# do not format submodules
# FIXME: sync submodule list with tidy/bootstrap/etc

View File

@ -115,8 +115,12 @@ pub fn format(build: &Builder<'_>, check: bool, paths: &[PathBuf]) {
let rustfmt_config: RustfmtConfig = t!(toml::from_str(&rustfmt_config));
let mut fmt_override = ignore::overrides::OverrideBuilder::new(&build.src);
for ignore in rustfmt_config.ignore {
if let Some(ignore) = ignore.strip_prefix('!') {
fmt_override.add(ignore).expect(ignore);
} else {
fmt_override.add(&format!("!{ignore}")).expect(&ignore);
}
}
let git_available = match Command::new("git")
.arg("--version")
.stdout(Stdio::null())

View File

@ -5,7 +5,7 @@
use std::path::PathBuf;
use run_make_support::{rustc, aux_build};
use run_make_support::{aux_build, rustc};
fn main() {
aux_build().input("stable.rs").emit("metadata").run();
@ -13,11 +13,7 @@ fn main() {
let mut stable_path = PathBuf::from(env!("TMPDIR"));
stable_path.push("libstable.rmeta");
let output = rustc()
.input("main.rs")
.emit("metadata")
.extern_("stable", &stable_path)
.output();
let output = rustc().input("main.rs").emit("metadata").extern_("stable", &stable_path).output();
let stderr = String::from_utf8_lossy(&output.stderr);
let version = include_str!(concat!(env!("S"), "/src/version"));

View File

@ -3,17 +3,11 @@
use run_make_support::{rustc, rustdoc, tmp_dir};
fn main() {
rustc()
.arg("success.rs")
.run();
rustc().arg("success.rs").run();
rustc()
.arg("--invalid-arg-foo")
.run_fail_assert_exit_code(1);
rustc().arg("--invalid-arg-foo").run_fail_assert_exit_code(1);
rustc()
.arg("compile-error.rs")
.run_fail_assert_exit_code(1);
rustc().arg("compile-error.rs").run_fail_assert_exit_code(1);
rustc()
.env("RUSTC_ICE", "0")
@ -21,21 +15,11 @@ fn main() {
.arg("compile-error.rs")
.run_fail_assert_exit_code(101);
rustdoc()
.arg("success.rs")
.arg("-o")
.arg(tmp_dir().join("exit-code"))
.run();
rustdoc().arg("success.rs").arg("-o").arg(tmp_dir().join("exit-code")).run();
rustdoc()
.arg("--invalid-arg-foo")
.run_fail_assert_exit_code(1);
rustdoc().arg("--invalid-arg-foo").run_fail_assert_exit_code(1);
rustdoc()
.arg("compile-error.rs")
.run_fail_assert_exit_code(1);
rustdoc().arg("compile-error.rs").run_fail_assert_exit_code(1);
rustdoc()
.arg("lint-failure.rs")
.run_fail_assert_exit_code(1);
rustdoc().arg("lint-failure.rs").run_fail_assert_exit_code(1);
}

View File

@ -14,15 +14,11 @@
use std::io::BufRead;
use run_make_support::{rustc, is_msvc};
use run_make_support::{is_msvc, rustc};
fn main() {
// build supporting crate
rustc()
.input("bar.rs")
.crate_type("rlib")
.arg("-lbar_cli")
.run();
rustc().input("bar.rs").crate_type("rlib").arg("-lbar_cli").run();
// build main crate as staticlib
let output = rustc()
@ -37,7 +33,9 @@ fn main() {
for l in output.stderr.lines() {
let l = l.expect("utf-8 string");
let Some(args) = l.strip_prefix("note: native-static-libs:") else { continue; };
let Some(args) = l.strip_prefix("note: native-static-libs:") else {
continue;
};
assert!(!found_note);
found_note = true;
@ -53,7 +51,7 @@ fn main() {
);
let found = $args.contains(&&*lib);
assert!(found, "unable to find lib `{}` in those linker args: {:?}", lib, $args);
}}
}};
}
assert_contains_lib!("glib-2.0" in args); // in bar.rs

View File

@ -13,11 +13,7 @@ struct Option<'a> {
fn main() {
// Printed from CodegenBackend trait impl in rustc_codegen_llvm/src/lib.rs
check(Option {
target: &target(),
option: "relocation-models",
includes: &["dynamic-no-pic"],
});
check(Option { target: &target(), option: "relocation-models", includes: &["dynamic-no-pic"] });
// Printed by compiler/rustc_codegen_llvm/src/llvm_util.rs
check(Option {

View File

@ -1,6 +1,6 @@
//@ only-wasm32-wasip1
use run_make_support::{tmp_dir, wasmparser, rustc};
use run_make_support::{rustc, tmp_dir, wasmparser};
use std::collections::HashMap;
use std::path::Path;

View File

@ -1,6 +1,6 @@
//@ only-wasm32-wasip1
use run_make_support::{tmp_dir, wasmparser, rustc};
use run_make_support::{rustc, tmp_dir, wasmparser};
use std::collections::HashMap;
use std::path::Path;
use wasmparser::ExternalKind::*;

View File

@ -1,17 +1,12 @@
//@ only-wasm32-wasip1
use run_make_support::{tmp_dir, wasmparser, rustc};
use run_make_support::{rustc, tmp_dir, wasmparser};
use std::collections::HashMap;
use wasmparser::TypeRef::Func;
fn main() {
rustc().input("foo.rs").target("wasm32-wasip1").run();
rustc()
.input("bar.rs")
.target("wasm32-wasip1")
.arg("-Clto")
.opt()
.run();
rustc().input("bar.rs").target("wasm32-wasip1").arg("-Clto").opt().run();
let file = std::fs::read(&tmp_dir().join("bar.wasm")).unwrap();