diff --git a/src/tools/tidy/src/allowed_run_make_makefiles.txt b/src/tools/tidy/src/allowed_run_make_makefiles.txt index 741bb46d1a713..aa8a0be5fd490 100644 --- a/src/tools/tidy/src/allowed_run_make_makefiles.txt +++ b/src/tools/tidy/src/allowed_run_make_makefiles.txt @@ -175,8 +175,4 @@ run-make/track-pgo-dep-info/Makefile run-make/translation/Makefile run-make/type-mismatch-same-crate-name/Makefile run-make/unstable-flag-required/Makefile -run-make/volatile-intrinsics/Makefile -run-make/wasm-exceptions-nostd/Makefile -run-make/wasm-override-linker/Makefile -run-make/weird-output-filenames/Makefile run-make/x86_64-fortanix-unknown-sgx-lvi/Makefile diff --git a/tests/run-make/compressed-debuginfo/rmake.rs b/tests/run-make/compressed-debuginfo/rmake.rs index 9c6d50ab243cd..37002c672d8c0 100644 --- a/tests/run-make/compressed-debuginfo/rmake.rs +++ b/tests/run-make/compressed-debuginfo/rmake.rs @@ -5,7 +5,7 @@ // FIXME: This test isn't comprehensive and isn't covering all possible combinations. -use run_make_support::{assert_contains, cmd, run_in_tmpdir, rustc}; +use run_make_support::{assert_contains, cmd, llvm_readobj, run_in_tmpdir, rustc}; fn check_compression(compression: &str, to_find: &str) { run_in_tmpdir(|| { @@ -19,8 +19,7 @@ fn check_compression(compression: &str, to_find: &str) { .run(); let stderr = out.stderr_utf8(); if stderr.is_empty() { - // FIXME: `readelf` might need to be replaced with `llvm-readelf`. - cmd("readelf").arg("-t").arg("foo.o").run().assert_stdout_contains(to_find); + llvm_readobj().arg("-t").arg("foo.o").run().assert_stdout_contains(to_find); } else { assert_contains( &stderr, diff --git a/tests/run-make/volatile-intrinsics/Makefile b/tests/run-make/volatile-intrinsics/Makefile deleted file mode 100644 index 5672a045873dd..0000000000000 --- a/tests/run-make/volatile-intrinsics/Makefile +++ /dev/null @@ -1,10 +0,0 @@ -# ignore-cross-compile -include ../tools.mk - -all: - # The tests must pass... - $(RUSTC) main.rs - $(call RUN,main) - # ... and the loads/stores must not be optimized out. - $(RUSTC) main.rs --emit=llvm-ir - $(CGREP) "load volatile" "store volatile" < $(TMPDIR)/main.ll diff --git a/tests/run-make/volatile-intrinsics/rmake.rs b/tests/run-make/volatile-intrinsics/rmake.rs new file mode 100644 index 0000000000000..fb9be4bb9ba23 --- /dev/null +++ b/tests/run-make/volatile-intrinsics/rmake.rs @@ -0,0 +1,18 @@ +//@ ignore-cross-compile + +use run_make_support::fs_wrapper::read; +use run_make_support::{assert_contains, run, rustc}; + +fn main() { + // The tests must pass... + rustc().input("main.rs").run(); + run("main"); + + // ... and the loads/stores must not be optimized out. + rustc().input("main.rs").emit("llvm-ir").run(); + + let raw_llvm_ir = read("main.ll"); + let llvm_ir = String::from_utf8_lossy(&raw_llvm_ir); + assert_contains(&llvm_ir, "load volatile"); + assert_contains(&llvm_ir, "store volatile"); +} diff --git a/tests/run-make/wasm-abi/rmake.rs b/tests/run-make/wasm-abi/rmake.rs index 0fc326babd943..ff12bcd536e7f 100644 --- a/tests/run-make/wasm-abi/rmake.rs +++ b/tests/run-make/wasm-abi/rmake.rs @@ -1,9 +1,8 @@ //@ only-wasm32-wasip1 //@ needs-wasmtime -use run_make_support::rustc; +use run_make_support::{cmd, rustc}; use std::path::Path; -use std::process::Command; fn main() { rustc().input("foo.rs").target("wasm32-wasip1").run(); @@ -19,14 +18,12 @@ fn main() { } fn run(file: &Path, method: &str, expected_output: &str) { - let output = Command::new("wasmtime") + cmd("wasmtime") .arg("run") .arg("--preload=host=host.wat") .arg("--invoke") .arg(method) .arg(file) - .output() - .unwrap(); - assert!(output.status.success()); - assert_eq!(expected_output, String::from_utf8_lossy(&output.stdout)); + .run() + .assert_stdout_equals(expected_output); } diff --git a/tests/run-make/wasm-exceptions-nostd/Makefile b/tests/run-make/wasm-exceptions-nostd/Makefile deleted file mode 100644 index 34755ec14b745..0000000000000 --- a/tests/run-make/wasm-exceptions-nostd/Makefile +++ /dev/null @@ -1,12 +0,0 @@ -include ../tools.mk - -# only-wasm32-bare - -# Add a few command line args to make exceptions work -RUSTC := $(RUSTC) -C llvm-args=-wasm-enable-eh -RUSTC := $(RUSTC) -C target-feature=+exception-handling -RUSTC := $(RUSTC) -C panic=unwind - -all: - $(RUSTC) src/lib.rs --target wasm32-unknown-unknown - $(NODE) verify.mjs $(TMPDIR)/lib.wasm diff --git a/tests/run-make/wasm-exceptions-nostd/rmake.rs b/tests/run-make/wasm-exceptions-nostd/rmake.rs new file mode 100644 index 0000000000000..720ee9909d2ab --- /dev/null +++ b/tests/run-make/wasm-exceptions-nostd/rmake.rs @@ -0,0 +1,18 @@ +//@ only-wasm32-bare + +use std::path::Path; + +use run_make_support::{cmd, env_var, rustc}; + +fn main() { + // Add a few command line args to make exceptions work + rustc() + .input(Path::new("src").join("lib.rs")) + .target("wasm32-unknown-unknown") + .panic("unwind") + .arg("-Cllvm-args=-wasm-enable-eh") + .arg("-Ctarget-feature=+exception-handling") + .run(); + + cmd(&env_var("NODE")).arg("verify.mjs").arg("lib.wasm").run(); +} diff --git a/tests/run-make/wasm-exceptions-nostd/src/panicking.rs b/tests/run-make/wasm-exceptions-nostd/src/panicking.rs index 52a32f3cd3034..414c9f6a1650b 100644 --- a/tests/run-make/wasm-exceptions-nostd/src/panicking.rs +++ b/tests/run-make/wasm-exceptions-nostd/src/panicking.rs @@ -17,8 +17,8 @@ fn panic_handler(info: &core::panic::PanicInfo<'_>) -> ! { use alloc::boxed::Box; use alloc::string::ToString; - let msg = info.message().map(|msg| msg.to_string()).unwrap_or("(no message)".to_string()); - let exception = Box::new(msg.to_string()); + let msg = info.message().to_string(); + let exception = Box::new(msg); unsafe { let exception_raw = Box::into_raw(exception); wasm_throw(exception_raw as *mut u8); diff --git a/tests/run-make/wasm-override-linker/Makefile b/tests/run-make/wasm-override-linker/Makefile deleted file mode 100644 index 1a01a574dee28..0000000000000 --- a/tests/run-make/wasm-override-linker/Makefile +++ /dev/null @@ -1,16 +0,0 @@ -# needs-force-clang-based-tests - -# FIXME(#126180): This test doesn't actually run anywhere, because the only -# CI job that sets RUSTBUILD_FORCE_CLANG_BASED_TESTS runs very few tests. - -include ../tools.mk - -ifeq ($(TARGET),wasm32-unknown-unknown) -all: - $(RUSTC) foo.rs --crate-type cdylib --target $(TARGET) -C linker=$(CLANG) -else ifeq ($(TARGET),wasm64-unknown-unknown) -all: - $(RUSTC) foo.rs --crate-type cdylib --target $(TARGET) -C linker=$(CLANG) -else -all: -endif diff --git a/tests/run-make/wasm-override-linker/rmake.rs b/tests/run-make/wasm-override-linker/rmake.rs new file mode 100644 index 0000000000000..01bc08e990159 --- /dev/null +++ b/tests/run-make/wasm-override-linker/rmake.rs @@ -0,0 +1,17 @@ +// How to run this +// $ RUSTBUILD_FORCE_CLANG_BASED_TESTS=1 ./x.py test tests/run-make/wasm-override-linker/ + +//@ needs-force-clang-based-tests + +use run_make_support::{env_var, rustc, target}; + +fn main() { + if matches!(target().as_str(), "wasm32-unknown-unknown" | "wasm64-unknown-unknown") { + rustc() + .input("foo.rs") + .crate_type("cdylib") + .target(&target()) + .linker(&env_var("CLANG")) + .run(); + } +} diff --git a/tests/run-make/weird-output-filenames/Makefile b/tests/run-make/weird-output-filenames/Makefile deleted file mode 100644 index d3a34e3b46e89..0000000000000 --- a/tests/run-make/weird-output-filenames/Makefile +++ /dev/null @@ -1,15 +0,0 @@ -include ../tools.mk - -all: - cp foo.rs $(TMPDIR)/.foo.rs - $(RUSTC) $(TMPDIR)/.foo.rs 2>&1 \ - | $(CGREP) -e "invalid character.*in crate name:" - cp foo.rs $(TMPDIR)/.foo.bar - $(RUSTC) $(TMPDIR)/.foo.bar 2>&1 \ - | $(CGREP) -e "invalid character.*in crate name:" - cp foo.rs $(TMPDIR)/+foo+bar.rs - $(RUSTC) $(TMPDIR)/+foo+bar.rs 2>&1 \ - | $(CGREP) -e "invalid character.*in crate name:" - cp foo.rs $(TMPDIR)/-foo.rs - $(RUSTC) $(TMPDIR)/-foo.rs 2>&1 \ - | $(CGREP) 'crate names cannot start with a `-`' diff --git a/tests/run-make/weird-output-filenames/rmake.rs b/tests/run-make/weird-output-filenames/rmake.rs new file mode 100644 index 0000000000000..ed331a0b8d4ea --- /dev/null +++ b/tests/run-make/weird-output-filenames/rmake.rs @@ -0,0 +1,19 @@ +use run_make_support::fs_wrapper::copy; +use run_make_support::regex::Regex; +use run_make_support::{cwd, rustc}; + +fn main() { + let invalid_characters = [".foo.rs", ".foo.bar", "+foo+bar.rs"]; + let re = Regex::new(r"invalid character.*in crate name:").unwrap(); + for f in invalid_characters { + copy("foo.rs", f); + let stderr = rustc().input(f).run_fail().stderr_utf8(); + assert!(re.is_match(&stderr)); + } + + copy("foo.rs", "-foo.rs"); + rustc() + .input(cwd().join("-foo.rs")) + .run_fail() + .assert_stderr_contains("crate names cannot start with a `-`"); +}