From a26c5eaf39271729548ae4cc83377787ab9f83e7 Mon Sep 17 00:00:00 2001 From: dominicmh Date: Fri, 12 Apr 2024 21:25:30 +0200 Subject: [PATCH 1/3] make test fail by adding setUpAll and tearDownAll --- __tests__/fixtures/empty/dart-json.json | 24 +- reports/dart/pubspec.lock | 279 +++++++++++++----------- reports/dart/pubspec.yaml | 2 +- 3 files changed, 172 insertions(+), 133 deletions(-) diff --git a/__tests__/fixtures/empty/dart-json.json b/__tests__/fixtures/empty/dart-json.json index 4f3a23ef..e47cf112 100644 --- a/__tests__/fixtures/empty/dart-json.json +++ b/__tests__/fixtures/empty/dart-json.json @@ -1,9 +1,15 @@ -{"protocolVersion":"0.1.1","runnerVersion":"1.15.4","pid":21320,"type":"start","time":0} -{"suite":{"id":0,"platform":"vm","path":"test\\main_test.dart"},"type":"suite","time":0} -{"test":{"id":1,"name":"loading test\\main_test.dart","suiteID":0,"groupIDs":[],"metadata":{"skip":false,"skipReason":null},"line":null,"column":null,"url":null},"type":"testStart","time":1} -{"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,"result":"success","skipped":false,"hidden":true,"type":"testDone","time":4018} -{"testID":3,"result":"success","skipped":false,"hidden":true,"type":"testDone","time":4025} -{"success":true,"type":"done","time":4029} +{"protocolVersion":"0.1.1","runnerVersion":"1.25.3","pid":7103,"type":"start","time":0} +{"suite":{"id":0,"platform":"vm","path":"test/second_test.dart"},"type":"suite","time":0} +{"test":{"id":1,"name":"loading test/second_test.dart","suiteID":0,"groupIDs":[],"metadata":{"skip":false,"skipReason":null},"line":null,"column":null,"url":null},"type":"testStart","time":0} +{"suite":{"id":2,"platform":"vm","path":"test/main_test.dart"},"type":"suite","time":4} +{"test":{"id":3,"name":"loading test/main_test.dart","suiteID":2,"groupIDs":[],"metadata":{"skip":false,"skipReason":null},"line":null,"column":null,"url":null},"type":"testStart","time":4} +{"count":2,"time":5,"type":"allSuites"} +{"testID":1,"result":"success","skipped":false,"hidden":true,"type":"testDone","time":294} +{"testID":3,"messageType":"print","message":"Hello from the test","type":"print","time":297} +{"testID":3,"result":"success","skipped":false,"hidden":true,"type":"testDone","time":321} +{"group":{"id":4,"suiteID":2,"parentID":null,"name":"","metadata":{"skip":false,"skipReason":null},"testCount":0,"line":null,"column":null,"url":null},"type":"group","time":322} +{"test":{"id":5,"name":"(setUpAll)","suiteID":2,"groupIDs":[4],"metadata":{"skip":false,"skipReason":null},"line":6,"column":3,"url":"file:///Users/domu/Downloads/test-reporter/reports/dart/test/main_test.dart"},"type":"testStart","time":322} +{"testID":5,"result":"success","skipped":false,"hidden":true,"type":"testDone","time":330} +{"test":{"id":6,"name":"(tearDownAll)","suiteID":2,"groupIDs":[4],"metadata":{"skip":false,"skipReason":null},"line":7,"column":3,"url":"file:///Users/domu/Downloads/test-reporter/reports/dart/test/main_test.dart"},"type":"testStart","time":330} +{"testID":6,"result":"success","skipped":false,"hidden":true,"type":"testDone","time":331} +{"success":true,"type":"done","time":333} diff --git a/reports/dart/pubspec.lock b/reports/dart/pubspec.lock index 882993d5..f21dc879 100644 --- a/reports/dart/pubspec.lock +++ b/reports/dart/pubspec.lock @@ -5,344 +5,377 @@ packages: dependency: transitive description: name: _fe_analyzer_shared - url: "https://pub.dartlang.org" + sha256: "0b2f2bd91ba804e53a61d757b986f89f1f9eaed5b11e4b2f5a2468d86d6c9fc7" + url: "https://pub.dev" source: hosted - version: "11.0.0" + version: "67.0.0" analyzer: dependency: transitive description: name: analyzer - url: "https://pub.dartlang.org" + sha256: "37577842a27e4338429a1cbc32679d508836510b056f1eedf0c8d20e39c1383d" + url: "https://pub.dev" source: hosted - version: "0.40.4" + version: "6.4.1" args: dependency: transitive description: name: args - url: "https://pub.dartlang.org" + sha256: "7cf60b9f0cc88203c5a190b4cd62a99feea42759a7fa695010eb5de1c0b2252a" + url: "https://pub.dev" source: hosted - version: "1.6.0" + version: "2.5.0" async: dependency: transitive description: name: async - url: "https://pub.dartlang.org" + sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c" + url: "https://pub.dev" source: hosted - version: "2.4.2" + version: "2.11.0" boolean_selector: dependency: transitive description: name: boolean_selector - url: "https://pub.dartlang.org" + sha256: "6cfb5af12253eaf2b368f07bacc5a80d1301a071c73360d746b7f2e32d762c66" + url: "https://pub.dev" source: hosted - version: "2.0.0" - charcode: - dependency: transitive - description: - name: charcode - url: "https://pub.dartlang.org" - source: hosted - version: "1.1.3" - cli_util: - dependency: transitive - description: - name: cli_util - url: "https://pub.dartlang.org" - source: hosted - version: "0.2.0" + version: "2.1.1" collection: dependency: transitive description: name: collection - url: "https://pub.dartlang.org" + sha256: ee67cb0715911d28db6bf4af1026078bd6f0128b07a5f66fb2ed94ec6783c09a + url: "https://pub.dev" source: hosted - version: "1.14.13" + version: "1.18.0" convert: dependency: transitive description: name: convert - url: "https://pub.dartlang.org" + sha256: "0f08b14755d163f6e2134cb58222dd25ea2a2ee8a195e53983d57c075324d592" + url: "https://pub.dev" source: hosted - version: "2.1.1" + version: "3.1.1" coverage: dependency: transitive description: name: coverage - url: "https://pub.dartlang.org" + sha256: "8acabb8306b57a409bf4c83522065672ee13179297a6bb0cb9ead73948df7c76" + url: "https://pub.dev" source: hosted - version: "0.14.1" + version: "1.7.2" crypto: dependency: transitive description: name: crypto - url: "https://pub.dartlang.org" + sha256: ff625774173754681d66daaf4a448684fb04b78f902da9cb3d308c19cc5e8bab + url: "https://pub.dev" source: hosted - version: "2.1.5" - glob: + version: "3.0.3" + file: dependency: transitive description: - name: glob - url: "https://pub.dartlang.org" + name: file + sha256: "5fc22d7c25582e38ad9a8515372cd9a93834027aacf1801cf01164dac0ffa08c" + url: "https://pub.dev" source: hosted - version: "1.2.0" - http: + version: "7.0.0" + frontend_server_client: + dependency: transitive + description: + name: frontend_server_client + sha256: f64a0333a82f30b0cca061bc3d143813a486dc086b574bfb233b7c1372427694 + url: "https://pub.dev" + source: hosted + version: "4.0.0" + glob: dependency: transitive description: - name: http - url: "https://pub.dartlang.org" + name: glob + sha256: "0e7014b3b7d4dac1ca4d6114f82bf1782ee86745b9b42a92c9289c23d8a0ab63" + url: "https://pub.dev" source: hosted - version: "0.12.2" + version: "2.1.2" http_multi_server: dependency: transitive description: name: http_multi_server - url: "https://pub.dartlang.org" + sha256: "97486f20f9c2f7be8f514851703d0119c3596d14ea63227af6f7a481ef2b2f8b" + url: "https://pub.dev" source: hosted - version: "2.2.0" + version: "3.2.1" http_parser: dependency: transitive description: name: http_parser - url: "https://pub.dartlang.org" + sha256: "2aa08ce0341cc9b354a498388e30986515406668dbcc4f7c950c3e715496693b" + url: "https://pub.dev" source: hosted - version: "3.1.4" + version: "4.0.2" io: dependency: transitive description: name: io - url: "https://pub.dartlang.org" + sha256: "2ec25704aba361659e10e3e5f5d672068d332fc8ac516421d483a11e5cbd061e" + url: "https://pub.dev" source: hosted - version: "0.3.4" + version: "1.0.4" js: dependency: transitive description: name: js - url: "https://pub.dartlang.org" + sha256: c1b2e9b5ea78c45e1a0788d29606ba27dc5f71f019f32ca5140f61ef071838cf + url: "https://pub.dev" source: hosted - version: "0.6.2" + version: "0.7.1" logging: dependency: transitive description: name: logging - url: "https://pub.dartlang.org" + sha256: "623a88c9594aa774443aa3eb2d41807a48486b5613e67599fb4c41c0ad47c340" + url: "https://pub.dev" source: hosted - version: "0.11.4" + version: "1.2.0" matcher: dependency: transitive description: name: matcher - url: "https://pub.dartlang.org" + sha256: d2323aa2060500f906aa31a895b4030b6da3ebdcc5619d14ce1aada65cd161cb + url: "https://pub.dev" source: hosted - version: "0.12.9" + version: "0.12.16+1" meta: dependency: transitive description: name: meta - url: "https://pub.dartlang.org" + sha256: "25dfcaf170a0190f47ca6355bdd4552cb8924b430512ff0cafb8db9bd41fe33b" + url: "https://pub.dev" source: hosted - version: "1.2.3" + version: "1.14.0" mime: dependency: transitive description: name: mime - url: "https://pub.dartlang.org" + sha256: "2e123074287cc9fd6c09de8336dae606d1ddb88d9ac47358826db698c176a1f2" + url: "https://pub.dev" source: hosted - version: "0.9.7" - node_interop: - dependency: transitive - description: - name: node_interop - url: "https://pub.dartlang.org" - source: hosted - version: "1.1.1" - node_io: - dependency: transitive - description: - name: node_io - url: "https://pub.dartlang.org" - source: hosted - version: "1.1.1" + version: "1.0.5" node_preamble: dependency: transitive description: name: node_preamble - url: "https://pub.dartlang.org" + sha256: "6e7eac89047ab8a8d26cf16127b5ed26de65209847630400f9aefd7cd5c730db" + url: "https://pub.dev" source: hosted - version: "1.4.12" + version: "2.0.2" package_config: dependency: transitive description: name: package_config - url: "https://pub.dartlang.org" + sha256: "1c5b77ccc91e4823a5af61ee74e6b972db1ef98c2ff5a18d3161c982a55448bd" + url: "https://pub.dev" source: hosted - version: "1.9.3" + version: "2.1.0" path: dependency: transitive description: name: path - url: "https://pub.dartlang.org" + sha256: "087ce49c3f0dc39180befefc60fdb4acd8f8620e5682fe2476afd0b3688bb4af" + url: "https://pub.dev" source: hosted - version: "1.7.0" + version: "1.9.0" pedantic: dependency: "direct dev" description: name: pedantic - url: "https://pub.dartlang.org" + sha256: "67fc27ed9639506c856c840ccce7594d0bdcd91bc8d53d6e52359449a1d50602" + url: "https://pub.dev" source: hosted - version: "1.9.2" + version: "1.11.1" pool: dependency: transitive description: name: pool - url: "https://pub.dartlang.org" + sha256: "20fe868b6314b322ea036ba325e6fc0711a22948856475e2c2b6306e8ab39c2a" + url: "https://pub.dev" source: hosted - version: "1.4.0" + version: "1.5.1" pub_semver: dependency: transitive description: name: pub_semver - url: "https://pub.dartlang.org" + sha256: "40d3ab1bbd474c4c2328c91e3a7df8c6dd629b79ece4c4bd04bee496a224fb0c" + url: "https://pub.dev" source: hosted - version: "1.4.4" + version: "2.1.4" shelf: dependency: transitive description: name: shelf - url: "https://pub.dartlang.org" + sha256: ad29c505aee705f41a4d8963641f91ac4cee3c8fad5947e033390a7bd8180fa4 + url: "https://pub.dev" source: hosted - version: "0.7.9" + version: "1.4.1" shelf_packages_handler: dependency: transitive description: name: shelf_packages_handler - url: "https://pub.dartlang.org" + sha256: "89f967eca29607c933ba9571d838be31d67f53f6e4ee15147d5dc2934fee1b1e" + url: "https://pub.dev" source: hosted - version: "2.0.0" + version: "3.0.2" shelf_static: dependency: transitive description: name: shelf_static - url: "https://pub.dartlang.org" + sha256: a41d3f53c4adf0f57480578c1d61d90342cd617de7fc8077b1304643c2d85c1e + url: "https://pub.dev" source: hosted - version: "0.2.8" + version: "1.1.2" shelf_web_socket: dependency: transitive description: name: shelf_web_socket - url: "https://pub.dartlang.org" + sha256: "9ca081be41c60190ebcb4766b2486a7d50261db7bd0f5d9615f2d653637a84c1" + url: "https://pub.dev" source: hosted - version: "0.2.3" + version: "1.0.4" source_map_stack_trace: dependency: transitive description: name: source_map_stack_trace - url: "https://pub.dartlang.org" + sha256: "84cf769ad83aa6bb61e0aa5a18e53aea683395f196a6f39c4c881fb90ed4f7ae" + url: "https://pub.dev" source: hosted - version: "2.0.0" + version: "2.1.1" source_maps: dependency: transitive description: name: source_maps - url: "https://pub.dartlang.org" + sha256: "708b3f6b97248e5781f493b765c3337db11c5d2c81c3094f10904bfa8004c703" + url: "https://pub.dev" source: hosted - version: "0.10.9" + version: "0.10.12" source_span: dependency: transitive description: name: source_span - url: "https://pub.dartlang.org" + sha256: "53e943d4206a5e30df338fd4c6e7a077e02254531b138a15aec3bd143c1a8b3c" + url: "https://pub.dev" source: hosted - version: "1.7.0" + version: "1.10.0" stack_trace: dependency: transitive description: name: stack_trace - url: "https://pub.dartlang.org" + sha256: "73713990125a6d93122541237550ee3352a2d84baad52d375a4cad2eb9b7ce0b" + url: "https://pub.dev" source: hosted - version: "1.9.5" + version: "1.11.1" stream_channel: dependency: transitive description: name: stream_channel - url: "https://pub.dartlang.org" + sha256: ba2aa5d8cc609d96bbb2899c28934f9e1af5cddbd60a827822ea467161eb54e7 + url: "https://pub.dev" source: hosted - version: "2.0.0" + version: "2.1.2" string_scanner: dependency: transitive description: name: string_scanner - url: "https://pub.dartlang.org" + sha256: "556692adab6cfa87322a115640c11f13cb77b3f076ddcc5d6ae3c20242bedcde" + url: "https://pub.dev" source: hosted - version: "1.0.5" + version: "1.2.0" term_glyph: dependency: transitive description: name: term_glyph - url: "https://pub.dartlang.org" + sha256: a29248a84fbb7c79282b40b8c72a1209db169a2e0542bce341da992fe1bc7e84 + url: "https://pub.dev" source: hosted - version: "1.1.0" + version: "1.2.1" test: dependency: "direct dev" description: name: test - url: "https://pub.dartlang.org" + sha256: d87214d19fb311997d8128ec501a980f77cb240ac4e7e219accf452813ff473c + url: "https://pub.dev" source: hosted - version: "1.15.4" + version: "1.25.3" test_api: dependency: transitive description: name: test_api - url: "https://pub.dartlang.org" + sha256: "2419f20b0c8677b2d67c8ac4d1ac7372d862dc6c460cdbb052b40155408cd794" + url: "https://pub.dev" source: hosted - version: "0.2.18" + version: "0.7.1" test_core: dependency: transitive description: name: test_core - url: "https://pub.dartlang.org" + sha256: "2236f70be1e5ab405c675e88c36935a87dad9e05a506b57dd5c0f617f5aebcb2" + url: "https://pub.dev" source: hosted - version: "0.3.11+1" + version: "0.6.1" typed_data: dependency: transitive description: name: typed_data - url: "https://pub.dartlang.org" + sha256: facc8d6582f16042dd49f2463ff1bd6e2c9ef9f3d5da3d9b087e244a7b564b3c + url: "https://pub.dev" source: hosted - version: "1.2.0" + version: "1.3.2" vm_service: dependency: transitive description: name: vm_service - url: "https://pub.dartlang.org" + sha256: a75f83f14ad81d5fe4b3319710b90dec37da0e22612326b696c9e1b8f34bbf48 + url: "https://pub.dev" source: hosted - version: "4.2.0" + version: "14.2.0" watcher: dependency: transitive description: name: watcher - url: "https://pub.dartlang.org" + sha256: "3d2ad6751b3c16cf07c7fca317a1413b3f26530319181b37e3b9039b84fc01d8" + url: "https://pub.dev" + source: hosted + version: "1.1.0" + web: + dependency: transitive + description: + name: web + sha256: "97da13628db363c635202ad97068d47c5b8aa555808e7a9411963c533b449b27" + url: "https://pub.dev" source: hosted - version: "0.9.7+15" + version: "0.5.1" web_socket_channel: dependency: transitive description: name: web_socket_channel - url: "https://pub.dartlang.org" + sha256: "58c6666b342a38816b2e7e50ed0f1e261959630becd4c879c4f26bfa14aa5a42" + url: "https://pub.dev" source: hosted - version: "1.1.0" + version: "2.4.5" webkit_inspection_protocol: dependency: transitive description: name: webkit_inspection_protocol - url: "https://pub.dartlang.org" + sha256: "87d3f2333bb240704cd3f1c6b5b7acd8a10e7f0bc28c28dcf14e782014f4a572" + url: "https://pub.dev" source: hosted - version: "0.7.3" + version: "1.2.1" yaml: dependency: transitive description: name: yaml - url: "https://pub.dartlang.org" + sha256: "75769501ea3489fca56601ff33454fe45507ea3bfb014161abc3b43ae25989d5" + url: "https://pub.dev" source: hosted - version: "2.2.1" + version: "3.1.2" sdks: - dart: ">=2.8.1 <3.0.0" + dart: ">=3.3.0 <4.0.0" diff --git a/reports/dart/pubspec.yaml b/reports/dart/pubspec.yaml index 860687f7..ade35788 100644 --- a/reports/dart/pubspec.yaml +++ b/reports/dart/pubspec.yaml @@ -2,7 +2,7 @@ name: darttest description: A simple command-line application. environment: - sdk: '>=2.8.1 <3.0.0' + sdk: '>=2.12.0 <3.0.0' dev_dependencies: pedantic: ^1.9.0 From cacdfc564b3a8060388e8acef12dbcb045b02f54 Mon Sep 17 00:00:00 2001 From: dominicmh Date: Fri, 12 Apr 2024 21:31:54 +0200 Subject: [PATCH 2/3] exclude hidden "tests" from test result --- src/parsers/dart-json/dart-json-parser.ts | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/parsers/dart-json/dart-json-parser.ts b/src/parsers/dart-json/dart-json-parser.ts index 25a716b8..f0afd45f 100644 --- a/src/parsers/dart-json/dart-json-parser.ts +++ b/src/parsers/dart-json/dart-json-parser.ts @@ -123,7 +123,7 @@ 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 && tests[evt.testID]) { + } else if (isTestDoneEvent(evt) && tests[evt.testID]) { tests[evt.testID].testDone = evt } else if (isErrorEvent(evt) && tests[evt.testID]) { tests[evt.testID].error = evt @@ -152,14 +152,16 @@ export class DartJsonParser implements TestParser { return groups.map(group => { group.tests.sort((a, b) => (a.testStart.test.line ?? 0) - (b.testStart.test.line ?? 0)) - const tests = group.tests.map(tc => { - const error = this.getError(suite, tc) - const testName = - group.group.name !== undefined && tc.testStart.test.name.startsWith(group.group.name) - ? tc.testStart.test.name.slice(group.group.name.length).trim() - : tc.testStart.test.name.trim() - return new TestCaseResult(testName, tc.result, tc.time, error) - }) + const tests = group.tests + .filter(tc => !tc.testDone?.hidden) + .map(tc => { + const error = this.getError(suite, tc) + const testName = + group.group.name !== undefined && tc.testStart.test.name.startsWith(group.group.name) + ? tc.testStart.test.name.slice(group.group.name.length).trim() + : tc.testStart.test.name.trim() + return new TestCaseResult(testName, tc.result, tc.time, error) + }) return new TestGroupResult(group.group.name, tests) }) } From 9d4bb430298c183c641d6006fbcbd1233991031d Mon Sep 17 00:00:00 2001 From: dominicmh Date: Fri, 12 Apr 2024 21:32:40 +0200 Subject: [PATCH 3/3] build & package --- dist/index.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/dist/index.js b/dist/index.js index dee44688..5f42b53e 100644 --- a/dist/index.js +++ b/dist/index.js @@ -558,7 +558,7 @@ class DartJsonParser { group.tests.push(test); tests[evt.test.id] = test; } - else if ((0, dart_json_types_1.isTestDoneEvent)(evt) && !evt.hidden && tests[evt.testID]) { + else if ((0, dart_json_types_1.isTestDoneEvent)(evt) && tests[evt.testID]) { tests[evt.testID].testDone = evt; } else if ((0, dart_json_types_1.isErrorEvent)(evt) && tests[evt.testID]) { @@ -585,7 +585,9 @@ class DartJsonParser { groups.sort((a, b) => { var _a, _b; return ((_a = a.group.line) !== null && _a !== void 0 ? _a : 0) - ((_b = b.group.line) !== null && _b !== void 0 ? _b : 0); }); return groups.map(group => { group.tests.sort((a, b) => { var _a, _b; return ((_a = a.testStart.test.line) !== null && _a !== void 0 ? _a : 0) - ((_b = b.testStart.test.line) !== null && _b !== void 0 ? _b : 0); }); - const tests = group.tests.map(tc => { + const tests = group.tests + .filter(tc => { var _a; return !((_a = tc.testDone) === null || _a === void 0 ? void 0 : _a.hidden); }) + .map(tc => { const error = this.getError(suite, tc); const testName = group.group.name !== undefined && tc.testStart.test.name.startsWith(group.group.name) ? tc.testStart.test.name.slice(group.group.name.length).trim()