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.
This commit is contained in:
Martin Nordholts 2023-10-07 08:14:38 +02:00
parent f96541e9a9
commit 88966c4773
3 changed files with 22 additions and 12 deletions

View File

@ -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

View File

@ -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>"

View File

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