diff options
| author | Martin Nordholts <enselic@gmail.com> | 2023-10-07 08:14:38 +0200 |
|---|---|---|
| committer | Martin Nordholts <enselic@gmail.com> | 2023-10-07 08:30:40 +0200 |
| commit | 88966c477386db4ccabd18df3de52647d3540f96 (patch) | |
| tree | 9252b32fdcabb6a6c624aaac6883cb15a1b53c88 | |
| parent | f96541e9a9be7a5b28191be9229d72c8bf47baa7 (diff) | |
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.
| -rw-r--r-- | tests/run-make/metadata-dep-info/Makefile | 6 | ||||
| -rw-r--r-- | tests/run-make/silly-file-names/Makefile | 6 | ||||
| -rw-r--r-- | tests/run-make/tools.mk | 22 |
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` |
