about summary refs log tree commit diff
path: root/tests/run-make
diff options
context:
space:
mode:
authorOneirical <manchot@videotron.ca>2024-05-24 11:50:35 -0400
committerOneirical <manchot@videotron.ca>2024-06-17 13:51:52 -0400
commit6228b3e40e78ca0a29fd4599c9b7a3e340bb1572 (patch)
tree534eda82e029a4622adfc6e5b5562d0020a59437 /tests/run-make
parent5f44f9511d95c8efbae0e1c312e130d91acd1134 (diff)
downloadrust-6228b3e40e78ca0a29fd4599c9b7a3e340bb1572.tar.gz
rust-6228b3e40e78ca0a29fd4599c9b7a3e340bb1572.zip
Rewrite and rename `issue-26092` to rmake
Diffstat (limited to 'tests/run-make')
-rw-r--r--tests/run-make/CURRENT_RUSTC_VERSION/rmake.rs1
-rw-r--r--tests/run-make/clear-error-blank-output/blank.rs (renamed from tests/run-make/issue-26092/blank.rs)0
-rw-r--r--tests/run-make/clear-error-blank-output/rmake.rs13
-rw-r--r--tests/run-make/issue-26092/Makefile6
-rw-r--r--tests/run-make/link-arg/rmake.rs24
-rw-r--r--tests/run-make/link-dedup/Makefile12
-rw-r--r--tests/run-make/link-dedup/rmake.rs28
7 files changed, 33 insertions, 51 deletions
diff --git a/tests/run-make/CURRENT_RUSTC_VERSION/rmake.rs b/tests/run-make/CURRENT_RUSTC_VERSION/rmake.rs
index b3227b79559..d937514c2ca 100644
--- a/tests/run-make/CURRENT_RUSTC_VERSION/rmake.rs
+++ b/tests/run-make/CURRENT_RUSTC_VERSION/rmake.rs
@@ -12,7 +12,6 @@ fn main() {
 
     let output =
         rustc().input("main.rs").emit("metadata").extern_("stable", "libstable.rmeta").run();
-
     let version = fs_wrapper::read_to_string(source_root().join("src/version"));
     let expected_string = format!("stable since {}", version.trim());
     output.assert_stderr_contains(expected_string);
diff --git a/tests/run-make/issue-26092/blank.rs b/tests/run-make/clear-error-blank-output/blank.rs
index f328e4d9d04..f328e4d9d04 100644
--- a/tests/run-make/issue-26092/blank.rs
+++ b/tests/run-make/clear-error-blank-output/blank.rs
diff --git a/tests/run-make/clear-error-blank-output/rmake.rs b/tests/run-make/clear-error-blank-output/rmake.rs
new file mode 100644
index 00000000000..e0f042cf805
--- /dev/null
+++ b/tests/run-make/clear-error-blank-output/rmake.rs
@@ -0,0 +1,13 @@
+// When an empty output file is passed to rustc, the ensuing error message
+// should be clear. However, calling file_stem on an empty path returns None,
+// which, when unwrapped, causes a panic, stopping execution of rustc
+// and printing an obscure message instead of reaching the helpful
+// error message. This test checks that the panic does not occur.
+// See https://github.com/rust-lang/rust/pull/26199
+
+use run_make_support::rustc;
+
+fn main() {
+    let output = rustc().output("").stdin(b"fn main() {}").run_fail();
+    output.assert_stderr_not_contains("panic");
+}
diff --git a/tests/run-make/issue-26092/Makefile b/tests/run-make/issue-26092/Makefile
deleted file mode 100644
index 96822e7690b..00000000000
--- a/tests/run-make/issue-26092/Makefile
+++ /dev/null
@@ -1,6 +0,0 @@
-include ../tools.mk
-
-# This test ensures that rustc does not panic with `-o ""` option.
-
-all:
-	$(RUSTC) -o "" blank.rs 2>&1 | $(CGREP) -i 'panic' && exit 1 || exit 0
diff --git a/tests/run-make/link-arg/rmake.rs b/tests/run-make/link-arg/rmake.rs
index dd496101f6a..a6d68800792 100644
--- a/tests/run-make/link-arg/rmake.rs
+++ b/tests/run-make/link-arg/rmake.rs
@@ -7,18 +7,14 @@
 use run_make_support::rustc;
 
 fn main() {
-    let output = String::from_utf8(
-        rustc()
-            .input("empty.rs")
-            .link_arg("-lfoo")
-            .link_arg("-lbar")
-            .print("link-args")
-            .command_output()
-            .stdout,
-    )
-    .unwrap();
-    assert!(
-        output.contains("lfoo") || output.contains("lbar"),
-        "The output did not contain the expected \"lfoo\" or \"lbar\" strings."
-    );
+    // We are only checking for the output of --print=link-args,
+    // rustc failing or succeeding does not matter.
+    let out = rustc()
+        .input("empty.rs")
+        .link_arg("-lfoo")
+        .link_arg("-lbar")
+        .print("link-args")
+        .run_unchecked();
+    out.assert_stdout_contains("lfoo");
+    out.assert_stdout_contains("lbar");
 }
diff --git a/tests/run-make/link-dedup/Makefile b/tests/run-make/link-dedup/Makefile
deleted file mode 100644
index eff18ab48ab..00000000000
--- a/tests/run-make/link-dedup/Makefile
+++ /dev/null
@@ -1,12 +0,0 @@
-# ignore-msvc
-
-include ../tools.mk
-
-all:
-	$(RUSTC) depa.rs
-	$(RUSTC) depb.rs
-	$(RUSTC) depc.rs
-	$(RUSTC) empty.rs --cfg bar 2>&1 | $(CGREP) '"-ltesta" "-ltestb" "-ltesta"'
-	$(RUSTC) empty.rs 2>&1 | $(CGREP) '"-ltesta"'
-	$(RUSTC) empty.rs 2>&1 | $(CGREP) -v '"-ltestb"'
-	$(RUSTC) empty.rs 2>&1 | $(CGREP) -v '"-ltesta" "-ltesta" "-ltesta"'
diff --git a/tests/run-make/link-dedup/rmake.rs b/tests/run-make/link-dedup/rmake.rs
index a0d3ac86542..9bff3a4b44c 100644
--- a/tests/run-make/link-dedup/rmake.rs
+++ b/tests/run-make/link-dedup/rmake.rs
@@ -7,26 +7,18 @@
 
 //@ ignore-msvc
 
+use run_make_support::rustc;
+
 fn main() {
     rustc().input("depa.rs").run();
     rustc().input("depb.rs").run();
     rustc().input("depc.rs").run();
-    let output =
-        String::from_utf8(rustc().input("empty.rs").cfg("bar").command_output().stderr).unwrap();
-    let pos_a1 =
-        output.find("-ltesta").expect("empty.rs, compiled with --cfg, should contain -ltesta");
-    let pos_b = output[pos_a1..]
-        .find("-ltestb")
-        .map(|pos| pos + pos_a1)
-        .expect("empty.rs, compiled with --cfg, should contain -ltestb");
-    let _ = output[pos_b..]
-        .find("-ltesta")
-        .map(|pos| pos + pos_b)
-        .expect("empty.rs, compiled with --cfg, should contain a second -ltesta");
-    let output = String::from_utf8(rustc().input("empty.rs").command_output().stderr).unwrap();
-    assert!(output.contains("-ltesta"));
-    let output = String::from_utf8(rustc().input("empty.rs").command_output().stderr).unwrap();
-    assert!(!output.contains("-ltestb"));
-    let output = String::from_utf8(rustc().input("empty.rs").command_output().stderr).unwrap();
-    assert_eq!(output.matches("-ltesta").count, 1);
+    let output = rustc().input("empty.rs").cfg("bar").run_fail();
+    output.assert_stderr_contains(r#""-ltesta" "-ltestb" "-ltesta""#);
+    let output = rustc().input("empty.rs").run_fail();
+    output.assert_stderr_contains(r#""-ltesta""#);
+    let output = rustc().input("empty.rs").run_fail();
+    output.assert_stderr_not_contains(r#""-ltestb""#);
+    let output = rustc().input("empty.rs").run_fail();
+    output.assert_stderr_not_contains(r#""-ltesta" "-ltesta" "-ltesta""#);
 }