From 892dbefe18b9cbf6393c9d0900cbedd90e44d492 Mon Sep 17 00:00:00 2001 From: Adrian Dombeck Date: Wed, 27 Nov 2024 16:09:51 +0100 Subject: [PATCH] Fix lines starting with ? being incorrectly interpreted These lines should only be interpreted as a package being skipped when it's not output from a test. There was no functionality yet to encode such a condition, so this commit adds a `precondition` function to the stateChange struct. --- testdata/issue-61.parser.json | 101 +++++++++++++++++++++++++++++++ testdata/issue-61.tokenizer.json | 101 +++++++++++++++++++++++++++++++ testdata/issue-61.txt | 16 +++++ tokenizer/tokenizer.go | 81 +++++++++++++++++++++++-- 4 files changed, 295 insertions(+), 4 deletions(-) create mode 100644 testdata/issue-61.parser.json create mode 100644 testdata/issue-61.tokenizer.json create mode 100644 testdata/issue-61.txt diff --git a/testdata/issue-61.parser.json b/testdata/issue-61.parser.json new file mode 100644 index 0000000..fa2cdf5 --- /dev/null +++ b/testdata/issue-61.parser.json @@ -0,0 +1,101 @@ +[ + { + "action": "run", + "package": "github.com/ubuntu/authd/pam/integration-tests", + "version": "", + "test": "TestNativeAuthenticate/Authenticate_user_with_qr_code_in_screen", + "elapsed": "0s", + "output": null, + "cached": false, + "coverage": null, + "json": true + }, + { + "action": "pause", + "package": "github.com/ubuntu/authd/pam/integration-tests", + "version": "", + "test": "TestNativeAuthenticate/Authenticate_user_with_qr_code_in_screen", + "elapsed": "0s", + "output": null, + "cached": false, + "coverage": null, + "json": true + }, + { + "action": "run", + "package": "github.com/ubuntu/authd/pam/integration-tests", + "version": "", + "test": "TestNativeAuthenticate/Deny_authentication_if_current_user_is_not_considered_as_root", + "elapsed": "0s", + "output": null, + "cached": false, + "coverage": null, + "json": true + }, + { + "action": "pause", + "package": "github.com/ubuntu/authd/pam/integration-tests", + "version": "", + "test": "TestNativeAuthenticate/Deny_authentication_if_current_user_is_not_considered_as_root", + "elapsed": "0s", + "output": null, + "cached": false, + "coverage": null, + "json": true + }, + { + "action": "cont", + "package": "github.com/ubuntu/authd/pam/integration-tests", + "version": "", + "test": "TestNativeAuthenticate/Deny_authentication_if_current_user_is_not_considered_as_root", + "elapsed": "0s", + "output": null, + "cached": false, + "coverage": null, + "json": true + }, + { + "action": "cont", + "package": "github.com/ubuntu/authd/pam/integration-tests", + "version": "", + "test": "TestNativeAuthenticate/Authenticate_user_with_qr_code_in_screen", + "elapsed": "0s", + "output": null, + "cached": false, + "coverage": null, + "json": true + }, + { + "action": "pass", + "package": "github.com/ubuntu/authd/pam/integration-tests", + "version": "", + "test": "TestNativeAuthenticate/Deny_authentication_if_current_user_is_not_considered_as_root", + "elapsed": "15.99s", + "output": null, + "cached": false, + "coverage": null, + "json": true + }, + { + "action": "stdout", + "package": "github.com/ubuntu/authd/pam/integration-tests", + "version": "", + "test": "TestNativeAuthenticate/Authenticate_user_with_qr_code_in_screen", + "elapsed": "0s", + "output": "PyAgPz8gICAgICAgID8/Pz8gICAgPz8gID8/Pz8/PyAgICAgICAgICAgICAgICA/Pz8/Pz8/Pz8/Pz9cbj8/Pz8/Pz8/Pz8/Pz8/Pz8/Pz8/Pz8/PyAgICA/Pz8/Pz8gICAgICA/PyAgICAgICAgPz8/Pz8/ICAgICAgICAgID8/Pz8/Pz8/XG4/Pz8/Pz8/PyAgICAgICAgICAgICAgPz8gID8/Pz8/PyAgICA/Pz8/ICA/PyAgICAgID8/ICA/PyAgICA/PyAgPz8/Pz8/Pz8/P1xuPz8/Pz8/Pz8gID8/Pz8/Pz8/Pz8gID8/ICA/Pz8/ICAgID8/Pz8/PyAgICA/Pz8/ICA/Pz8/Pz8gICAgPz8gID8/Pz8/Pz8/Pz9cbj8/Pz8/Pz8/ICA/PyAgICAgID8/ICA/Pz8/Pz8gICAgICA/PyAgICA/Pz8/Pz8/PyAgICAgICAgICA/PyAgICAgID8/Pz8/Pz8/XG4/Pz8/Pz8/PyAgPz8gICAgICA/PyAgPz8gICAgPz8/Pz8/Pz8gID8/ICAgID8/Pz8/PyAgPz8gICAgICA/PyAgPz8/Pz8/Pz8/P1xuPz8/Pz8/Pz8gID8/ICAgICAgPz8gID8/ICAgID8/ICA/Pz8/ICAgICAgPz8/PyAgPz8/Pz8/ICA/Pz8/ICA/PyAgPz8/Pz8/Pz9cbj8/Pz8/Pz8/ICA/Pz8/Pz8/Pz8/ICA/Pz8/ICAgID8/Pz8/PyAgPz8gID8/Pz8gICAgPz8gICAgICAgID8/ICA/Pz8/Pz8/Pz8/XG4/Pz8/Pz8/PyAgICAgICAgICAgICAgPz8gICAgPz8gICAgPz8gICAgICAgID8/ICAgICAgICA/Pz8/ICA/PyAgPz8/Pz8/Pz8/P1xuPz8/Pz8/Pz8/Pz8/Pz8/Pz8/Pz8/Pz8/Pz8/Pz8/Pz8/Pz8/Pz8/Pz8/Pz8/Pz8/Pz8/Pz8/Pz8/Pz8/Pz8/Pz8/Pz8/Pz8/Pz9cbj8/Pz8/Pz8/Pz8/Pz8/Pz8/Pz8/Pz8/Pz8/Pz8/Pz8/Pz8/Pz8/Pz8/Pz8/Pz8/Pz8/Pz8/Pz8/Pz8/Pz8/Pz8/Pz8/Pz8/Pz8/XG4/Pz8/Pz8/Pz8/Pz8/Pz8/Pz8/Pz8/Pz8/Pz8/Pz8/Pz8/Pz8/Pz8/Pz8/Pz8/Pz8/Pz8/Pz8/Pz8/Pz8/Pz8/Pz8/Pz8/Pz8/P1xuPz8/Pz8/Pz8/Pz8/Pz8/Pz8/Pz8/Pz8/Pz8/Pz8/Pz8/Pz8/Pz8/Pz8/Pz8/Pz8/Pz8/Pz8/Pz8/Pz8/Pz8/Pz8/Pz8/Pz8/Pz9cbiAgICAgICAgICAgICAgICAgICAgICAgaHR0cHM6Ly91YnVudHVmb3J1bS1ici5vcmcvIA==", + "cached": false, + "coverage": null, + "json": true + }, + { + "action": "pass", + "package": "github.com/ubuntu/authd/pam/integration-tests", + "version": "", + "test": "TestNativeAuthenticate/Authenticate_user_with_qr_code_in_screen", + "elapsed": "51.42s", + "output": null, + "cached": false, + "coverage": null, + "json": true + } +] diff --git a/testdata/issue-61.tokenizer.json b/testdata/issue-61.tokenizer.json new file mode 100644 index 0000000..fa2cdf5 --- /dev/null +++ b/testdata/issue-61.tokenizer.json @@ -0,0 +1,101 @@ +[ + { + "action": "run", + "package": "github.com/ubuntu/authd/pam/integration-tests", + "version": "", + "test": "TestNativeAuthenticate/Authenticate_user_with_qr_code_in_screen", + "elapsed": "0s", + "output": null, + "cached": false, + "coverage": null, + "json": true + }, + { + "action": "pause", + "package": "github.com/ubuntu/authd/pam/integration-tests", + "version": "", + "test": "TestNativeAuthenticate/Authenticate_user_with_qr_code_in_screen", + "elapsed": "0s", + "output": null, + "cached": false, + "coverage": null, + "json": true + }, + { + "action": "run", + "package": "github.com/ubuntu/authd/pam/integration-tests", + "version": "", + "test": "TestNativeAuthenticate/Deny_authentication_if_current_user_is_not_considered_as_root", + "elapsed": "0s", + "output": null, + "cached": false, + "coverage": null, + "json": true + }, + { + "action": "pause", + "package": "github.com/ubuntu/authd/pam/integration-tests", + "version": "", + "test": "TestNativeAuthenticate/Deny_authentication_if_current_user_is_not_considered_as_root", + "elapsed": "0s", + "output": null, + "cached": false, + "coverage": null, + "json": true + }, + { + "action": "cont", + "package": "github.com/ubuntu/authd/pam/integration-tests", + "version": "", + "test": "TestNativeAuthenticate/Deny_authentication_if_current_user_is_not_considered_as_root", + "elapsed": "0s", + "output": null, + "cached": false, + "coverage": null, + "json": true + }, + { + "action": "cont", + "package": "github.com/ubuntu/authd/pam/integration-tests", + "version": "", + "test": "TestNativeAuthenticate/Authenticate_user_with_qr_code_in_screen", + "elapsed": "0s", + "output": null, + "cached": false, + "coverage": null, + "json": true + }, + { + "action": "pass", + "package": "github.com/ubuntu/authd/pam/integration-tests", + "version": "", + "test": "TestNativeAuthenticate/Deny_authentication_if_current_user_is_not_considered_as_root", + "elapsed": "15.99s", + "output": null, + "cached": false, + "coverage": null, + "json": true + }, + { + "action": "stdout", + "package": "github.com/ubuntu/authd/pam/integration-tests", + "version": "", + "test": "TestNativeAuthenticate/Authenticate_user_with_qr_code_in_screen", + "elapsed": "0s", + "output": "PyAgPz8gICAgICAgID8/Pz8gICAgPz8gID8/Pz8/PyAgICAgICAgICAgICAgICA/Pz8/Pz8/Pz8/Pz9cbj8/Pz8/Pz8/Pz8/Pz8/Pz8/Pz8/Pz8/PyAgICA/Pz8/Pz8gICAgICA/PyAgICAgICAgPz8/Pz8/ICAgICAgICAgID8/Pz8/Pz8/XG4/Pz8/Pz8/PyAgICAgICAgICAgICAgPz8gID8/Pz8/PyAgICA/Pz8/ICA/PyAgICAgID8/ICA/PyAgICA/PyAgPz8/Pz8/Pz8/P1xuPz8/Pz8/Pz8gID8/Pz8/Pz8/Pz8gID8/ICA/Pz8/ICAgID8/Pz8/PyAgICA/Pz8/ICA/Pz8/Pz8gICAgPz8gID8/Pz8/Pz8/Pz9cbj8/Pz8/Pz8/ICA/PyAgICAgID8/ICA/Pz8/Pz8gICAgICA/PyAgICA/Pz8/Pz8/PyAgICAgICAgICA/PyAgICAgID8/Pz8/Pz8/XG4/Pz8/Pz8/PyAgPz8gICAgICA/PyAgPz8gICAgPz8/Pz8/Pz8gID8/ICAgID8/Pz8/PyAgPz8gICAgICA/PyAgPz8/Pz8/Pz8/P1xuPz8/Pz8/Pz8gID8/ICAgICAgPz8gID8/ICAgID8/ICA/Pz8/ICAgICAgPz8/PyAgPz8/Pz8/ICA/Pz8/ICA/PyAgPz8/Pz8/Pz9cbj8/Pz8/Pz8/ICA/Pz8/Pz8/Pz8/ICA/Pz8/ICAgID8/Pz8/PyAgPz8gID8/Pz8gICAgPz8gICAgICAgID8/ICA/Pz8/Pz8/Pz8/XG4/Pz8/Pz8/PyAgICAgICAgICAgICAgPz8gICAgPz8gICAgPz8gICAgICAgID8/ICAgICAgICA/Pz8/ICA/PyAgPz8/Pz8/Pz8/P1xuPz8/Pz8/Pz8/Pz8/Pz8/Pz8/Pz8/Pz8/Pz8/Pz8/Pz8/Pz8/Pz8/Pz8/Pz8/Pz8/Pz8/Pz8/Pz8/Pz8/Pz8/Pz8/Pz8/Pz8/Pz9cbj8/Pz8/Pz8/Pz8/Pz8/Pz8/Pz8/Pz8/Pz8/Pz8/Pz8/Pz8/Pz8/Pz8/Pz8/Pz8/Pz8/Pz8/Pz8/Pz8/Pz8/Pz8/Pz8/Pz8/Pz8/XG4/Pz8/Pz8/Pz8/Pz8/Pz8/Pz8/Pz8/Pz8/Pz8/Pz8/Pz8/Pz8/Pz8/Pz8/Pz8/Pz8/Pz8/Pz8/Pz8/Pz8/Pz8/Pz8/Pz8/Pz8/P1xuPz8/Pz8/Pz8/Pz8/Pz8/Pz8/Pz8/Pz8/Pz8/Pz8/Pz8/Pz8/Pz8/Pz8/Pz8/Pz8/Pz8/Pz8/Pz8/Pz8/Pz8/Pz8/Pz8/Pz8/Pz9cbiAgICAgICAgICAgICAgICAgICAgICAgaHR0cHM6Ly91YnVudHVmb3J1bS1ici5vcmcvIA==", + "cached": false, + "coverage": null, + "json": true + }, + { + "action": "pass", + "package": "github.com/ubuntu/authd/pam/integration-tests", + "version": "", + "test": "TestNativeAuthenticate/Authenticate_user_with_qr_code_in_screen", + "elapsed": "51.42s", + "output": null, + "cached": false, + "coverage": null, + "json": true + } +] diff --git a/testdata/issue-61.txt b/testdata/issue-61.txt new file mode 100644 index 0000000..ecb7606 --- /dev/null +++ b/testdata/issue-61.txt @@ -0,0 +1,16 @@ +{"Time":"2024-11-27T11:45:46.804362634Z","Action":"run","Package":"github.com/ubuntu/authd/pam/integration-tests","Test":"TestNativeAuthenticate/Authenticate_user_switching_auth_mode"} +{"Time":"2024-11-27T11:45:46.80435001Z","Action":"output","Package":"github.com/ubuntu/authd/pam/integration-tests","Test":"TestNativeAuthenticate/Authenticate_user_with_qr_code_in_screen","Output":"=== RUN TestNativeAuthenticate/Authenticate_user_with_qr_code_in_screen\n"} +{"Time":"2024-11-27T11:45:46.804354558Z","Action":"output","Package":"github.com/ubuntu/authd/pam/integration-tests","Test":"TestNativeAuthenticate/Authenticate_user_with_qr_code_in_screen","Output":"=== PAUSE TestNativeAuthenticate/Authenticate_user_with_qr_code_in_screen\n"} +{"Time":"2024-11-27T11:45:46.804358115Z","Action":"pause","Package":"github.com/ubuntu/authd/pam/integration-tests","Test":"TestNativeAuthenticate/Authenticate_user_with_qr_code_in_screen"} +{"Time":"2024-11-27T11:45:46.804378243Z","Action":"run","Package":"github.com/ubuntu/authd/pam/integration-tests","Test":"TestNativeAuthenticate/Deny_authentication_if_current_user_is_not_considered_as_root"} +{"Time":"2024-11-27T11:45:46.80438219Z","Action":"output","Package":"github.com/ubuntu/authd/pam/integration-tests","Test":"TestNativeAuthenticate/Deny_authentication_if_current_user_is_not_considered_as_root","Output":"=== RUN TestNativeAuthenticate/Deny_authentication_if_current_user_is_not_considered_as_root\n"} +{"Time":"2024-11-27T11:45:46.804386949Z","Action":"output","Package":"github.com/ubuntu/authd/pam/integration-tests","Test":"TestNativeAuthenticate/Deny_authentication_if_current_user_is_not_considered_as_root","Output":"=== PAUSE TestNativeAuthenticate/Deny_authentication_if_current_user_is_not_considered_as_root\n"} +{"Time":"2024-11-27T11:45:46.804373875Z","Action":"pause","Package":"github.com/ubuntu/authd/pam/integration-tests","Test":"TestNativeAuthenticate/Authenticate_user_switching_auth_mode"} +{"Time":"2024-11-27T12:03:23.32968147Z","Action":"cont","Package":"github.com/ubuntu/authd/pam/integration-tests","Test":"TestNativeAuthenticate/Deny_authentication_if_current_user_is_not_considered_as_root"} +{"Time":"2024-11-27T12:03:23.329687401Z","Action":"output","Package":"github.com/ubuntu/authd/pam/integration-tests","Test":"TestNativeAuthenticate/Deny_authentication_if_current_user_is_not_considered_as_root","Output":"=== CONT TestNativeAuthenticate/Deny_authentication_if_current_user_is_not_considered_as_root\n"} +{"Time":"2024-11-27T12:03:39.189892471Z","Action":"cont","Package":"github.com/ubuntu/authd/pam/integration-tests","Test":"TestNativeAuthenticate/Authenticate_user_with_qr_code_in_screen"} +{"Time":"2024-11-27T12:03:39.189896689Z","Action":"output","Package":"github.com/ubuntu/authd/pam/integration-tests","Test":"TestNativeAuthenticate/Authenticate_user_with_qr_code_in_screen","Output":"=== CONT TestNativeAuthenticate/Authenticate_user_with_qr_code_in_screen\n"} +{"Time":"2024-11-27T12:03:39.319245395Z","Action":"output","Package":"github.com/ubuntu/authd/pam/integration-tests","Test":"TestNativeAuthenticate/Deny_authentication_if_current_user_is_not_considered_as_root","Output":"--- PASS: TestNativeAuthenticate/Deny_authentication_if_current_user_is_not_considered_as_root (15.99s)\n"} +{"Time":"2024-11-27T12:04:30.610470288Z","Action":"output","Package":"github.com/ubuntu/authd/pam/integration-tests","Test":"TestNativeAuthenticate/Authenticate_user_with_qr_code_in_screen","Output":"? ?? ???? ?? ?????? ????????????\\n???????????????????????? ?????? ?? ?????? ????????\\n???????? ?? ?????? ???? ?? ?? ?? ?? ??????????\\n???????? ?????????? ?? ???? ?????? ???? ?????? ?? ??????????\\n???????? ?? ?? ?????? ?? ???????? ?? ????????\\n???????? ?? ?? ?? ???????? ?? ?????? ?? ?? ??????????\\n???????? ?? ?? ?? ?? ???? ???? ?????? ???? ?? ????????\\n???????? ?????????? ???? ?????? ?? ???? ?? ?? ??????????\\n???????? ?? ?? ?? ?? ???? ?? ??????????\\n??????????????????????????????????????????????????????????????????????????\\n??????????????????????????????????????????????????????????????????????????\\n??????????????????????????????????????????????????????????????????????????\\n??????????????????????????????????????????????????????????????????????????\\n https://ubuntuforum-br.org/ "} +{"Time":"2024-11-27T12:04:30.611060693Z","Action":"output","Package":"github.com/ubuntu/authd/pam/integration-tests","Test":"TestNativeAuthenticate/Authenticate_user_with_qr_code_in_screen","Output":"--- PASS: TestNativeAuthenticate/Authenticate_user_with_qr_code_in_screen (51.42s)\n"} +{"Time":"2024-11-27T12:04:31.618971235Z","Action":"pass","Package":"github.com/ubuntu/authd/pam/integration-tests","Test":"TestNativeAuthenticate/Authenticate_user_with_qr_code_in_screen","Elapsed":51.42} \ No newline at end of file diff --git a/tokenizer/tokenizer.go b/tokenizer/tokenizer.go index 22fc61f..80751d1 100644 --- a/tokenizer/tokenizer.go +++ b/tokenizer/tokenizer.go @@ -29,10 +29,11 @@ const ( ) type stateChange struct { - regexp *regexp.Regexp - inputState state - action Action - newState state + regexp *regexp.Regexp + inputState state + action Action + newState state + precondition func(jsonLine *jsonTestEvent) bool } var stateMachine = []stateChange{ @@ -41,324 +42,392 @@ var stateMachine = []stateChange{ stateInit, ActionDownload, stateInit, + nil, }, { regexp.MustCompile(`^go: (?P[^@]+)@(?P[^:]+): (?P.*)`), stateInit, ActionDownloadFailed, stateInit, + nil, }, { regexp.MustCompile(`^# (?P.*)$`), stateInit, ActionPackage, stateBetweenTests, + nil, }, { regexp.MustCompile(`^# (?P.*)$`), stateBetweenTests, ActionPackage, stateBetweenTests, + nil, }, { regexp.MustCompile(`^=== RUN\s+(?P.*)$`), stateInit, ActionRun, stateRun, + nil, }, { regexp.MustCompile(`^=== RUN\s+(?P.*)$`), stateBetweenTests, ActionRun, stateRun, + nil, }, { regexp.MustCompile(`^=== RUN\s+(?P.*)$`), stateRun, ActionRun, stateRun, + nil, }, { regexp.MustCompile(`^=== RUN\s+(?P.*)$`), stateBetweenTests, ActionRun, stateRun, + nil, }, { regexp.MustCompile(`^=== PAUSE\s+(?P.*)$`), stateRun, ActionPause, stateBetweenTests, + nil, }, { regexp.MustCompile(`^=== PAUSE\s+(?P.*)$`), stateBetweenTests, ActionPause, stateBetweenTests, + nil, }, { regexp.MustCompile(`^=== CONT\s+(?P.*)$`), stateBetweenTests, ActionCont, stateRun, + nil, }, { regexp.MustCompile(`^=== CONT\s+(?P.*)$`), stateRun, ActionCont, stateRun, + nil, }, { regexp.MustCompile(`^\s*--- FAIL:\s+(?P[^\s]+) \(((?Pcached)|(?P[^\s]*))\)$`), stateInit, ActionFail, stateBetweenTests, + nil, }, { regexp.MustCompile(`^\s*--- FAIL:\s+(?P[^\s]+) \(((?Pcached)|(?P[^\s]*))\)$`), stateRun, ActionFail, stateBetweenTests, + nil, }, { regexp.MustCompile(`^\s*--- FAIL:\s+(?P[^\s]+) \(((?Pcached)|(?P[^\s]*))\)$`), stateBetweenTests, ActionFail, stateBetweenTests, + nil, }, { regexp.MustCompile(`^\s*--- PASS:\s+(?P[^\s]+) \(((?Pcached)|(?P[^\s]*))\)$`), stateInit, ActionPass, stateBetweenTests, + nil, }, { regexp.MustCompile(`^\s*--- PASS:\s+(?P[^\s]+) \(((?Pcached)|(?P[^\s]*))\)$`), stateRun, ActionPass, stateBetweenTests, + nil, }, { regexp.MustCompile(`^\s*--- PASS:\s+(?P[^\s]+) \(((?Pcached)|(?P[^\s]*))\)$`), stateBetweenTests, ActionPass, stateBetweenTests, + nil, }, { regexp.MustCompile(`^\s*--- SKIP:\s+(?P[^\s]+) \(((?Pcached)|(?P[^\s]*))\)$`), stateRun, ActionSkip, stateBetweenTests, + nil, }, { regexp.MustCompile(`^\s*--- SKIP:\s+(?P[^\s]+) \(((?Pcached)|(?P[^\s]*))\)$`), stateBetweenTests, ActionSkip, stateBetweenTests, + nil, }, { regexp.MustCompile(`^ok\s+(?P[^\s]+)\s+(\((?Pcached)\)|(?P[^\s]*))(|([\s]+)coverage: ((?P.*)% of statements|\[no statements]))$`), stateRun, ActionPass, stateRun, + nil, }, { regexp.MustCompile(`^ok\s+(?P[^\s]+)\s+(\((?Pcached)\)|(?P[^\s]*))(|([\s]+)coverage: ((?P.*)% of statements|\[no statements]))$`), stateInit, ActionPass, stateBetweenTests, + nil, }, { regexp.MustCompile(`^ok\s+(?P[^\s]+)\s+(\((?Pcached)\)|(?P[^\s]*))(|\s+coverage: ((?P.*)% of statements|\[no statements]))$`), stateBetweenTests, ActionPass, stateBetweenTests, + nil, + }, + { + regexp.MustCompile(`^ok\s+(?P[^\s]+)\s+(\((?Pcached)\)|(?P[^\s]*))(|\s+coverage: ((?P.*)% of statements|\[no statements]))$`), + stateBetweenTests, + ActionPass, + stateBetweenTests, + nil, }, { regexp.MustCompile(`^\?\s+(?P[^\s]+)\s+\[(?P.*)]$`), stateInit, ActionSkip, stateBetweenTests, + func(jsonLine *jsonTestEvent) bool { return jsonLine == nil || jsonLine.Test == "" }, }, { regexp.MustCompile(`^\?\s+(?P[^\s]+)\s+\[(?P.*)]$`), stateBetweenTests, ActionSkip, stateBetweenTests, + func(jsonLine *jsonTestEvent) bool { return jsonLine == nil || jsonLine.Test == "" }, }, { regexp.MustCompile(`^\?\s+(?P[^\s]+)\s+\[(?P.*)]$`), stateRun, ActionSkip, stateRun, + func(jsonLine *jsonTestEvent) bool { return jsonLine == nil || jsonLine.Test == "" }, }, { regexp.MustCompile(`^\?\s+(?P[^\s]+)\s+(?P.*)$`), stateInit, ActionSkip, stateBetweenTests, + func(jsonLine *jsonTestEvent) bool { return jsonLine == nil || jsonLine.Test == "" }, }, { regexp.MustCompile(`^\?\s+(?P[^\s]+)\s+(?P.*)$`), stateBetweenTests, ActionSkip, stateBetweenTests, + func(jsonLine *jsonTestEvent) bool { return jsonLine == nil || jsonLine.Test == "" }, }, { regexp.MustCompile(`^FAIL\s+(?P[^\s]+)\s+\((?P[^\s]*)\)$`), stateInit, ActionFail, stateBetweenTests, + nil, }, { regexp.MustCompile(`^FAIL\s+(?P[^\s]+)\s+(?P[^\s]*)$`), stateRun, ActionFail, stateBetweenTests, + nil, }, { regexp.MustCompile(`^FAIL\s+(?P[^\s]+)\s+(?P[^\s]*)$`), stateBetweenTests, ActionFail, stateBetweenTests, + nil, }, { regexp.MustCompile(`^FAIL\s+(?P[^\s]+)\s+\[(?P.*)]$`), stateBetweenTests, ActionFail, stateBetweenTests, + nil, }, { regexp.MustCompile(`^PASS\s+(?P[^\s]+)\s+\(((?P[0-9.smh]+)|(?Pcached))\)$`), stateInit, ActionPass, stateBetweenTests, + nil, }, { regexp.MustCompile(`^PASS\s+(?P[^\s]+)\s+\(((?P[0-9.smh]+)|(?Pcached))\)$`), stateRun, ActionPass, stateBetweenTests, + nil, }, { regexp.MustCompile(`^PASS\s+(?P[^\s]+)\s+\(((?P[^\s]*)|(?Pcached))\)$`), stateBetweenTests, ActionPass, stateBetweenTests, + nil, }, { regexp.MustCompile(`^SKIP\s+(?P[^\s]+)\s+\(((?P[^\s]*)|(?Pcached))\)$`), stateInit, ActionSkip, stateBetweenTests, + nil, }, { regexp.MustCompile(`^SKIP\s+(?P[^\s]+)\s+\(((?P[^\s]*)|(?Pcached))\)$`), stateRun, ActionSkip, stateBetweenTests, + nil, }, { regexp.MustCompile(`^SKIP\s+(?P[^\s]+)\s+\(((?P[^\s]*)|(?Pcached))\)$`), stateBetweenTests, ActionSkip, stateBetweenTests, + nil, }, { regexp.MustCompile(`^FAIL$`), stateInit, ActionFailFinal, stateBetweenTests, + nil, }, { regexp.MustCompile(`^FAIL$`), stateRun, ActionFailFinal, stateBetweenTests, + nil, }, { regexp.MustCompile(`^FAIL$`), stateBetweenTests, ActionFailFinal, stateBetweenTests, + nil, }, { regexp.MustCompile(`^PASS$`), stateInit, ActionPassFinal, stateBetweenTests, + nil, }, { regexp.MustCompile(`^PASS$`), stateRun, ActionPassFinal, stateBetweenTests, + nil, }, { regexp.MustCompile(`^PASS$`), stateBetweenTests, ActionPassFinal, stateBetweenTests, + nil, }, { regexp.MustCompile(`^SKIP$`), stateInit, ActionSkipFinal, stateBetweenTests, + nil, }, { regexp.MustCompile(`^SKIP$`), stateRun, ActionSkipFinal, stateBetweenTests, + nil, }, { regexp.MustCompile(`^SKIP$`), stateBetweenTests, ActionSkipFinal, stateBetweenTests, + nil, }, { regexp.MustCompile(`^coverage: (?P.*)% of statements$`), stateBetweenTests, ActionCoverage, stateBetweenTests, + nil, }, { regexp.MustCompile(`^coverage: (?P.*)% of statements$`), stateRun, ActionCoverage, stateRun, + nil, + }, + { + regexp.MustCompile(`^coverage: (?P.*)% of statements$`), + stateInit, + ActionCoverage, + stateInit, + nil, }, { regexp.MustCompile(`^coverage: \[no statements]$`), stateBetweenTests, ActionCoverageNoStatements, stateBetweenTests, + nil, }, { regexp.MustCompile(`^coverage: \[no statements]$`), stateRun, ActionCoverageNoStatements, stateRun, + nil, }, { regexp.MustCompile(`^(?P.*)$`), stateInit, ActionStdout, stateBetweenTests, + nil, }, { regexp.MustCompile(`^(?P.*)$`), stateBetweenTests, ActionStdout, stateBetweenTests, + nil, }, { regexp.MustCompile(`^(?P.*)$`), stateRun, ActionStdout, stateRun, + nil, }, } @@ -423,6 +492,10 @@ func parseLine(currentState state, line []byte, output chan<- Event) state { continue } + if stateTransition.precondition != nil && !stateTransition.precondition(jsonLine) { + continue + } + if match := stateTransition.regexp.FindSubmatch(line); len(match) != 0 { elapsed, err := getTimeElapsed(stateTransition.regexp, match, "Elapsed") if err == nil {