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

Add unique test module scope for arg to 'cargo test' #565

Closed
wants to merge 1 commit into from
Closed

Add unique test module scope for arg to 'cargo test' #565

wants to merge 1 commit into from

Conversation

cebernard
Copy link

When rustic-cargo-current-test sees point at a test module's definition (or slightly below, while being above the first test function), then construct an argument for 'cargo test' that will run only that module's tests.

Since most test modules are not uniquely named, this means either prepending the parent module to the current module (e.g. when tests are in 'some_mod.rs', then 'cargo test some_mod::tests'), or if at crate root then using 'lib' or 'main' as the argument (e.g. when tests are in 'lib.rs', then 'cargo test lib').

Handle both module definition styles, either when modules are defined in a like-named file or living in a like-named directory in a file named 'mod.rs'.

This commit is feature complete, but only covers the scenario where tests are defined in the same file as production code.

Partially resolves #561 (1-3).

When rustic-cargo-current-test sees point at a test module's
definition (or slightly below, while being above the first test
function), then construct an argument for 'cargo test' that will run
only that module's tests.

Since most test modules are not uniquely named, this means either
prepending the parent module to the current module (e.g. when tests
are in 'some_mod.rs', then 'cargo test some_mod::tests'), or if at
crate root then using 'lib' or 'main' as the argument (e.g. when tests
are in 'lib.rs', then 'cargo test lib').

Handle both module definition styles, either when modules are defined
in a like-named file or living in a like-named directory
in a file named 'mod.rs'.

This commit is feature complete, but only covers the scenario where
tests are defined in the same file as production code.

Partially resolves #561 (1-3).
@cebernard
Copy link
Author

Hi everyone. Just checking in to see if there's any feedback on this PR. I'm happy to make any adjustments based on your suggestions.

@psibi
Copy link
Collaborator

psibi commented May 22, 2024

This repo is unmaintained, this is the new home: https://github.com/emacs-rustic/rustic

More details here: https://psibi.in/posts/rustic.html

@cebernard
Copy link
Author

Thanks. Somehow I missed the memo. I guess I'll duplicate this PR on that repo.

@cebernard cebernard closed this by deleting the head repository May 26, 2024
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.

rustic-cargo-current-test is broken for running all tests in a module
2 participants