You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The current algorithm for the kdoc test is a simple line number comparison
of the output from ./scripts/kernel-doc. This is not guaranteed to be
accurate, as a patch could fix some warnings while introducing others,
resulting in the total number of lines not changing.
In addition, it is difficult to quickly determine which warnings are new.
Historically, a simple "diff" was used to compare the before and after
results. This was difficult to parse because line numbers change due to
code being added or moved.
To fix this, use a set difference algorithm which compares based on data
from the warning lines without including the line number.
To do this, introduce a KdocWarning dataclass, which represents a warning
based on its kind, file, line, and content. Extract these from the lines
via a regular expression that looks for the expected pattern of output from
./scripts/kernel-doc.
Using a @DataClass allows specifying which fields to compare against. In
particular, the line number is not counted. Additionally, the original
message as output from ./scripts/kernel-doc is preserved as its own
(non-compared) field.
Some warnings are spread over two lines, indicated by the first line ending
in a semicolon. Handle this when iterating over the output of kernel-doc
and converting to the new warning objects.
Any output line which doesn't match the regular expression is converted so
that its entire message becomes the contents. This ensures that such lines
still get counted and still get compared in some form, rather than silently
ignored.
After obtaining the converted output from ./scripts/kernel-doc, convert the
current_warnings and incumbent_warnings lists into sets.
Calculate the set of new and removed warnings by iterating the original
lists. For new_warnings, find the sequence of warnings which are in the
current_warnings but not in the incumbent set. Do the same to calculate the
set of removed warnings.
This implementation is fast, as it can use the hash-based comparisons
for efficient set lookup. Using the original list also preserves the order
of the warnings as output by ./scripts/kernel-doc.
Calculating both the new and removed counts provides useful data for users
of the NIPA tests. It is much easier to see at a glance what warnings were
added.
Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
0 commit comments