blob: b3d1009dbd09260611bb6c4e7439e3af1ee60214 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
|
# needs-profiler-support
# min-llvm-version: 11.0
-include ../coverage/coverage_tools.mk
BASEDIR=../coverage-spanview
SOURCEDIR=../coverage
define SPANVIEW_HEADER
<!DOCTYPE html>
<!--
Preview this file as rendered HTML from the github source at:
https://htmlpreview.github.io/?https://github.com/rust-lang/rust/blob/master/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.%s/%s
For revisions in Pull Requests (PR):
* Replace "rust-lang" with the github PR author
* Replace "master" with the PR branch name
-->
endef
export SPANVIEW_HEADER
all: $(patsubst $(SOURCEDIR)/lib/%.rs,%,$(wildcard $(SOURCEDIR)/lib/*.rs)) $(patsubst $(SOURCEDIR)/%.rs,%,$(wildcard $(SOURCEDIR)/*.rs))
# Ensure there are no `expected` results for tests that may have been removed or renamed
.PHONY: clear_expected_if_blessed
clear_expected_if_blessed:
ifdef RUSTC_BLESS_TEST
rm -rf expected_mir_dump.*/
endif
-include clear_expected_if_blessed
# FIXME(richkadel): The actions for these two types of targets (libraries and binaries) should be
# combined.
%: $(SOURCEDIR)/lib/%.rs
# Compile the test library with coverage instrumentation
$(RUSTC) $(SOURCEDIR)/lib/$@.rs \
$$( sed -n 's/^\/\/ compile-flags: \([^#]*\).*/\1/p' $(SOURCEDIR)/lib/$@.rs ) \
--crate-type rlib \
-Ztrim-diagnostic-paths=no \
-Zdump-mir=InstrumentCoverage -Zdump-mir-spanview -Zdump-mir-dir="$(TMPDIR)"/mir_dump.$@ \
-Zinstrument-coverage
for path in "$(TMPDIR)"/mir_dump.$@/*; do \
file="$$(basename "$$path")"; \
urlescaped="$$("$(PYTHON)" $(BASEDIR)/escape_url.py $$file)" || exit $$?; \
printf "$$SPANVIEW_HEADER\n" "$@" "$$urlescaped" > "$$path".modified; \
tail -n +2 "$$path" >> "$$path".modified; \
mv "$$path".modified "$$path"; \
done && true # for/done ends in non-zero status
ifdef RUSTC_BLESS_TEST
mkdir -p expected_mir_dump.$@
cp "$(TMPDIR)"/mir_dump.$@/*InstrumentCoverage.0.html expected_mir_dump.$@/
else
# Check that the selected `mir_dump` files match what we expect (`--bless` refreshes `expected`)
mkdir -p "$(TMPDIR)"/actual_mir_dump.$@
rm -f "$(TMPDIR)"/actual_mir_dump.$@/*
cp "$(TMPDIR)"/mir_dump.$@/*InstrumentCoverage.0.html "$(TMPDIR)"/actual_mir_dump.$@/
$(DIFF) -r expected_mir_dump.$@/ "$(TMPDIR)"/actual_mir_dump.$@/
endif
%: $(SOURCEDIR)/%.rs
# Compile the test program with coverage instrumentation
$(RUSTC) $(SOURCEDIR)/$@.rs \
$$( sed -n 's/^\/\/ compile-flags: \([^#]*\).*/\1/p' $(SOURCEDIR)/$@.rs ) \
-L "$(TMPDIR)" \
-Ztrim-diagnostic-paths=no \
-Zdump-mir=InstrumentCoverage -Zdump-mir-spanview -Zdump-mir-dir="$(TMPDIR)"/mir_dump.$@ \
-Zinstrument-coverage
for path in "$(TMPDIR)"/mir_dump.$@/*; do \
file="$$(basename "$$path")"; \
urlescaped="$$("$(PYTHON)" $(BASEDIR)/escape_url.py $$file)" || exit $$?; \
printf "$$SPANVIEW_HEADER\n" "$@" "$$urlescaped" > "$$path".modified; \
tail -n +2 "$$path" >> "$$path".modified; \
mv "$$path".modified "$$path"; \
done && true # for/done ends in non-zero status
ifdef RUSTC_BLESS_TEST
mkdir -p expected_mir_dump.$@
cp "$(TMPDIR)"/mir_dump.$@/*InstrumentCoverage.0.html expected_mir_dump.$@/
else
# Check that the selected `mir_dump` files match what we expect (`--bless` refreshes `expected`)
mkdir -p "$(TMPDIR)"/actual_mir_dump.$@
rm -f "$(TMPDIR)"/actual_mir_dump.$@/*
cp "$(TMPDIR)"/mir_dump.$@/*InstrumentCoverage.0.html "$(TMPDIR)"/actual_mir_dump.$@/
$(DIFF) -r expected_mir_dump.$@/ "$(TMPDIR)"/actual_mir_dump.$@/
endif
|