Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(runtime/testing): format aggregate errors #12183

Merged

Conversation

caspervonb
Copy link
Contributor

@caspervonb caspervonb commented Sep 22, 2021

Prints out the actual errors contained in aggregate errors rather than just stating that an aggregate error occured.

Before:

test aggregate ... FAILED (11ms)

failures:

aggregate
AggregateError
    at file:///home/caspervonb/deno/cli/tests/testdata/test/aggregate_error.ts:5:9
    at asyncOpSanitizer (deno:runtime/js/40_testing.js:35:15)
    at resourceSanitizer (deno:runtime/js/40_testing.js:72:13)
    at exitSanitizer (deno:runtime/js/40_testing.js:99:15)
    at runTest (deno:runtime/js/40_testing.js:215:13)
    at Object.runTests (deno:runtime/js/40_testing.js:283:28)
    at file:///home/caspervonb/deno/a4959e45-e14a-4088-9481-1767fec6e3e4$deno$test.js:4:27

failures:

	aggregate

After:

test aggregate ... FAILED (23ms)

failures:

aggregate
Error: Error 1
    at file:///home/caspervonb/deno/cli/tests/testdata/test/aggregate_error.ts:2:18
    at asyncOpSanitizer (deno:runtime/js/40_testing.js:35:15)
    at resourceSanitizer (deno:runtime/js/40_testing.js:72:13)
    at exitSanitizer (deno:runtime/js/40_testing.js:99:15)
    at runTest (deno:runtime/js/40_testing.js:223:13)
    at Object.runTests (deno:runtime/js/40_testing.js:308:28)
    at [deno:cli/tools/test.rs:302:6]:1:21
Error: Error 2
    at file:///home/caspervonb/deno/cli/tests/testdata/test/aggregate_error.ts:3:18
    at asyncOpSanitizer (deno:runtime/js/40_testing.js:35:15)
    at resourceSanitizer (deno:runtime/js/40_testing.js:72:13)
    at exitSanitizer (deno:runtime/js/40_testing.js:99:15)
    at runTest (deno:runtime/js/40_testing.js:223:13)
    at Object.runTests (deno:runtime/js/40_testing.js:308:28)
    at [deno:cli/tools/test.rs:302:6]:1:21

failures:

	aggregate

@@ -186,6 +186,14 @@ finishing test case.`;
ArrayPrototypePush(tests, testDef);
}

function formatFailure(error) {
if (error.errors) {
return { failed: error.errors.map(error => inspectArgs([error])).join("\n") };
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Blank line in-between?

Suggested change
return { failed: error.errors.map(error => inspectArgs([error])).join("\n") };
return { failed: error.errors.map(error => inspectArgs([error])).join("\n\n") };

@caspervonb caspervonb force-pushed the fix-runtime-test-print-aggregate-errors branch from b5c5cbf to a243343 Compare September 22, 2021 16:26
@caspervonb
Copy link
Contributor Author

Chrome screenshot attached for reference.

Our inspect implementation basically matches Chrome so to have any useful printouts while keeping console as-is we need to special case this while formatting test failures.

image

@nayeemrmn
Copy link
Collaborator

How about this formatting:

AggregateError [
  Error: Error 1
      at file:///home/caspervonb/deno/cli/tests/testdata/test/aggregate_error.ts:2:18
      at asyncOpSanitizer (deno:runtime/js/40_testing.js:35:15)
      at resourceSanitizer (deno:runtime/js/40_testing.js:72:13)
      at exitSanitizer (deno:runtime/js/40_testing.js:99:15)
      at runTest (deno:runtime/js/40_testing.js:223:13)
      at Object.runTests (deno:runtime/js/40_testing.js:308:28)
      at [deno:cli/tools/test.rs:302:6]:1:21,
  Error: Error 2
      at file:///home/caspervonb/deno/cli/tests/testdata/test/aggregate_error.ts:3:18
      at asyncOpSanitizer (deno:runtime/js/40_testing.js:35:15)
      at resourceSanitizer (deno:runtime/js/40_testing.js:72:13)
      at exitSanitizer (deno:runtime/js/40_testing.js:99:15)
      at runTest (deno:runtime/js/40_testing.js:223:13)
      at Object.runTests (deno:runtime/js/40_testing.js:308:28)
      at [deno:cli/tools/test.rs:302:6]:1:21
]
    at file:///home/caspervonb/deno/cli/tests/testdata/test/aggregate_error.ts:5:9
    at asyncOpSanitizer (deno:runtime/js/40_testing.js:35:15)
    at resourceSanitizer (deno:runtime/js/40_testing.js:72:13)
    at exitSanitizer (deno:runtime/js/40_testing.js:99:15)
    at runTest (deno:runtime/js/40_testing.js:215:13)
    at Object.runTests (deno:runtime/js/40_testing.js:283:28)
    at file:///home/caspervonb/deno/a4959e45-e14a-4088-9481-1767fec6e3e4$deno$test.js:4:27

@caspervonb
Copy link
Contributor Author

caspervonb commented Sep 22, 2021

Looked at Sindre's implementation, seemed like a reasonable way to format it. Pretty much the same as your suggestion @nayeemrmn but there's no delimiters, 4 spaces is quite obvious with a monospace font in a terminal tho.

AggregateError
    Error: Error 1
        at file:///home/caspervonb/deno/cli/tests/testdata/test/aggregate_error.ts:2:18
        at asyncOpSanitizer (deno:runtime/js/40_testing.js:35:15)
        at resourceSanitizer (deno:runtime/js/40_testing.js:72:13)
        at exitSanitizer (deno:runtime/js/40_testing.js:99:15)
        at runTest (deno:runtime/js/40_testing.js:230:13)
        at Object.runTests (deno:runtime/js/40_testing.js:315:28)
        at [deno:cli/tools/test.rs:302:6]:1:21
    Error: Error 2
        at file:///home/caspervonb/deno/cli/tests/testdata/test/aggregate_error.ts:3:18
        at asyncOpSanitizer (deno:runtime/js/40_testing.js:35:15)
        at resourceSanitizer (deno:runtime/js/40_testing.js:72:13)
        at exitSanitizer (deno:runtime/js/40_testing.js:99:15)
        at runTest (deno:runtime/js/40_testing.js:230:13)
        at Object.runTests (deno:runtime/js/40_testing.js:315:28)
        at [deno:cli/tools/test.rs:302:6]:1:21AggregateError
    at file:///home/caspervonb/deno/cli/tests/testdata/test/aggregate_error.ts:5:9
    at asyncOpSanitizer (deno:runtime/js/40_testing.js:35:15)
    at resourceSanitizer (deno:runtime/js/40_testing.js:72:13)
    at exitSanitizer (deno:runtime/js/40_testing.js:99:15)
    at runTest (deno:runtime/js/40_testing.js:230:13)
    at Object.runTests (deno:runtime/js/40_testing.js:315:28)
    at [deno:cli/tools/test.rs:302:6]:1:21

Copy link
Member

@bartlomieju bartlomieju left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems useful. @dsherret any objections?

Copy link
Member

@dsherret dsherret left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks nice!

@bartlomieju bartlomieju merged commit 6bf5c85 into denoland:main Sep 30, 2021
@caspervonb caspervonb deleted the fix-runtime-test-print-aggregate-errors branch October 1, 2021 10:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants