Skip to content

Commit

Permalink
A hash character at the beginning of Output line causes test to be ma…
Browse files Browse the repository at this point in the history
…rked as failed (#52)

* test: case for #52 without hash
* test: introduce # character to the output line
* fix: don’t fail test when there is a # in the JSON Output
  • Loading branch information
JackuB authored May 31, 2023
1 parent 9eae5ab commit b870aff
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 0 deletions.
27 changes: 27 additions & 0 deletions testdata/issue-52.parser.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"prefix": null,
"downloads": {
"packages": null,
"failed": false,
"reason": ""
},
"packages": [
{
"name": "code-intelligence.com/cifuzz/integration-tests/other",
"result": "",
"duration": "0s",
"coverage": null,
"output": "",
"testcases": [
{
"name": "TestIntegration_Other_RunCoverage",
"result": "FAIL",
"duration": "0s",
"coverage": null,
"output": "# The FUZZ_TEST_CXXFLAGS and FUZZ_TEST_LDFLAGS environment variables"
}
],
"reason": ""
}
]
}
13 changes: 13 additions & 0 deletions testdata/issue-52.tokenizer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[
{
"action": "stdout",
"package": "code-intelligence.com/cifuzz/integration-tests/other",
"version": "",
"test": "TestIntegration_Other_RunCoverage",
"elapsed": "0s",
"output": "IyBUaGUgRlVaWl9URVNUX0NYWEZMQUdTIGFuZCBGVVpaX1RFU1RfTERGTEFHUyBlbnZpcm9ubWVudCB2YXJpYWJsZXM=",
"cached": false,
"coverage": null,
"json": true
}
]
1 change: 1 addition & 0 deletions testdata/issue-52.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"Time":"2023-05-26T14:52:41.180732Z","Action":"output","Package":"code-intelligence.com/cifuzz/integration-tests/other","Test":"TestIntegration_Other_RunCoverage","Output":"# The FUZZ_TEST_CXXFLAGS and FUZZ_TEST_LDFLAGS environment variables\n"}
5 changes: 5 additions & 0 deletions tokenizer/tokenizer.go
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,11 @@ func parseLine(currentState state, line []byte, output chan<- Event) state {
continue
}

// Don't match the "package" action against a JSON lines - issue #52
if jsonLine != nil && stateTransition.action == ActionPackage {
continue
}

if match := stateTransition.regexp.FindSubmatch(line); len(match) != 0 {
elapsed, err := getTimeElapsed(stateTransition.regexp, match, "Elapsed")
if err == nil {
Expand Down

0 comments on commit b870aff

Please sign in to comment.