Skip to content

Commit 6d27169

Browse files
committedOct 8, 2023
Auto merge of #116509 - Enselic:rustc-test-op, r=Mark-Simulacrum
tests/run-make: Move RUSTC_TEST_OP to tools.mk and use in more places
2 parents e08de86 + d9a7afe commit 6d27169

File tree

11 files changed

+33
-69
lines changed

11 files changed

+33
-69
lines changed
 

‎tests/run-make/const_fn_mir/Makefile

+1-6
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,4 @@ include ../tools.mk
33

44
all:
55
$(RUSTC) main.rs --emit=mir -o "$(TMPDIR)"/dump.mir
6-
7-
ifdef RUSTC_BLESS_TEST
8-
cp "$(TMPDIR)"/dump.mir dump.mir
9-
else
10-
$(DIFF) dump.mir "$(TMPDIR)"/dump.mir
11-
endif
6+
$(RUSTC_TEST_OP) "$(TMPDIR)"/dump.mir dump.mir

‎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/overwrite-input/Makefile

+2-8
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,5 @@ include ../tools.mk
33
all:
44
$(RUSTC) main.rs -o main.rs 2> $(TMPDIR)/file.stderr || echo "failed successfully"
55
$(RUSTC) main.rs -o . 2> $(TMPDIR)/folder.stderr || echo "failed successfully"
6-
7-
ifdef RUSTC_BLESS_TEST
8-
cp "$(TMPDIR)"/file.stderr file.stderr
9-
cp "$(TMPDIR)"/folder.stderr folder.stderr
10-
else
11-
$(DIFF) file.stderr "$(TMPDIR)"/file.stderr
12-
$(DIFF) folder.stderr "$(TMPDIR)"/folder.stderr
13-
endif
6+
$(RUSTC_TEST_OP) "$(TMPDIR)"/file.stderr file.stderr
7+
$(RUSTC_TEST_OP) "$(TMPDIR)"/folder.stderr folder.stderr

‎tests/run-make/raw-dylib-alt-calling-convention/Makefile

+2-10
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,9 @@ else
1616
endif
1717

1818
"$(TMPDIR)"/driver > "$(TMPDIR)"/output.txt
19-
ifdef RUSTC_BLESS_TEST
20-
cp "$(TMPDIR)"/output.txt output.txt
21-
else
22-
$(DIFF) output.txt "$(TMPDIR)"/output.txt
23-
endif
19+
$(RUSTC_TEST_OP) "$(TMPDIR)"/output.txt output.txt
2420

2521
ifdef IS_MSVC
2622
"$(TMPDIR)"/driver true > "$(TMPDIR)"/output.msvc.txt
27-
ifdef RUSTC_BLESS_TEST
28-
cp "$(TMPDIR)"/output.msvc.txt output.msvc.txt
29-
else
30-
$(DIFF) output.msvc.txt "$(TMPDIR)"/output.msvc.txt
31-
endif
23+
$(RUSTC_TEST_OP) "$(TMPDIR)"/output.msvc.txt output.msvc.txt
3224
endif

‎tests/run-make/raw-dylib-import-name-type/Makefile

+1-6
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,4 @@ else
1414
$(CC) "$(TMPDIR)"/extern.obj extern.gnu.def --no-leading-underscore -shared -o "$(TMPDIR)"/extern.dll
1515
endif
1616
"$(TMPDIR)"/driver > "$(TMPDIR)"/output.txt
17-
18-
ifdef RUSTC_BLESS_TEST
19-
cp "$(TMPDIR)"/output.txt output.txt
20-
else
21-
$(DIFF) output.txt "$(TMPDIR)"/output.txt
22-
endif
17+
$(RUSTC_TEST_OP) "$(TMPDIR)"/output.txt output.txt

‎tests/run-make/raw-dylib-inline-cross-dylib/Makefile

+1-6
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,4 @@ else
2727
$(CC) "$(TMPDIR)"/extern_2.obj -shared -o "$(TMPDIR)"/extern_2.dll
2828
endif
2929
$(call RUN,driver) > "$(TMPDIR)"/output.txt
30-
31-
ifdef RUSTC_BLESS_TEST
32-
cp "$(TMPDIR)"/output.txt output.txt
33-
else
34-
$(DIFF) output.txt "$(TMPDIR)"/output.txt
35-
endif
30+
$(RUSTC_TEST_OP) "$(TMPDIR)"/output.txt output.txt

‎tests/run-make/raw-dylib-link-ordinal/Makefile

+1-6
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,4 @@ else
1414
$(CC) "$(TMPDIR)"/exporter.obj exporter.def -shared -o "$(TMPDIR)"/exporter.dll
1515
endif
1616
"$(TMPDIR)"/driver > "$(TMPDIR)"/output.txt
17-
18-
ifdef RUSTC_BLESS_TEST
19-
cp "$(TMPDIR)"/output.txt output.txt
20-
else
21-
$(DIFF) output.txt "$(TMPDIR)"/output.txt
22-
endif
17+
$(RUSTC_TEST_OP) "$(TMPDIR)"/output.txt output.txt

‎tests/run-make/raw-dylib-stdcall-ordinal/Makefile

+1-6
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,4 @@ else
1515
$(CC) "$(TMPDIR)"/exporter.obj exporter-gnu.def -shared -o "$(TMPDIR)"/exporter.dll
1616
endif
1717
"$(TMPDIR)"/driver > "$(TMPDIR)"/actual_output.txt
18-
19-
ifdef RUSTC_BLESS_TEST
20-
cp "$(TMPDIR)"/actual_output.txt expected_output.txt
21-
else
22-
$(DIFF) expected_output.txt "$(TMPDIR)"/actual_output.txt
23-
endif
18+
$(RUSTC_TEST_OP) "$(TMPDIR)"/actual_output.txt expected_output.txt

‎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`

‎tests/run-make/unknown-mod-stdin/Makefile

+2-9
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,5 @@ include ../tools.mk
44

55
all:
66
echo 'mod unknown;' | $(RUSTC) --crate-type rlib - >$(TMPDIR)/unknown-mod.stdout 2>$(TMPDIR)/unknown-mod.stderr || echo "failed successfully"
7-
8-
# Bless like this: RUSTC_BLESS_TEST=1 ./x.py test tests/run-make/unknown-mod-stdin
9-
ifdef RUSTC_BLESS_TEST
10-
cp "$(TMPDIR)"/unknown-mod.stdout unknown-mod.stdout
11-
cp "$(TMPDIR)"/unknown-mod.stderr unknown-mod.stderr
12-
else
13-
$(DIFF) unknown-mod.stdout "$(TMPDIR)"/unknown-mod.stdout
14-
$(DIFF) unknown-mod.stderr "$(TMPDIR)"/unknown-mod.stderr
15-
endif
7+
$(RUSTC_TEST_OP) "$(TMPDIR)"/unknown-mod.stdout unknown-mod.stdout
8+
$(RUSTC_TEST_OP) "$(TMPDIR)"/unknown-mod.stderr unknown-mod.stderr

0 commit comments

Comments
 (0)
Please sign in to comment.