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

feat(cli/tools): add a subcommand --hide-stacktraces for test #24095

Merged
merged 19 commits into from
Aug 20, 2024

Conversation

Hajime-san
Copy link
Contributor

@Hajime-san Hajime-san commented Jun 4, 2024

resolves #24002

I implemented this suggestion that I think it sounds reasonable for reducing noise.
Also, this feature could hide stack trace when running test from editor with LSP command by internal code updated, however I don't touch it currently.

example

  • test.ts
import { assert } from "@std/assert/assert";

Deno.test("assert a b", () => {
  assertEquals("foo", "bar");
});

before

% deno test test.ts              
running 1 test from ./test.ts
assert a b ... FAILED (6ms)

 ERRORS 

assert a b => ./test.ts:3:6
error: AssertionError: Values are not equal.


    [Diff] Actual / Expected


-   foo
+   bar


  throw new AssertionError(message);
        ^
    at Module.assertEquals (https://deno.land/[email protected]/assert/assert_equals.ts:52:9)
    at assertEquals (https://deno.land/[email protected]/testing/asserts.ts:101:11)
    at file:///path/to/test.ts:4:3

 FAILURES 

assert a b => ./test.ts:3:6

FAILED | 0 passed | 1 failed (7ms)

error: Test failed

after

% target/debug/deno test --hide-stacktraces test.ts               
Check file:///path/to/test.ts
running 1 test from ./test.ts
assert a b ... FAILED (10ms)

 ERRORS 

assert a b => ./test.ts:3:6
error: AssertionError: Values are not equal.


    [Diff] Actual / Expected


-   foo
+   bar



 FAILURES 

assert a b => ./test.ts:3:6

FAILED | 0 passed | 1 failed (15ms)

error: Test failed

@Hajime-san Hajime-san marked this pull request as ready for review June 4, 2024 03:12
Copy link
Member

@lucacasonato lucacasonato left a comment

Choose a reason for hiding this comment

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

Thanks, just a couple comments. Sorry for the slow review.

@@ -2683,6 +2684,12 @@ Note: running multiple `deno test --clean` calls in series or parallel for the s
.help("Select reporter to use. Default to 'pretty'.")
.value_parser(["pretty", "dot", "junit", "tap"])
)
.arg(
Arg::new("hide-traces")
Copy link
Member

Choose a reason for hiding this comment

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

Can you rename this option to --hide-stacktraces?

cli/tools/test/mod.rs Outdated Show resolved Hide resolved
@bartlomieju bartlomieju added this to the 1.45 milestone Jun 17, 2024
Hajime-san and others added 2 commits June 18, 2024 10:53
remove unnecessary attribute

Co-authored-by: Luca Casonato <[email protected]>
Signed-off-by: Hajime-san <[email protected]>
@Hajime-san Hajime-san changed the title feat(cli/tools): add a subcommand --hide-traces for test feat(cli/tools): add a subcommand --hide-stacktraces for test Jun 18, 2024
@dsherret dsherret modified the milestones: 1.45, 1.46 Jul 10, 2024
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.

LGTM. Thanks!

@dsherret dsherret enabled auto-merge (squash) August 19, 2024 23:49
@dsherret dsherret disabled auto-merge August 20, 2024 00:49
@dsherret dsherret enabled auto-merge (squash) August 20, 2024 00:57
@dsherret dsherret merged commit 19bcb40 into denoland:main Aug 20, 2024
17 checks passed
@Hajime-san
Copy link
Contributor Author

@dsherret
Thank you for updating!

@Hajime-san Hajime-san deleted the add-test-subcommand-hide-traces branch August 20, 2024 05:40
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.

add --hide-traces flag to deno test to ignore the stack trace completely
4 participants