Skip to content

Commit 9c357e6

Browse files
Lambdariszhuyunxing
authored andcommitted
coverage. Replace line numbers in mcdc reports with LL
1 parent 4713614 commit 9c357e6

File tree

2 files changed

+63
-31
lines changed

2 files changed

+63
-31
lines changed

src/tools/compiletest/src/runtest.rs

Lines changed: 37 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -277,11 +277,19 @@ impl<'test> TestCx<'test> {
277277
Ui | MirOpt => false,
278278
mode => panic!("unimplemented for mode {:?}", mode),
279279
};
280-
if test_should_run { self.run_if_enabled() } else { WillExecute::No }
280+
if test_should_run {
281+
self.run_if_enabled()
282+
} else {
283+
WillExecute::No
284+
}
281285
}
282286

283287
fn run_if_enabled(&self) -> WillExecute {
284-
if self.config.run_enabled() { WillExecute::Yes } else { WillExecute::Disabled }
288+
if self.config.run_enabled() {
289+
WillExecute::Yes
290+
} else {
291+
WillExecute::Disabled
292+
}
285293
}
286294

287295
fn should_run_successfully(&self, pm: Option<PassMode>) -> bool {
@@ -752,6 +760,18 @@ impl<'test> TestCx<'test> {
752760
Lazy::new(|| Regex::new(r"(?m:^)(?<prefix>(?: \|)+ Branch \()[0-9]+:").unwrap());
753761
let coverage = BRANCH_LINE_NUMBER_RE.replace_all(&coverage, "${prefix}LL:");
754762

763+
// ` |---> MC/DC Decision Region (1:` => ` |---> MC/DC Decision Region (LL:`
764+
static MCDC_DECISION_LINE_NUMBER_RE: Lazy<Regex> = Lazy::new(|| {
765+
Regex::new(r"(?m:^)(?<prefix>(?: \|)+---> MC/DC Decision Region \()[0-9]+:").unwrap()
766+
});
767+
let coverage = MCDC_DECISION_LINE_NUMBER_RE.replace_all(&coverage, "${prefix}LL:");
768+
769+
// ` | Condition C1 --> (1:` => ` | Condition C1 --> (LL:`
770+
static MCDC_CONDITION_LINE_NUMBER_RE: Lazy<Regex> = Lazy::new(|| {
771+
Regex::new(r"(?m:^)(?<prefix>(?: \|)+ Condition C\d+ --> \()[0-9]+:").unwrap()
772+
});
773+
let coverage = MCDC_CONDITION_LINE_NUMBER_RE.replace_all(&coverage, "${prefix}LL:");
774+
755775
coverage.into_owned()
756776
}
757777

@@ -2722,7 +2742,11 @@ impl<'test> TestCx<'test> {
27222742
/// The revision, ignored for incremental compilation since it wants all revisions in
27232743
/// the same directory.
27242744
fn safe_revision(&self) -> Option<&str> {
2725-
if self.config.mode == Incremental { None } else { self.revision }
2745+
if self.config.mode == Incremental {
2746+
None
2747+
} else {
2748+
self.revision
2749+
}
27262750
}
27272751

27282752
/// Gets the absolute path to the directory where all output for the given
@@ -2945,7 +2969,11 @@ impl<'test> TestCx<'test> {
29452969

29462970
fn charset() -> &'static str {
29472971
// FreeBSD 10.1 defaults to GDB 6.1.1 which doesn't support "auto" charset
2948-
if cfg!(target_os = "freebsd") { "ISO-8859-1" } else { "UTF-8" }
2972+
if cfg!(target_os = "freebsd") {
2973+
"ISO-8859-1"
2974+
} else {
2975+
"UTF-8"
2976+
}
29492977
}
29502978

29512979
fn run_rustdoc_test(&self) {
@@ -4747,7 +4775,11 @@ impl<'test> TestCx<'test> {
47474775
for output_file in files {
47484776
println!("Actual {} saved to {}", kind, output_file.display());
47494777
}
4750-
if self.config.bless { 0 } else { 1 }
4778+
if self.config.bless {
4779+
0
4780+
} else {
4781+
1
4782+
}
47514783
}
47524784

47534785
fn check_and_prune_duplicate_outputs(

tests/coverage/mcdc_if.coverage

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77
LL| 2| if a && b {
88
^0
99
------------------
10-
|---> MC/DC Decision Region (7:8) to (7:14)
10+
|---> MC/DC Decision Region (LL:8) to (7:14)
1111
|
1212
| Number of Conditions: 2
13-
| Condition C1 --> (7:8)
14-
| Condition C2 --> (7:13)
13+
| Condition C1 --> (LL:8)
14+
| Condition C2 --> (LL:13)
1515
|
1616
| Executed MC/DC Test Vectors:
1717
|
@@ -33,11 +33,11 @@
3333
LL| 2| if a && b {
3434
^1
3535
------------------
36-
|---> MC/DC Decision Region (15:8) to (15:14)
36+
|---> MC/DC Decision Region (LL:8) to (15:14)
3737
|
3838
| Number of Conditions: 2
39-
| Condition C1 --> (15:8)
40-
| Condition C2 --> (15:13)
39+
| Condition C1 --> (LL:8)
40+
| Condition C2 --> (LL:13)
4141
|
4242
| Executed MC/DC Test Vectors:
4343
|
@@ -59,11 +59,11 @@
5959
LL| 2|fn mcdc_check_b(a: bool, b: bool) {
6060
LL| 2| if a && b {
6161
------------------
62-
|---> MC/DC Decision Region (23:8) to (23:14)
62+
|---> MC/DC Decision Region (LL:8) to (23:14)
6363
|
6464
| Number of Conditions: 2
65-
| Condition C1 --> (23:8)
66-
| Condition C2 --> (23:13)
65+
| Condition C1 --> (LL:8)
66+
| Condition C2 --> (LL:13)
6767
|
6868
| Executed MC/DC Test Vectors:
6969
|
@@ -86,11 +86,11 @@
8686
LL| 3| if a && b {
8787
^2
8888
------------------
89-
|---> MC/DC Decision Region (31:8) to (31:14)
89+
|---> MC/DC Decision Region (LL:8) to (31:14)
9090
|
9191
| Number of Conditions: 2
92-
| Condition C1 --> (31:8)
93-
| Condition C2 --> (31:13)
92+
| Condition C1 --> (LL:8)
93+
| Condition C2 --> (LL:13)
9494
|
9595
| Executed MC/DC Test Vectors:
9696
|
@@ -116,12 +116,12 @@
116116
LL| 4| if a && (b || c) {
117117
^3 ^2
118118
------------------
119-
|---> MC/DC Decision Region (41:8) to (41:21)
119+
|---> MC/DC Decision Region (LL:8) to (41:21)
120120
|
121121
| Number of Conditions: 3
122-
| Condition C1 --> (41:8)
123-
| Condition C2 --> (41:14)
124-
| Condition C3 --> (41:19)
122+
| Condition C1 --> (LL:8)
123+
| Condition C2 --> (LL:14)
124+
| Condition C3 --> (LL:19)
125125
|
126126
| Executed MC/DC Test Vectors:
127127
|
@@ -149,12 +149,12 @@
149149
LL| 4| if (a || b) && c {
150150
^1
151151
------------------
152-
|---> MC/DC Decision Region (51:8) to (51:21)
152+
|---> MC/DC Decision Region (LL:8) to (51:21)
153153
|
154154
| Number of Conditions: 3
155-
| Condition C1 --> (51:9)
156-
| Condition C2 --> (51:14)
157-
| Condition C3 --> (51:20)
155+
| Condition C1 --> (LL:9)
156+
| Condition C2 --> (LL:14)
157+
| Condition C3 --> (LL:20)
158158
|
159159
| Executed MC/DC Test Vectors:
160160
|
@@ -179,11 +179,11 @@
179179
LL| 3| if a || b {
180180
^0
181181
------------------
182-
|---> MC/DC Decision Region (59:8) to (59:14)
182+
|---> MC/DC Decision Region (LL:8) to (59:14)
183183
|
184184
| Number of Conditions: 2
185-
| Condition C1 --> (59:8)
186-
| Condition C2 --> (59:13)
185+
| Condition C1 --> (LL:8)
186+
| Condition C2 --> (LL:13)
187187
|
188188
| Executed MC/DC Test Vectors:
189189
|
@@ -199,11 +199,11 @@
199199
LL| 3| if b && c {
200200
^2
201201
------------------
202-
|---> MC/DC Decision Region (61:12) to (61:18)
202+
|---> MC/DC Decision Region (LL:12) to (61:18)
203203
|
204204
| Number of Conditions: 2
205-
| Condition C1 --> (61:12)
206-
| Condition C2 --> (61:17)
205+
| Condition C1 --> (LL:12)
206+
| Condition C2 --> (LL:17)
207207
|
208208
| Executed MC/DC Test Vectors:
209209
|

0 commit comments

Comments
 (0)