Skip to content

Commit

Permalink
Fix flutter-json doesn't provide error details
Browse files Browse the repository at this point in the history
  • Loading branch information
Michal Dorner committed Feb 1, 2021
1 parent 2365963 commit 855ff9b
Show file tree
Hide file tree
Showing 13 changed files with 3,196 additions and 51 deletions.
473 changes: 473 additions & 0 deletions __tests__/__outputs__/provider-test-results.md

Large diffs are not rendered by default.

1,963 changes: 1,953 additions & 10 deletions __tests__/__snapshots__/dart-json.test.ts.snap

Large diffs are not rendered by default.

18 changes: 9 additions & 9 deletions __tests__/__snapshots__/dotnet-trx.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -11,40 +11,40 @@ TestRunResult {
"tests": Array [
TestCaseResult {
"error": Object {
"details": "System.DivideByZeroException : Attempted to divide by zero.
at DotnetTests.Unit.Calculator.Div(Int32 a, Int32 b) in C:\\\\Users\\\\Michal\\\\Workspace\\\\dorny\\\\test-check\\\\reports\\\\dotnet\\\\DotnetTests.Unit\\\\Calculator.cs:line 9
at DotnetTests.XUnitTests.CalculatorTests.Exception_In_TargetTest() in C:\\\\Users\\\\Michal\\\\Workspace\\\\dorny\\\\test-check\\\\reports\\\\dotnet\\\\DotnetTests.XUnitTests\\\\CalculatorTests.cs:line 33",
"line": 9,
"message": "System.DivideByZeroException : Attempted to divide by zero.",
"path": "DotnetTests.Unit/Calculator.cs",
"stackTrace": "System.DivideByZeroException : Attempted to divide by zero.
at DotnetTests.Unit.Calculator.Div(Int32 a, Int32 b) in C:\\\\Users\\\\Michal\\\\Workspace\\\\dorny\\\\test-check\\\\reports\\\\dotnet\\\\DotnetTests.Unit\\\\Calculator.cs:line 9
at DotnetTests.XUnitTests.CalculatorTests.Exception_In_TargetTest() in C:\\\\Users\\\\Michal\\\\Workspace\\\\dorny\\\\test-check\\\\reports\\\\dotnet\\\\DotnetTests.XUnitTests\\\\CalculatorTests.cs:line 33",
},
"name": "Exception_In_TargetTest",
"result": "failed",
"time": 0.4975,
},
TestCaseResult {
"error": Object {
"details": "System.Exception : Test
at DotnetTests.XUnitTests.CalculatorTests.Exception_In_Test() in C:\\\\Users\\\\Michal\\\\Workspace\\\\dorny\\\\test-check\\\\reports\\\\dotnet\\\\DotnetTests.XUnitTests\\\\CalculatorTests.cs:line 39",
"line": 39,
"message": "System.Exception : Test",
"path": "DotnetTests.XUnitTests/CalculatorTests.cs",
"stackTrace": "System.Exception : Test
at DotnetTests.XUnitTests.CalculatorTests.Exception_In_Test() in C:\\\\Users\\\\Michal\\\\Workspace\\\\dorny\\\\test-check\\\\reports\\\\dotnet\\\\DotnetTests.XUnitTests\\\\CalculatorTests.cs:line 39",
},
"name": "Exception_In_Test",
"result": "failed",
"time": 2.2728,
},
TestCaseResult {
"error": Object {
"details": "Assert.Equal() Failure
Expected: 3
Actual: 2
at DotnetTests.XUnitTests.CalculatorTests.Failing_Test() in C:\\\\Users\\\\Michal\\\\Workspace\\\\dorny\\\\test-check\\\\reports\\\\dotnet\\\\DotnetTests.XUnitTests\\\\CalculatorTests.cs:line 27",
"line": 27,
"message": "Assert.Equal() Failure
Expected: 3
Actual: 2",
"path": "DotnetTests.XUnitTests/CalculatorTests.cs",
"stackTrace": "Assert.Equal() Failure
Expected: 3
Actual: 2
at DotnetTests.XUnitTests.CalculatorTests.Failing_Test() in C:\\\\Users\\\\Michal\\\\Workspace\\\\dorny\\\\test-check\\\\reports\\\\dotnet\\\\DotnetTests.XUnitTests\\\\CalculatorTests.cs:line 27",
},
"name": "Failing_Test",
"result": "failed",
Expand Down
36 changes: 18 additions & 18 deletions __tests__/__snapshots__/jest-junit.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,7 @@ TestRunResult {
"tests": Array [
TestCaseResult {
"error": Object {
"line": 10,
"path": "__tests__/main.test.js",
"stackTrace": "Error: expect(received).toBeTruthy()
"details": "Error: expect(received).toBeTruthy()

Received: false
at Object.<anonymous> (C:\\\\Users\\\\Michal\\\\Workspace\\\\dorny\\\\test-check\\\\reports\\\\jest\\\\__tests__\\\\main.test.js:10:21)
Expand All @@ -34,16 +32,16 @@ Received: false
at mapper (C:\\\\Users\\\\Michal\\\\Workspace\\\\dorny\\\\test-check\\\\reports\\\\jest\\\\node_modules\\\\jest-jasmine2\\\\build\\\\queueRunner.js:28:19)
at C:\\\\Users\\\\Michal\\\\Workspace\\\\dorny\\\\test-check\\\\reports\\\\jest\\\\node_modules\\\\jest-jasmine2\\\\build\\\\queueRunner.js:75:41
at processTicksAndRejections (internal/process/task_queues.js:97:5)",
"line": 10,
"path": "__tests__/main.test.js",
},
"name": "Failing test",
"result": "failed",
"time": 2,
},
TestCaseResult {
"error": Object {
"line": 2,
"path": "lib/main.js",
"stackTrace": "Error: Some error
"details": "Error: Some error
at Object.throwError (C:\\\\Users\\\\Michal\\\\Workspace\\\\dorny\\\\test-check\\\\reports\\\\jest\\\\lib\\\\main.js:2:9)
at Object.<anonymous> (C:\\\\Users\\\\Michal\\\\Workspace\\\\dorny\\\\test-check\\\\reports\\\\jest\\\\__tests__\\\\main.test.js:14:11)
at Object.asyncJestTest (C:\\\\Users\\\\Michal\\\\Workspace\\\\dorny\\\\test-check\\\\reports\\\\jest\\\\node_modules\\\\jest-jasmine2\\\\build\\\\jasmineAsyncInstall.js:106:37)
Expand All @@ -52,6 +50,8 @@ Received: false
at mapper (C:\\\\Users\\\\Michal\\\\Workspace\\\\dorny\\\\test-check\\\\reports\\\\jest\\\\node_modules\\\\jest-jasmine2\\\\build\\\\queueRunner.js:28:19)
at C:\\\\Users\\\\Michal\\\\Workspace\\\\dorny\\\\test-check\\\\reports\\\\jest\\\\node_modules\\\\jest-jasmine2\\\\build\\\\queueRunner.js:75:41
at processTicksAndRejections (internal/process/task_queues.js:97:5)",
"line": 2,
"path": "lib/main.js",
},
"name": "Exception in target unit",
"result": "failed",
Expand All @@ -64,16 +64,16 @@ Received: false
"tests": Array [
TestCaseResult {
"error": Object {
"line": 21,
"path": "__tests__/main.test.js",
"stackTrace": "Error: Some error
"details": "Error: Some error
at Object.<anonymous> (C:\\\\Users\\\\Michal\\\\Workspace\\\\dorny\\\\test-check\\\\reports\\\\jest\\\\__tests__\\\\main.test.js:21:11)
at Object.asyncJestTest (C:\\\\Users\\\\Michal\\\\Workspace\\\\dorny\\\\test-check\\\\reports\\\\jest\\\\node_modules\\\\jest-jasmine2\\\\build\\\\jasmineAsyncInstall.js:106:37)
at C:\\\\Users\\\\Michal\\\\Workspace\\\\dorny\\\\test-check\\\\reports\\\\jest\\\\node_modules\\\\jest-jasmine2\\\\build\\\\queueRunner.js:45:12
at new Promise (<anonymous>)
at mapper (C:\\\\Users\\\\Michal\\\\Workspace\\\\dorny\\\\test-check\\\\reports\\\\jest\\\\node_modules\\\\jest-jasmine2\\\\build\\\\queueRunner.js:28:19)
at C:\\\\Users\\\\Michal\\\\Workspace\\\\dorny\\\\test-check\\\\reports\\\\jest\\\\node_modules\\\\jest-jasmine2\\\\build\\\\queueRunner.js:75:41
at processTicksAndRejections (internal/process/task_queues.js:97:5)",
"line": 21,
"path": "__tests__/main.test.js",
},
"name": "Exception in test",
"result": "failed",
Expand All @@ -92,9 +92,7 @@ Received: false
"tests": Array [
TestCaseResult {
"error": Object {
"line": 1,
"path": "__tests__/second.test.js",
"stackTrace": ": Timeout - Async callback was not invoked within the 1 ms timeout specified by jest.setTimeout.Timeout - Async callback was not invoked within the 1 ms timeout specified by jest.setTimeout.Error:
"details": ": Timeout - Async callback was not invoked within the 1 ms timeout specified by jest.setTimeout.Timeout - Async callback was not invoked within the 1 ms timeout specified by jest.setTimeout.Error:
at new Spec (C:\\\\Users\\\\Michal\\\\Workspace\\\\dorny\\\\test-check\\\\reports\\\\jest\\\\node_modules\\\\jest-jasmine2\\\\build\\\\jasmine\\\\Spec.js:116:22)
at new Spec (C:\\\\Users\\\\Michal\\\\Workspace\\\\dorny\\\\test-check\\\\reports\\\\jest\\\\node_modules\\\\jest-jasmine2\\\\build\\\\setup_jest_globals.js:78:9)
at specFactory (C:\\\\Users\\\\Michal\\\\Workspace\\\\dorny\\\\test-check\\\\reports\\\\jest\\\\node_modules\\\\jest-jasmine2\\\\build\\\\jasmine\\\\Env.js:523:24)
Expand All @@ -108,6 +106,8 @@ Received: false
at jasmine2 (C:\\\\Users\\\\Michal\\\\Workspace\\\\dorny\\\\test-check\\\\reports\\\\jest\\\\node_modules\\\\jest-jasmine2\\\\build\\\\index.js:230:13)
at runTestInternal (C:\\\\Users\\\\Michal\\\\Workspace\\\\dorny\\\\test-check\\\\reports\\\\jest\\\\node_modules\\\\jest-runner\\\\build\\\\runTest.js:380:22)
at runTest (C:\\\\Users\\\\Michal\\\\Workspace\\\\dorny\\\\test-check\\\\reports\\\\jest\\\\node_modules\\\\jest-runner\\\\build\\\\runTest.js:472:34)",
"line": 1,
"path": "__tests__/second.test.js",
},
"name": "Timeout test",
"result": "failed",
Expand Down Expand Up @@ -22013,9 +22013,7 @@ Is good for you.\\")",
},
TestCaseResult {
"error": Object {
"line": 418,
"path": "e2e/__tests__/jestChangedFiles.test.ts",
"stackTrace": "Error: abort: empty revision range
"details": "Error: abort: empty revision range
at makeError (/home/dorny/dorny/jest/node_modules/execa/lib/error.js:59:11)
at handlePromise (/home/dorny/dorny/jest/node_modules/execa/index.js:114:26)
at runMicrotasks (<anonymous>)
Expand All @@ -22026,6 +22024,8 @@ Is good for you.\\")",
at Object.<anonymous> (/home/dorny/dorny/jest/e2e/__tests__/jestChangedFiles.test.ts:418:28)
at _callCircusTest (/home/dorny/dorny/jest/packages/jest-circus/build/run.js:218:5)
at _runTest (/home/dorny/dorny/jest/packages/jest-circus/build/run.js:155:3)",
"line": 418,
"path": "e2e/__tests__/jestChangedFiles.test.ts",
},
"name": "gets changed files for hg",
"result": "failed",
Expand Down Expand Up @@ -25368,9 +25368,7 @@ Is good for you.\\")",
},
TestCaseResult {
"error": Object {
"line": 360,
"path": "e2e/__tests__/onlyChanged.test.ts",
"stackTrace": "Error: expect(received).toMatch(expected)
"details": "Error: expect(received).toMatch(expected)

Expected pattern: /PASS __tests__(\\\\/|\\\\\\\\)file2.test.js/
Received string: \\"·
Expand All @@ -25387,6 +25385,8 @@ Received string: \\"·
at _runTestsForDescribeBlock (/home/dorny/dorny/jest/packages/jest-circus/build/run.js:66:9)
at run (/home/dorny/dorny/jest/packages/jest-circus/build/run.js:25:3)
at runAndTransformResultsToJestFormat (/home/dorny/dorny/jest/packages/jest-circus/build/legacy-code-todo-rewrite/jestAdapterInit.js:163:21)",
"line": 360,
"path": "e2e/__tests__/onlyChanged.test.ts",
},
"name": "gets changed files for hg",
"result": "failed",
Expand Down
23 changes: 23 additions & 0 deletions __tests__/dart-json.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,27 @@ describe('dart-json tests', () => {
fs.mkdirSync(path.dirname(outputPath), {recursive: true})
fs.writeFileSync(outputPath, report)
})

it('report from rrousselGit/provider test results matches snapshot', async () => {
const fixturePath = path.join(__dirname, 'fixtures', 'external', 'flutter', 'provider-test-results.json')
const trackedFilesPath = path.join(__dirname, 'fixtures', 'external', 'flutter', 'files.txt')
const outputPath = path.join(__dirname, '__outputs__', 'provider-test-results.md')
const filePath = normalizeFilePath(path.relative(__dirname, fixturePath))
const fileContent = fs.readFileSync(fixturePath, {encoding: 'utf8'})

const trackedFiles = fs.readFileSync(trackedFilesPath, {encoding: 'utf8'}).split(/\n\r?/g)
const opts: ParseOptions = {
trackedFiles,
parseErrors: true,
workDir: '/__w/provider/provider/'
}

const parser = new DartJsonParser(opts)
const result = await parser.parse(filePath, fileContent)
expect(result).toMatchSnapshot()

const report = getReport([result])
fs.mkdirSync(path.dirname(outputPath), {recursive: true})
fs.writeFileSync(outputPath, report)
})
})
57 changes: 57 additions & 0 deletions __tests__/fixtures/external/flutter/files.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
.github/ISSUE_TEMPLATE/bug_report.md
.github/ISSUE_TEMPLATE/config.yml
.github/ISSUE_TEMPLATE/feature_request.md
.github/workflows/build.yml
.gitignore
CHANGELOG.md
LICENSE
README.md
all_lint_rules.yaml
analysis_options.yaml
dart_test.yaml
example/.gitignore
example/.metadata
example/lib/main.dart
example/pubspec.yaml
example/test/widget_test.dart
example/test_driver/app.dart
example/test_driver/app_test.dart
lib/provider.dart
lib/single_child_widget.dart
lib/src/async_provider.dart
lib/src/change_notifier_provider.dart
lib/src/consumer.dart
lib/src/deferred_inherited_provider.dart
lib/src/inherited_provider.dart
lib/src/listenable_provider.dart
lib/src/provider.dart
lib/src/proxy_provider.dart
lib/src/reassemble_handler.dart
lib/src/selector.dart
lib/src/value_listenable_provider.dart
pubspec.yaml
resources/devtools_providers.jpg
resources/expanded_devtools.jpg
resources/flutter_favorite.png
resources/translations/es_MX/README.md
resources/translations/pt_br/README.md
resources/translations/zh-CN/README.md
scripts/flutter_test.sh
test/builder_test.dart
test/change_notifier_provider_test.dart
test/common.dart
test/consumer_test.dart
test/context_test.dart
test/dart_test.yaml
test/future_provider_test.dart
test/inherited_provider_test.dart
test/listenable_provider_test.dart
test/listenable_proxy_provider_test.dart
test/multi_provider_test.dart
test/provider_test.dart
test/proxy_provider_test.dart
test/reassemble_test.dart
test/selector_test.dart
test/stateful_provider_test.dart
test/stream_provider_test.dart
test/value_listenable_provider_test.dart
Loading

0 comments on commit 855ff9b

Please sign in to comment.