about summary refs log tree commit diff
diff options
context:
space:
mode:
authorZalathar <Zalathar@users.noreply.github.com>2023-06-12 18:07:05 +1000
committerZalathar <Zalathar@users.noreply.github.com>2023-06-28 11:09:19 +1000
commit7b4e75b98965f45dd35a31968d388c7deca997a2 (patch)
tree36c7acc5aa8e8b5825162ad2c3b395d1239d1d69
parentedd051c31e267212e21ee30931078210ee55f579 (diff)
downloadrust-7b4e75b98965f45dd35a31968d388c7deca997a2.tar.gz
rust-7b4e75b98965f45dd35a31968d388c7deca997a2.zip
Remove the old `coverage-reports` and `coverage` directories
-rw-r--r--src/tools/compiletest/src/header.rs2
-rw-r--r--tests/run-make/coverage-llvmir/Makefile2
-rw-r--r--tests/run-make/coverage-reports/Makefile182
-rwxr-xr-xtests/run-make/coverage-reports/normalize_paths.py12
-rwxr-xr-xtests/run-make/coverage-reports/sort_subviews.py50
-rw-r--r--tests/run-make/coverage/WARNING_KEEP_NAMES_SHORT.txt10
-rw-r--r--tests/run-make/coverage/compiletest-ignore-dir3
-rw-r--r--tests/run-make/coverage/coverage_tools.mk6
8 files changed, 2 insertions, 265 deletions
diff --git a/src/tools/compiletest/src/header.rs b/src/tools/compiletest/src/header.rs
index b699accf34c..c835962ad12 100644
--- a/src/tools/compiletest/src/header.rs
+++ b/src/tools/compiletest/src/header.rs
@@ -913,7 +913,7 @@ pub fn make_test_description<R: Read>(
         // The run-coverage tests are treated as having these extra directives,
         // without needing to specify them manually in every test file.
         // (Some of the comments below have been copied over from
-        // `tests/run-make/coverage-reports/Makefile`.)
+        // `tests/run-make/coverage-reports/Makefile`, which no longer exists.)
         Mode::RunCoverage => {
             &[
                 "needs-profiler-support",
diff --git a/tests/run-make/coverage-llvmir/Makefile b/tests/run-make/coverage-llvmir/Makefile
index 7be65505332..be92f8ac8fc 100644
--- a/tests/run-make/coverage-llvmir/Makefile
+++ b/tests/run-make/coverage-llvmir/Makefile
@@ -6,7 +6,7 @@
 # version during testing, with an additional directive at the top of this file
 # that sets, for example: `min-llvm-version: 12.0`
 
-include ../coverage/coverage_tools.mk
+include ../tools.mk
 
 BASEDIR=../coverage-llvmir
 
diff --git a/tests/run-make/coverage-reports/Makefile b/tests/run-make/coverage-reports/Makefile
deleted file mode 100644
index 283b89edaf0..00000000000
--- a/tests/run-make/coverage-reports/Makefile
+++ /dev/null
@@ -1,182 +0,0 @@
-# NOTE: Most of the tests previously associated with this makefile have been
-# migrated over to the custom `run-coverage` test suite instead, so only a few
-# harder-to-port tests remain here.
-
-# needs-profiler-support
-# ignore-windows-gnu
-
-# FIXME(pietroalbini): this test currently does not work on cross-compiled
-# targets because remote-test is not capable of sending back the *.profraw
-# files generated by the LLVM instrumentation.
-# ignore-cross-compile
-
-# Rust coverage maps support LLVM Coverage Mapping Format versions 5 and 6,
-# corresponding with LLVM versions 12 and 13, respectively.
-# When upgrading LLVM versions, consider whether to enforce a minimum LLVM
-# version during testing, with an additional directive at the top of this file
-# that sets, for example: `min-llvm-version: 12.0`
-
-# FIXME(mati865): MinGW GCC miscompiles compiler-rt profiling library but with Clang it works
-# properly. Since we only have GCC on the CI ignore the test for now.
-
-include ../coverage/coverage_tools.mk
-
-BASEDIR=../coverage-reports
-SOURCEDIR=../coverage
-
-# The `llvm-cov show` flag `--debug`, used to generate the `counters` output files, is only
-# enabled if LLVM assertions are enabled. This requires Rust config `llvm/optimize` and not
-# `llvm/release_debuginfo`. Note that some CI builds disable debug assertions (by setting
-# `NO_LLVM_ASSERTIONS=1`), so the tests must still pass even if the `--debug` flag is
-# not supported. (Note that `counters` files are only produced in the `$(TMPDIR)`
-# directory, for inspection and debugging support. They are *not* copied to `expected_*`
-# files when `--bless`ed.)
-LLVM_COV_DEBUG := $(shell \
-		"$(LLVM_BIN_DIR)"/llvm-cov show --debug 2>&1 | \
-		grep -q "Unknown command line argument '--debug'"; \
-		echo $$?)
-ifeq ($(LLVM_COV_DEBUG), 1)
-DEBUG_FLAG=--debug
-endif
-
-# FIXME(richkadel): I'm adding `--ignore-filename-regex=` line(s) for specific test(s) that produce
-# `llvm-cov` results for multiple files (for example `uses_crate.rs` and `used_crate/mod.rs`) as a
-# workaround for two problems causing tests to fail on Windows:
-#
-# 1. When multiple files appear in the `llvm-cov show` results, each file's coverage results can
-#    appear in different a different order. Whether this is random or, somehow, platform-specific,
-#    the Windows output flips the order of the files, compared to Linux. In the `uses_crate.rs`
-#    test, the only test-unique (interesting) results we care about are the results for only one
-#    of the two files, `mod/uses_crate.rs`, so the workaround is to ignore all but this one file.
-#    In the future, we may want a more sophisticated solution that splits apart `llvm-cov show`
-#    results into separate results files for each result (taking care not to create new file
-#    paths that might be too long for Windows MAX_PATH limits when creating these new sub-results,
-#    as well).
-# 2. When multiple files appear in the `llvm-cov show` results, the results for each file are
-#    prefixed with their filename, including platform-specific path separators (`\` for Windows,
-#    and `/` everywhere else). This could be filtered or normalized of course, but by ignoring
-#    coverage results for all but one of the file, the filenames are no longer included anyway.
-#    If this changes (if/when we decide to support `llvm-cov show` results for multiple files),
-#    the file path separator differences may need to be addressed.
-#
-# Since this is only a workaround, I decided to implement the override by adding an option for
-# each file to be ignored, using a `--ignore-filename-regex=` entry for each one, rather than
-# implement some more sophisticated solution with a new custom test directive in the test file
-# itself (similar to `expect-exit-status`) because that would add a lot of complexity and still
-# be a workaround, with the same result, with no benefit.
-#
-# Yes these `--ignore-filename-regex=` options are included in all invocations of `llvm-cov show`
-# for now, but it is effectively ignored for all tests that don't include this file anyway.
-#
-# (Note that it's also possible the `_counters.<test>.txt` and `<test>.json` files (if generated)
-# may order results from multiple files inconsistently, which might also have to be accommodated
-# if and when we allow `llvm-cov` to produce results for multiple files. Note, the path separators
-# appear to be normalized to `/` in those files, thankfully.)
-LLVM_COV_IGNORE_FILES=\
-	--ignore-filename-regex='(uses_crate.rs|uses_inline_crate.rs|unused_mod.rs)'
-
-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 -f expected_*
-endif
-
--include clear_expected_if_blessed
-
-%: $(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 -Cinstrument-coverage --target $(TARGET)
-
-%: $(SOURCEDIR)/%.rs
-	# Compile the test program with coverage instrumentation
-	$(RUSTC) $(SOURCEDIR)/$@.rs \
-			$$( sed -n 's/^\/\/ compile-flags: \([^#]*\).*/\1/p' $(SOURCEDIR)/$@.rs ) \
-			-L "$(TMPDIR)" -Cinstrument-coverage --target $(TARGET)
-
-	# Run it in order to generate some profiling data,
-	# with `LLVM_PROFILE_FILE=<profdata_file>` environment variable set to
-	# output the coverage stats for this run.
-	LLVM_PROFILE_FILE="$(TMPDIR)"/$@.profraw \
-			$(call RUN,$@) || \
-			( \
-				status=$$?; \
-				grep -q "^\/\/ expect-exit-status-$$status" $(SOURCEDIR)/$@.rs || \
-				( >&2 echo "program exited with an unexpected exit status: $$status"; \
-					false \
-				) \
-			)
-
-	# Run it through rustdoc as well to cover doctests.
-	# `%p` is the pid, and `%m` the binary signature. We suspect that the pid alone
-	# might result in overwritten files and failed tests, as rustdoc spawns each
-	# doctest as its own process, so make sure the filename is as unique as possible.
-	LLVM_PROFILE_FILE="$(TMPDIR)"/$@-%p-%m.profraw \
-			$(RUSTDOC) --crate-name workaround_for_79771 --test $(SOURCEDIR)/$@.rs \
-			$$( sed -n 's/^\/\/ compile-flags: \([^#]*\).*/\1/p' $(SOURCEDIR)/$@.rs ) \
-			-L "$(TMPDIR)" -Cinstrument-coverage \
-			-Z unstable-options --persist-doctests=$(TMPDIR)/rustdoc-$@
-
-	# Postprocess the profiling data so it can be used by the llvm-cov tool
-	"$(LLVM_BIN_DIR)"/llvm-profdata merge --sparse \
-			"$(TMPDIR)"/$@*.profraw \
-			-o "$(TMPDIR)"/$@.profdata
-
-	# Generate a coverage report using `llvm-cov show`.
-	"$(LLVM_BIN_DIR)"/llvm-cov show \
-			$(DEBUG_FLAG) \
-			$(LLVM_COV_IGNORE_FILES) \
-			--compilation-dir=. \
-			--Xdemangler="$(RUST_DEMANGLER)" \
-			--show-line-counts-or-regions \
-			--instr-profile="$(TMPDIR)"/$@.profdata \
-			$(call BIN,"$(TMPDIR)"/$@) \
-			$$( \
-				for file in $(TMPDIR)/rustdoc-$@/*/rust_out*; do \
-				[ -x "$$file" ] && printf "%s %s " -object $$file; \
-				done \
-			) \
-		2> "$(TMPDIR)"/show_coverage_stderr.$@.txt \
-		| "$(PYTHON)" $(BASEDIR)/normalize_paths.py \
-		| "$(PYTHON)" $(BASEDIR)/sort_subviews.py \
-		> "$(TMPDIR)"/actual_show_coverage.$@.txt || \
-	( status=$$? ; \
-		>&2 cat "$(TMPDIR)"/show_coverage_stderr.$@.txt ; \
-		exit $$status \
-	)
-
-ifdef DEBUG_FLAG
-	# The first line (beginning with "Args:" contains hard-coded, build-specific
-	# file paths. Strip that line and keep the remaining lines with counter debug
-	# data.
-	tail -n +2 "$(TMPDIR)"/show_coverage_stderr.$@.txt \
-		> "$(TMPDIR)"/actual_show_coverage_counters.$@.txt
-endif
-
-ifdef RUSTC_BLESS_TEST
-	cp "$(TMPDIR)"/actual_show_coverage.$@.txt \
-			expected_show_coverage.$@.txt
-else
-	# Compare the show coverage output (`--bless` refreshes `typical` files).
-	#
-	# `llvm-cov show` normally prints instantiation groups in an unpredictable
-	# order, but we have used `sort_subviews.py` to sort them, so we can still
-	# check the output directly with `diff`.
-	#
-	# Some of the test cases are currently not working (since #110393) and have
-	# been marked with `// ignore-llvm-cov-show-diffs` so that they don't fail
-	# the build.
-
-	$(DIFF) \
-		expected_show_coverage.$@.txt "$(TMPDIR)"/actual_show_coverage.$@.txt || \
-		( grep -q '^\/\/ ignore-llvm-cov-show-diffs' $(SOURCEDIR)/$@.rs && \
-			>&2 echo 'diff failed, but suppressed with `// ignore-llvm-cov-show-diffs` in $(SOURCEDIR)/$@.rs' \
-		) || \
-		( >&2 echo 'diff failed, and not suppressed without `// ignore-llvm-cov-show-diffs` in $(SOURCEDIR)/$@.rs'; \
-			false \
-		)
-endif
diff --git a/tests/run-make/coverage-reports/normalize_paths.py b/tests/run-make/coverage-reports/normalize_paths.py
deleted file mode 100755
index e5777ad2512..00000000000
--- a/tests/run-make/coverage-reports/normalize_paths.py
+++ /dev/null
@@ -1,12 +0,0 @@
-#!/usr/bin/env python
-
-from __future__ import print_function
-
-import sys
-
-# Normalize file paths in output
-for line in sys.stdin:
-    if line.startswith("..") and line.rstrip().endswith(".rs:"):
-        print(line.replace("\\", "/"), end='')
-    else:
-        print(line, end='')
diff --git a/tests/run-make/coverage-reports/sort_subviews.py b/tests/run-make/coverage-reports/sort_subviews.py
deleted file mode 100755
index 10cfc51d447..00000000000
--- a/tests/run-make/coverage-reports/sort_subviews.py
+++ /dev/null
@@ -1,50 +0,0 @@
-#!/usr/bin/env python3
-
-# `llvm-cov show` prints grouped subviews (e.g. for generic functions) in an
-# unstable order, which is inconvenient when checking output snapshots with
-# `diff`. To work around that, this script detects consecutive subviews in its
-# piped input, and sorts them while preserving their contents.
-
-from __future__ import print_function
-
-import sys
-
-
-def main():
-    subviews = []
-
-    def flush_subviews():
-        if not subviews:
-            return
-
-        # The last "subview" should be just a boundary line on its own, so
-        # temporarily remove it before sorting the accumulated subviews.
-        terminator = subviews.pop()
-        subviews.sort()
-        subviews.append(terminator)
-
-        for view in subviews:
-            for line in view:
-                print(line, end="")
-
-        subviews.clear()
-
-    for line in sys.stdin:
-        if line.startswith("  ------------------"):
-            # This is a subview boundary line, so start a new subview.
-            subviews.append([line])
-        elif line.startswith("  |"):
-            # Add this line to the current subview.
-            subviews[-1].append(line)
-        else:
-            # This line is not part of a subview, so sort and print any
-            # accumulated subviews, and then print the line as-is.
-            flush_subviews()
-            print(line, end="")
-
-    flush_subviews()
-    assert not subviews
-
-
-if __name__ == "__main__":
-    main()
diff --git a/tests/run-make/coverage/WARNING_KEEP_NAMES_SHORT.txt b/tests/run-make/coverage/WARNING_KEEP_NAMES_SHORT.txt
deleted file mode 100644
index 6a1403b8a00..00000000000
--- a/tests/run-make/coverage/WARNING_KEEP_NAMES_SHORT.txt
+++ /dev/null
@@ -1,10 +0,0 @@
-IMPORTANT: The Rust test programs in this directory generate various output
-files in the `../coverage*` directories (`expected` and `actual` files).
-
-Microsoft Windows has a relatively short limit on file paths (not individual
-path components, but the entire path). The files generated by these
-`../coverage*` tests typically have file paths that include the program
-source file name plus function and type names (depending on the program).
-
-Keep the test file names short, and keep function names and other symbols
-short as well, to avoid hitting the Windows limits.
diff --git a/tests/run-make/coverage/compiletest-ignore-dir b/tests/run-make/coverage/compiletest-ignore-dir
deleted file mode 100644
index 470ff996098..00000000000
--- a/tests/run-make/coverage/compiletest-ignore-dir
+++ /dev/null
@@ -1,3 +0,0 @@
-# Directory "coverage" supports the tests at prefix ../coverage-*
-
-# Use ./x.py [options] test tests/run-make/coverage to run all related tests.
diff --git a/tests/run-make/coverage/coverage_tools.mk b/tests/run-make/coverage/coverage_tools.mk
deleted file mode 100644
index 028c020a461..00000000000
--- a/tests/run-make/coverage/coverage_tools.mk
+++ /dev/null
@@ -1,6 +0,0 @@
-# Common Makefile include for Rust `run-make/coverage-* tests. Include this
-# file with the line:
-#
-# include ../coverage/coverage_tools.mk
-
-include ../tools.mk