test: move ignored line checking into a function

I will be reusing this logic, so moving it into a user-defined AWK
function will help with maintenance.

Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
This commit is contained in:
Patrick McCarty
2017-10-12 10:40:37 -07:00
committed by Matthew Johnson
parent 91b0bc818e
commit 00e6463652
+13 -4
View File
@@ -15,13 +15,22 @@ FILENAME ~ /ignore-list/ {
toignore[$0]++
}
# Checks if LINE matches any pattern in the "toignore" array. Returns the first
# matching pattern if true, 0 if false.
function is_ignored(line) {
for (pattern in toignore) {
if (line ~ pattern) {
return pattern
}
}
return 0
}
FILENAME ~ /lines-output/ {
# Skip to the next line if the current line matches any patterns from the
# global ignore list.
for (pattern in toignore) {
if ($0 ~ pattern) {
next
}
if (is_ignored($0)) {
next
}
# An output line may match a regular expression from lines-checked, which