]> git.lizzy.rs Git - rust.git/blob - src/test/run-make-fulldeps/coverage-spanview-base/Makefile
Disable the spanview tests on MacOS for now
[rust.git] / src / test / run-make-fulldeps / coverage-spanview-base / Makefile
1 # needs-profiler-support
2
3 # ISSUE(76038): When targeting MSVC, Rust binaries built with both `-Z instrument-coverage` and
4 # `-C link-dead-code` typically crash (with a seg-fault) or at best generate an empty `*.profraw`.
5 # See ../coverage/coverage_tools.mk for more information.
6
7 -include ../coverage/coverage_tools.mk
8
9 BASEDIR=../coverage-spanview-base
10 SOURCEDIR=../coverage
11
12 ifeq ($(UNAME),Darwin)
13 SED_HAS_ISSUES=1
14 endif
15
16 all: $(patsubst $(SOURCEDIR)/%.rs,%,$(wildcard $(SOURCEDIR)/*.rs))
17
18 # Ensure there are no `expected` results for tests that may have been removed or renamed
19 .PHONY: clear_expected_if_blessed
20 clear_expected_if_blessed:
21 ifdef RUSTC_BLESS_TEST
22         rm -rf expected_mir_dump.*/
23 endif
24
25 -include clear_expected_if_blessed
26
27 %: $(SOURCEDIR)/%.rs
28         # Compile the test program with coverage instrumentation and generate relevant MIR.
29         $(RUSTC) $(SOURCEDIR)/$@.rs \
30                         -Zinstrument-coverage \
31                         -Clink-dead-code=$(LINK_DEAD_CODE) \
32                         -Zdump-mir=InstrumentCoverage \
33                         -Zdump-mir-spanview \
34                         -Zdump-mir-dir="$(TMPDIR)"/mir_dump.$@
35
36 ifdef SED_HAS_ISSUES
37         # FIXME(richkadel): MacOS's default sed has some significant limitations. Until I've come up
38         # with a better workaround, I'm disabling this test for MacOS.
39         #
40         # For future reference, see if `gsed` is available as an alternative.
41         which gsed || echo "no gsed"
42 else
43
44         for path in "$(TMPDIR)"/mir_dump.$@/*; do \
45                 echo $$path; \
46                 file="$$(basename "$$path")"; \
47                 echo $$file; \
48                 urlescaped="$$("$(PYTHON)" $(BASEDIR)/escape_url.py $$file)" || exit $$?; \
49                 echo $$urlescaped; \
50                 sed -i -e '1a\
51 <!--\
52 \
53 Preview this file as rendered HTML from the github source at:\
54 https://htmlpreview.github.io/?https://github.com/rust-lang/rust/blob/master/src/test/run-make-fulldeps/coverage-spanview-base/expected_mir_dump.$@/'"$$urlescaped"'\
55 \
56 For revisions in Pull Requests (PR):\
57   * Replace "rust-lang" with the github PR author\
58   * Replace "master" with the PR branch name\
59 \
60 -->' "$$path"; \
61         done && true # for/done ends in non-zero status
62
63 ifdef RUSTC_BLESS_TEST
64         mkdir -p expected_mir_dump.$@
65         cp "$(TMPDIR)"/mir_dump.$@/*InstrumentCoverage.0.html expected_mir_dump.$@/
66 else
67         # Check that the selected `mir_dump` files match what we expect (`--bless` refreshes `expected`)
68         mkdir -p "$(TMPDIR)"/actual_mir_dump.$@
69         rm -f "$(TMPDIR)"/actual_mir_dump.$@/*
70         cp "$(TMPDIR)"/mir_dump.$@/*InstrumentCoverage.0.html "$(TMPDIR)"/actual_mir_dump.$@/
71         $(DIFF) -r expected_mir_dump.$@/ "$(TMPDIR)"/actual_mir_dump.$@/
72 endif
73
74 endif