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

Improve assertions in src/tests.rs #10449

Merged
merged 3 commits into from Sep 21, 2023

Conversation

sholderbach
Copy link
Member

@sholderbach sholderbach commented Sep 20, 2023

Description

Mention the expected substring in:

  • fn run_test_contains()
  • fn test_ide_contains()
  • fn fail_test()

Developer-Facing Changes

You can read the test failure to figure out what is going on, don't necessarily have to look up the test

New look of failure

failures:

---- tests::test_math::broken_math stdout ----
stdout:
stderr: Error: nu::parser::incomplete_math_expression

  × Incomplete math expression.
   ╭─[/tmp/.tmpz0V8nC:1:1]
 1 │ 3 +
   ·   ┬
   ·   ╰── incomplete math expression
   ╰────


Expected error to contain: Incomplete universe
thread 'tests::test_math::broken_math' panicked at 'assertion failed: !stderr.is_empty() && stderr.contains(expected)', src/tests.rs:181:5

Tests + Formatting

This is an assetion used in several tests in the workspace root

Mention the expected substring in:
- `fn run_test_contains()`
- `fn test_ide_contains()`
- `fn fail_test()`
Copy link
Member

@amtoine amtoine left a comment

Choose a reason for hiding this comment

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

better failing test messages? i can only sign up to that 😉

Move it out of the immediate panic message and below rest of the output.
This is easier to identify.
@sholderbach sholderbach merged commit 1072bd0 into nushell:main Sep 21, 2023
19 checks passed
@sholderbach sholderbach deleted the improve-test-assertions branch September 21, 2023 18:12
hardfau1t pushed a commit to hardfau1t/nushell that referenced this pull request Dec 14, 2023
# Description
Mention the expected substring in:
- `fn run_test_contains()`
- `fn test_ide_contains()`
- `fn fail_test()`


# Developer-Facing Changes
You can read the test failure to figure out what is going on, don't
necessarily have to look up the test

New look of failure
```
failures:

---- tests::test_math::broken_math stdout ----
stdout:
stderr: Error: nu::parser::incomplete_math_expression

  × Incomplete math expression.
   ╭─[/tmp/.tmpz0V8nC:1:1]
 1 │ 3 +
   ·   ┬
   ·   ╰── incomplete math expression
   ╰────


Expected error to contain: Incomplete universe
thread 'tests::test_math::broken_math' panicked at 'assertion failed: !stderr.is_empty() && stderr.contains(expected)', src/tests.rs:181:5
```
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.

None yet

2 participants