Skip to content

Commit 74f7e32

Browse files
committed
Auto merge of #78888 - richkadel:llvm-coverage-tests, r=tmandry
Fix and re-enable two coverage tests on MacOS Note, in the coverage-reports test, the comment about MacOS was wrong. The setting is based on config.toml llvm `optimize` setting. There doesn't appear to be any environment variable I can check, and I don't think we should add one. Testing the binary itself is a more reliable way to check anyway. For the coverage-spanview test, I removed the dependency on sed altogether, which is much less ugly than trying to work around the MacOS sed differences. I tested these changes on Linux, Windows, and Mac. r? `@tmandry` FYI `@wesleywiser`
2 parents 89bce3e + fe56d26 commit 74f7e32

File tree

2 files changed

+23
-35
lines changed
  • src/test/run-make-fulldeps

2 files changed

+23
-35
lines changed

src/test/run-make-fulldeps/coverage-reports-base/Makefile

+6-8
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,13 @@
1313
BASEDIR=../coverage-reports-base
1414
SOURCEDIR=../coverage
1515

16-
ifeq ($(UNAME),Darwin)
17-
# FIXME(richkadel): It appears that --debug is not available on MacOS even when not running
18-
# under CI.
19-
NO_LLVM_ASSERTIONS=1
20-
endif
21-
2216
# The `llvm-cov show` flag `--debug`, used to generate the `counters` output files, is only enabled
23-
# if LLVM assertions are enabled. Some CI builds disable debug assertions.
24-
ifndef NO_LLVM_ASSERTIONS
17+
# if LLVM assertions are enabled. Requires Rust config `llvm/optimize` and not
18+
# `llvm/release_debuginfo`. Note that some CI builds disable debug assertions (by setting
19+
# `NO_LLVM_ASSERTIONS=1`), so it is not OK to fail the test, but `bless`ed test results cannot be
20+
# generated without debug assertions.
21+
LLVM_COV_DEBUG := $(shell "$(LLVM_BIN_DIR)"/llvm-cov show --debug 2>&1 | grep -q "Unknown command line argument '--debug'"; echo $$?)
22+
ifeq ($(LLVM_COV_DEBUG), 1)
2523
DEBUG_FLAG=--debug
2624
endif
2725

src/test/run-make-fulldeps/coverage-spanview-base/Makefile

+17-27
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,20 @@
99
BASEDIR=../coverage-spanview-base
1010
SOURCEDIR=../coverage
1111

12-
ifeq ($(UNAME),Darwin)
13-
SED_HAS_ISSUES=1
14-
endif
12+
define SPANVIEW_HEADER
13+
<!DOCTYPE html>
14+
<!--
15+
16+
Preview this file as rendered HTML from the github source at:
17+
https://htmlpreview.github.io/?https://github.com/rust-lang/rust/blob/master/src/test/run-make-fulldeps/coverage-spanview-base/expected_mir_dump.%s/%s
18+
19+
For revisions in Pull Requests (PR):
20+
* Replace "rust-lang" with the github PR author
21+
* Replace "master" with the PR branch name
22+
23+
-->
24+
endef
25+
export SPANVIEW_HEADER
1526

1627
all: $(patsubst $(SOURCEDIR)/%.rs,%,$(wildcard $(SOURCEDIR)/*.rs))
1728

@@ -33,31 +44,12 @@ endif
3344
-Zdump-mir-spanview \
3445
-Zdump-mir-dir="$(TMPDIR)"/mir_dump.$@
3546

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-
4447
for path in "$(TMPDIR)"/mir_dump.$@/*; do \
45-
echo $$path; \
4648
file="$$(basename "$$path")"; \
47-
echo $$file; \
4849
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"; \
50+
printf "$$SPANVIEW_HEADER\n" "$@" "$$urlescaped" > "$$path".modified; \
51+
tail -n +2 "$$path" >> "$$path".modified; \
52+
mv "$$path".modified "$$path"; \
6153
done && true # for/done ends in non-zero status
6254

6355
ifdef RUSTC_BLESS_TEST
@@ -70,5 +62,3 @@ else
7062
cp "$(TMPDIR)"/mir_dump.$@/*InstrumentCoverage.0.html "$(TMPDIR)"/actual_mir_dump.$@/
7163
$(DIFF) -r expected_mir_dump.$@/ "$(TMPDIR)"/actual_mir_dump.$@/
7264
endif
73-
74-
endif

0 commit comments

Comments
 (0)