Skip to content

Commit 88966c4

Browse files
committed
tests/run-make: Move RUSTC_TEST_OP to tools.mk
To reduce duplication. A follow-up commit will begin using it in even more places.
1 parent f96541e commit 88966c4

File tree

3 files changed

+22
-12
lines changed

3 files changed

+22
-12
lines changed

tests/run-make/metadata-dep-info/Makefile

-6
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,5 @@
11
include ../tools.mk
22

3-
ifdef RUSTC_BLESS_TEST
4-
RUSTC_TEST_OP = cp
5-
else
6-
RUSTC_TEST_OP = $(DIFF)
7-
endif
8-
93
all:
104
$(RUSTC) --emit=metadata,dep-info --crate-type lib dash-separated.rs -C extra-filename=_something-extra
115
# Strip TMPDIR since it is a machine specific absolute path

tests/run-make/silly-file-names/Makefile

-6
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,6 @@
33

44
include ../tools.mk
55

6-
ifdef RUSTC_BLESS_TEST
7-
RUSTC_TEST_OP = cp
8-
else
9-
RUSTC_TEST_OP = $(DIFF)
10-
endif
11-
126
all:
137
echo '"comes from a file with a name that begins with <"' > "$(TMPDIR)/<leading-lt"
148
echo '"comes from a file with a name that ends with >"' > "$(TMPDIR)/trailing-gt>"

tests/run-make/tools.mk

+22
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,28 @@ CGREP := "$(S)/src/etc/cat-and-grep.sh"
2121
# diff with common flags for multi-platform diffs against text output
2222
DIFF := diff -u --strip-trailing-cr
2323

24+
# With RUSTC_TEST_OP you can elegantly support blessing of run-make tests. Do
25+
# like this in a Makefile recipe:
26+
#
27+
# "$(TMPDIR)"/your-test > "$(TMPDIR)"/your-test.run.stdout
28+
# $(RUSTC_TEST_OP) "$(TMPDIR)"/your-test.run.stdout your-test.run.stdout
29+
#
30+
# When running the test normally with
31+
#
32+
# ./x test tests/run-make/your-test
33+
#
34+
# the actual output will be diffed against the expected output. When running in
35+
# bless-mode with
36+
#
37+
# ./x test --bless tests/run-make/your-test
38+
#
39+
# the actual output will be blessed as the expected output.
40+
ifdef RUSTC_BLESS_TEST
41+
RUSTC_TEST_OP = cp
42+
else
43+
RUSTC_TEST_OP = $(DIFF)
44+
endif
45+
2446
# Some of the Rust CI platforms use `/bin/dash` to run `shell` script in
2547
# Makefiles. Other platforms, including many developer platforms, default to
2648
# `/bin/bash`. (In many cases, `make` is actually using `/bin/sh`, but `sh`

0 commit comments

Comments
 (0)