about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--tests/run-make/metadata-dep-info/Makefile6
-rw-r--r--tests/run-make/silly-file-names/Makefile6
-rw-r--r--tests/run-make/tools.mk22
3 files changed, 22 insertions, 12 deletions
diff --git a/tests/run-make/metadata-dep-info/Makefile b/tests/run-make/metadata-dep-info/Makefile
index f9043f21433..d48cbe0f295 100644
--- a/tests/run-make/metadata-dep-info/Makefile
+++ b/tests/run-make/metadata-dep-info/Makefile
@@ -1,11 +1,5 @@
 include ../tools.mk
 
-ifdef RUSTC_BLESS_TEST
-    RUSTC_TEST_OP = cp
-else
-    RUSTC_TEST_OP = $(DIFF)
-endif
-
 all:
 	$(RUSTC) --emit=metadata,dep-info --crate-type lib dash-separated.rs -C extra-filename=_something-extra
 	# Strip TMPDIR since it is a machine specific absolute path
diff --git a/tests/run-make/silly-file-names/Makefile b/tests/run-make/silly-file-names/Makefile
index a09bdb1c532..e51266c0880 100644
--- a/tests/run-make/silly-file-names/Makefile
+++ b/tests/run-make/silly-file-names/Makefile
@@ -3,12 +3,6 @@
 
 include ../tools.mk
 
-ifdef RUSTC_BLESS_TEST
-    RUSTC_TEST_OP = cp
-else
-    RUSTC_TEST_OP = $(DIFF)
-endif
-
 all:
 	echo '"comes from a file with a name that begins with <"' > "$(TMPDIR)/<leading-lt"
 	echo '"comes from a file with a name that ends with >"' > "$(TMPDIR)/trailing-gt>"
diff --git a/tests/run-make/tools.mk b/tests/run-make/tools.mk
index 6121a91e920..1d4e9111389 100644
--- a/tests/run-make/tools.mk
+++ b/tests/run-make/tools.mk
@@ -21,6 +21,28 @@ CGREP := "$(S)/src/etc/cat-and-grep.sh"
 # diff with common flags for multi-platform diffs against text output
 DIFF := diff -u --strip-trailing-cr
 
+# With RUSTC_TEST_OP you can elegantly support blessing of run-make tests. Do
+# like this in a Makefile recipe:
+#
+#   "$(TMPDIR)"/your-test > "$(TMPDIR)"/your-test.run.stdout
+#   $(RUSTC_TEST_OP) "$(TMPDIR)"/your-test.run.stdout your-test.run.stdout
+#
+# When running the test normally with
+#
+#   ./x test tests/run-make/your-test
+#
+# the actual output will be diffed against the expected output. When running in
+# bless-mode with
+#
+#   ./x test --bless tests/run-make/your-test
+#
+# the actual output will be blessed as the expected output.
+ifdef RUSTC_BLESS_TEST
+    RUSTC_TEST_OP = cp
+else
+    RUSTC_TEST_OP = $(DIFF)
+endif
+
 # Some of the Rust CI platforms use `/bin/dash` to run `shell` script in
 # Makefiles. Other platforms, including many developer platforms, default to
 # `/bin/bash`. (In many cases, `make` is actually using `/bin/sh`, but `sh`