-
Notifications
You must be signed in to change notification settings - Fork 0
Broaden no_expect lint for path-loaded test modules (incl. nonstandard names) #191
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
Closed
Closed
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
7da4ba0
feat(tests): recognise test modules with non-standard names
leynos 6fe9e4d
feat(no_expect_outside_tests): support real rstest with #[case] as te…
leynos f5fae09
test(examples): inline test module for expect allowance in non-standa…
leynos 30b9d26
refactor(driver,lib_ui_tests): enhance rstest companion module detect…
leynos ccd5e38
refactor(driver): move test context detection helpers into test_conte…
leynos 2eb7789
feat(no_expect_outside_tests): add support for detecting #[rstest] co…
leynos File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
crates/no_expect_outside_tests/examples/pass_expect_in_path_module_harness.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| //! Regression example covering `#[tokio::test]` inside a module with a | ||
| //! non-standard test name, compiled under `--test` harness. | ||
| //! | ||
| //! This validates that the `has_test_module_name` fallback correctly recognises | ||
| //! test functions inside modules whose names follow test naming conventions | ||
| //! (e.g. `service_tests`) even when `#[cfg(test)]` is not present in HIR. | ||
| //! | ||
| //! The module is inline rather than `#[path]`-loaded because `Test::example()` | ||
| //! copies only the single `.rs` file to a temp directory and does not preserve | ||
| //! subdirectories. | ||
| //! | ||
| //! Regression test for <https://github.com/leynos/whitaker/issues/132>. | ||
|
|
||
| mod service_tests { | ||
| #[tokio::test] | ||
| async fn expect_in_path_module_is_allowed() { | ||
| let value: Result<&str, ()> = Ok("ok"); | ||
| value.expect("non-standard module name test should permit expect"); | ||
| } | ||
| } | ||
|
|
||
| fn main() {} |
32 changes: 32 additions & 0 deletions
32
crates/no_expect_outside_tests/examples/pass_expect_in_rstest_harness.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| //! Regression example covering real `#[rstest]` handling for | ||
| //! `no_expect_outside_tests`. | ||
| //! | ||
| //! This uses the actual `rstest` crate (not a stub auxiliary proc-macro) to | ||
| //! validate that Whitaker correctly classifies functions annotated with | ||
| //! `#[rstest]` and `#[case]` as test-only code. | ||
| //! | ||
| //! `rstest_parametrize` was removed from the `rstest` crate in version 0.5.0 | ||
| //! and replaced by the unified `#[rstest]` attribute with `#[case(...)]`. | ||
| //! Whitaker still recognizes `rstest_parametrize` in the attribute registry for | ||
| //! backwards compatibility with older projects, but this example covers only the | ||
| //! current `#[rstest]` form since rstest 0.26.1 is the declared version. | ||
| //! | ||
| //! Regression test for <https://github.com/leynos/whitaker/issues/189>. | ||
|
|
||
| use rstest::rstest; | ||
|
|
||
| #[rstest] | ||
| #[case(1)] | ||
| #[case(42)] | ||
| fn rstest_allows_expect_in_test_context(#[case] value: i32) { | ||
| let parsed = Some(value).expect("value should be present"); | ||
| assert_eq!(parsed, value); | ||
| } | ||
|
|
||
| #[rstest] | ||
| fn rstest_allows_expect_without_cases() { | ||
| let result: Result<&str, ()> = Ok("ok"); | ||
| result.expect("rstest without cases should be test-only"); | ||
| } | ||
|
|
||
| fn main() {} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.