From 00e6463652f9d24ea12e681a3c3f4982739b18ee Mon Sep 17 00:00:00 2001 From: Patrick McCarty Date: Fri, 6 Oct 2017 14:43:59 -0700 Subject: [PATCH] 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 --- test/functional/matcher.awk | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/test/functional/matcher.awk b/test/functional/matcher.awk index b9bdc1d9..f9b43714 100644 --- a/test/functional/matcher.awk +++ b/test/functional/matcher.awk @@ -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