Commit 4df656c
committed
tests: kdoc: improve comparison and output
Currently, the kdoc test fails when the number of lines of outout from
./scripts/kernel-doc increases. This is a decent heuristic but can fail in
some cases. For example, if a patch adds one warning but removes another,
the total line count may not change. This could result in false negatives
where some patches do not fail the test despite adding new warnings.
Upon detecting a difference in warning count, the test uses diff to compare
the old and new warnings. This output is not very useful to humans. The
diff comparison includes the line numbers which are impacted by code
movement, making relevant warnings difficult to spot when reviewing test
output.
An ideal kdoc test should determine the actual set of new warnings. To
achieve this, use the following algorithm:
1) Capture the kernel-doc output for the old commit
2) Capture the kernel-doc output for the new commit
3) Carefully join and sort output so that its stable w.r.t line number changes
4) Strip line numbers from the warning content for both old and new output
5) Diff the stripped output, using --*-group-format to just print line
number ranges.
6) Use the difference line ranges to print from the unstripped output,
generating a set of new and removed warnings.
By ensuring that the sorted input is stable even if line numbers change,
this correctly locates all of the new warnings, and additionally any
removed warnings, avoiding a false test pass.
In addition, the output is far more useful for humans as the output is 1)
just the new warnings, and doesn't contain diff syntax and 2) doesn't
contain warnings whose only change is the line number.
This is a bit more complicated, especially since it requires reading
through the input and sorting multiple times. However, the end result is
significantly more useful.
Signed-off-by: Jacob Keller <[email protected]>1 parent 1668e7a commit 4df656c
1 file changed
+69
-16
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
7 | 36 | | |
8 | 37 | | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
9 | 42 | | |
10 | 43 | | |
11 | 44 | | |
| |||
15 | 48 | | |
16 | 49 | | |
17 | 50 | | |
18 | | - | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
19 | 56 | | |
20 | 57 | | |
21 | 58 | | |
22 | 59 | | |
23 | 60 | | |
24 | 61 | | |
25 | | - | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
26 | 67 | | |
27 | 68 | | |
28 | 69 | | |
29 | | - | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
30 | 79 | | |
31 | | - | |
32 | | - | |
33 | | - | |
| 80 | + | |
34 | 81 | | |
35 | | - | |
36 | | - | |
37 | | - | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
38 | 92 | | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | | - | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
43 | 96 | | |
44 | | - | |
45 | | - | |
| 97 | + | |
| 98 | + | |
46 | 99 | | |
47 | 100 | | |
48 | 101 | | |
49 | 102 | | |
50 | | - | |
| 103 | + | |
51 | 104 | | |
52 | 105 | | |
0 commit comments