Skip to content

Commit

Permalink
Merge pull request #114 from dorny/issue-113-print-breaks-dart-parsing
Browse files Browse the repository at this point in the history
Fix dart-json parsing broken by print message
  • Loading branch information
dorny committed May 13, 2021
2 parents cbdb218 + f88270a commit e873f73
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 11 deletions.
1 change: 1 addition & 0 deletions __tests__/fixtures/dart-json.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
{"suite":{"id":2,"platform":"vm","path":"test\\second_test.dart"},"type":"suite","time":11}
{"test":{"id":3,"name":"loading test\\second_test.dart","suiteID":2,"groupIDs":[],"metadata":{"skip":false,"skipReason":null},"line":null,"column":null,"url":null},"type":"testStart","time":11}
{"count":2,"type":"allSuites","time":11}
{"testID":1,"messageType":"print","message":"Hello from the test","type":"print","time":3828}
{"testID":3,"result":"success","skipped":false,"hidden":true,"type":"testDone","time":3649}
{"group":{"id":4,"suiteID":2,"parentID":null,"name":null,"metadata":{"skip":false,"skipReason":null},"testCount":2,"line":null,"column":null,"url":null},"type":"group","time":3654}
{"test":{"id":5,"name":"Timeout test","suiteID":2,"groupIDs":[4],"metadata":{"skip":false,"skipReason":null},"line":5,"column":3,"url":"file:///C:/Users/Michal/Workspace/dorny/test-check/reports/dart/test/second_test.dart"},"type":"testStart","time":3655}
Expand Down
14 changes: 7 additions & 7 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions reports/dart/test/main_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,6 @@ void main() {
throw Exception('Some error');
});
});

print('Hello from the test');
}
6 changes: 3 additions & 3 deletions src/parsers/dart-json/dart-json-parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,11 @@ export class DartJsonParser implements TestParser {
const group = suite.groups[evt.test.groupIDs[evt.test.groupIDs.length - 1]]
group.tests.push(test)
tests[evt.test.id] = test
} else if (isTestDoneEvent(evt) && !evt.hidden) {
} else if (isTestDoneEvent(evt) && !evt.hidden && tests[evt.testID]) {
tests[evt.testID].testDone = evt
} else if (isErrorEvent(evt)) {
} else if (isErrorEvent(evt) && tests[evt.testID]) {
tests[evt.testID].error = evt
} else if (isMessageEvent(evt)) {
} else if (isMessageEvent(evt) && tests[evt.testID]) {
tests[evt.testID].print.push(evt)
} else if (isDoneEvent(evt)) {
success = evt.success
Expand Down

0 comments on commit e873f73

Please sign in to comment.