@@ -22,6 +22,43 @@ ifeq ($(LLVM_COV_DEBUG), 1)
22
22
DEBUG_FLAG =--debug
23
23
endif
24
24
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
+
25
62
# When generating `expected_*` results (using `x.py test --bless`), the `--debug` flag is forced.
26
63
# If assertions are disabled, the command will fail with an error, rather than attempt to generate
27
64
# only partial results.
76
113
# Generate a coverage report using `llvm-cov show`.
77
114
"$(LLVM_BIN_DIR)"/llvm-cov show \
78
115
$(DEBUG_FLAG) \
116
+ $(LLVM_COV_IGNORE_FILES) \
79
117
--Xdemangler="$(RUST_DEMANGLER)" \
80
118
--show-line-counts-or-regions \
81
119
--instr-profile="$(TMPDIR)"/
[email protected] \
@@ -133,6 +171,7 @@ endif
133
171
# Generate a coverage report in JSON, using `llvm-cov export`, and fail if
134
172
# there are differences from the expected output.
135
173
"$(LLVM_BIN_DIR)"/llvm-cov export \
174
+ $(LLVM_COV_IGNORE_FILES) \
136
175
--summary-only \
137
176
--instr-profile="$(TMPDIR)"/
[email protected] \
138
177
$(call BIN,"$(TMPDIR)"/$@) \
0 commit comments