@@ -22,6 +22,43 @@ ifeq ($(LLVM_COV_DEBUG), 1)
2222DEBUG_FLAG =--debug
2323endif
2424
25+ # FIXME(richkadel): I'm adding `--ignore-filename-regex=` line(s) for specific test(s) that produce
26+ # `llvm-cov` results for multiple files (for example `uses_crate.rs` and `used_crate/mod.rs`) as a
27+ # workaround for two problems causing tests to fail on Windows:
28+ #
29+ # 1. When multiple files appear in the `llvm-cov show` results, each file's coverage results can
30+ # appear in different a different order. Whether this is random or, somehow, platform-specific,
31+ # the Windows output flips the order of the files, compared to Linux. In the `uses_crate.rs`
32+ # test, the only test-unique (interesting) results we care about are the results for only one
33+ # of the two files, `mod/uses_crate.rs`, so the workaround is to ignore all but this one file.
34+ # In the future, we may want a more sophisticated solution that splits apart `llvm-cov show`
35+ # results into separate results files for each result (taking care not to create new file
36+ # paths that might be too long for Windows MAX_PATH limits when creating these new sub-results,
37+ # as well).
38+ # 2. When multiple files appear in the `llvm-cov show` results, the results for each file are
39+ # prefixed with their filename, including platform-specific path separators (`\` for Windows,
40+ # and `/` everywhere else). This could be filtered or normalized of course, but by ignoring
41+ # coverage results for all but one of the file, the filenames are no longer included anyway.
42+ # If this changes (if/when we decide to support `llvm-cov show` results for multiple files),
43+ # the file path separator differences may need to be addressed.
44+ #
45+ # Since this is only a workaround, I decided to implement the override by adding an option for
46+ # each file to be ignored, using a `--ignore-filename-regex=` entry for each one, rather than
47+ # implement some more sophisticated solution with a new custom test directive in the test file
48+ # itself (similar to `expect-exit-status`) because that would add a lot of complexity and still
49+ # be a workaround, with the same result, with no benefit.
50+ #
51+ # Yes these `--ignore-filename-regex=` options are included in all invocations of `llvm-cov show`
52+ # for now, but it is effectively ignored for all tests that don't include this file anyway.
53+ #
54+ # Note that it's also possible the `_counters.<test>.txt` and `<test>.json` files may order
55+ # results from multiple files inconsistently, which might also have to be accomodated if and when
56+ # we allow `llvm-cov` to produce results for multiple files. (The path separators appear to be
57+ # normalized to `/` in those files, thankfully.) But since we are ignoring results for all but one
58+ # file, this workaround addresses those potential issues as well.
59+ LLVM_COV_IGNORE_FILES =\
60+ --ignore-filename-regex=uses_crate.rs
61+
2562# When generating `expected_*` results (using `x.py test --bless`), the `--debug` flag is forced.
2663# If assertions are disabled, the command will fail with an error, rather than attempt to generate
2764# only partial results.
76113 # Generate a coverage report using `llvm-cov show`.
77114 "$(LLVM_BIN_DIR)"/llvm-cov show \
78115 $(DEBUG_FLAG) \
116+ $(LLVM_COV_IGNORE_FILES) \
79117 --Xdemangler="$(RUST_DEMANGLER)" \
80118 --show-line-counts-or-regions \
81119 --instr-profile="$(TMPDIR)"/$@.profdata \
@@ -133,6 +171,7 @@ endif
133171 # Generate a coverage report in JSON, using `llvm-cov export`, and fail if
134172 # there are differences from the expected output.
135173 "$(LLVM_BIN_DIR)"/llvm-cov export \
174+ $(LLVM_COV_IGNORE_FILES) \
136175 --summary-only \
137176 --instr-profile="$(TMPDIR)"/$@.profdata \
138177 $(call BIN,"$(TMPDIR)"/$@) \
0 commit comments