Skip to content

Conversation

@julienbrs
Copy link

@julienbrs julienbrs commented Aug 9, 2024

Closes #1512

Introduced changes

  • Added an --exclude flag that functions similarly to the existing FilterName. This flag allows users to exclude tests based on their names.
  • Note: The current filter functionality works without a specific flag (snforge test simple_test launches all tests beginning with "simple_test", rather than requiring snforge test --filter simple_test). Given this, I believe the new --exclude option might not be compatible with the existing filter option. What do you think?

Checklist

  • Linked relevant issue
  • Updated relevant documentation
  • Added relevant tests
  • Performed self-review of the code
  • Added changes to CHANGELOG.md

@julienbrs julienbrs marked this pull request as ready for review August 19, 2024 08:38
@integraledelebesgue
Copy link
Contributor

Please fill the checklist and add your changes to the changelog :)

@integraledelebesgue
Copy link
Contributor

Also, always make sure to run cargo fmt and cargo lint before committing your changes

@github-actions
Copy link

github-actions bot commented Feb 3, 2025

Hi! This pull request hasn't had any activity for a while, so I am
marking it as stale. It will close in 14
days if it is not updated. Thanks for contributing!

@github-actions github-actions bot added the stale Stale Bot label Feb 3, 2025
@julienbrs julienbrs requested a review from a team as a code owner February 7, 2025 15:01
@github-actions github-actions bot removed the stale Stale Bot label Feb 10, 2025
Copy link
Contributor

@kkawula kkawula left a comment

Choose a reason for hiding this comment

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

Please run cargo lint before committing changes and address CI run errors.

@kkawula
Copy link
Contributor

kkawula commented Feb 17, 2025

Hi @julienbrs, any updates here?

@julienbrs
Copy link
Author

Will fix it asap tonight or next day

@kkawula
Copy link
Contributor

kkawula commented Feb 25, 2025

Hi @julienbrs how's it going?

@julienbrs
Copy link
Author

Hi @kkawula, everything is working correctly except for one failing test: e2e::docs_snippets_validation::test_docs_snippets.

Expected output (from the documentation snippet):

...
Tests: 0 passed, 1 failed, 2 skipped, 0 ignored, 0 excluded, 0 filtered out

Actual Output from the test runner:

... 
Tests: 2 passed, 1 failed, 0 skipped, 0 ignored, 0 excluded, 0 filtered out

Why I think it's happening

I suspect the issue is due to how --exit-first is currently implemented. When a test fails, the runner sets interrupted = true and stops processing new tests, but any tests that were already spawned asynchronously still run to completion (afaik).
Before my changes, this test was passing, and I’m not sure exactly what I did that could have broken it. Any insights on how to handle this properly would be greatly appreciated! 🙏

@cptartur
Copy link
Member

@kkawula please request some from the team once it's read for the second review.

@kkawula
Copy link
Contributor

kkawula commented Mar 24, 2025

Hi @kkawula, everything is working correctly except for one failing test: e2e::docs_snippets_validation::test_docs_snippets.

Expected output (from the documentation snippet):

...
Tests: 0 passed, 1 failed, 2 skipped, 0 ignored, 0 excluded, 0 filtered out

Actual Output from the test runner:

... 
Tests: 2 passed, 1 failed, 0 skipped, 0 ignored, 0 excluded, 0 filtered out

Why I think it's happening

I suspect the issue is due to how --exit-first is currently implemented. When a test fails, the runner sets interrupted = true and stops processing new tests, but any tests that were already spawned asynchronously still run to completion (afaik). Before my changes, this test was passing, and I’m not sure exactly what I did that could have broken it. Any insights on how to handle this properly would be greatly appreciated! 🙏

It isn't related to your changes directly, your conclusion is probably correct. Could you please add there a few tests, to show that they are skipped

@kkawula
Copy link
Contributor

kkawula commented Apr 2, 2025

Hi @julienbrs, any progress on this?

@julienbrs
Copy link
Author

It isn't related to your changes directly, your conclusion is probably correct. Could you please add there a few tests, to show that they are skipped

My bad, I might have made an autoformat on that md file and it added an empty line between that snippet code and the above <!-- { "ignored": true } -->. So indeed that error on snippet was already known before that PR

Apart from that, I think everything is fine now

@julienbrs julienbrs requested a review from kkawula April 4, 2025 23:57
Copy link
Contributor

@kkawula kkawula left a comment

Choose a reason for hiding this comment

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

We have added more tests to the master branch, that's why your CI is failing, you should add 0 excluded entry in these tests. Also, our CI now uses rust 1.86 for formatting and limiting. If you encounter any problem please update your local Rust to stable.

#[test]
fn with_exclude_flag() {
let temp = setup_package("simple_package");
// Exclude the test "test_failing"
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// Exclude the test "test_failing"

.arg("--exclude")
.arg("test_failing")
.assert()
.code(1); // Assuming no other test fails
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
.code(1); // Assuming no other test fails
.code(0);

Comment on lines +426 to +427
.arg("--exclude")
.arg("test_failing")
Copy link
Contributor

@kkawula kkawula Apr 7, 2025

Choose a reason for hiding this comment

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

excluding all failed tast should be better

@cptartur cptartur requested a review from ddoktorski April 8, 2025 10:19
Copy link
Contributor

@kkawula kkawula left a comment

Choose a reason for hiding this comment

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

HI @julienbrs, do you have further plans to work on this? After a little talk with the team, we decided that this flag should be renamed to --skip to stay consistent with cargo test

@julienbrs
Copy link
Author

HI @julienbrs, do you have further plans to work on this? After a little talk with the team, we decided that this flag should be renamed to --skip to stay consistent with cargo test

Hi @kkawula, will have some time to work + finish this PR for the next coming days. the --skip change is noted!

@kkawula
Copy link
Contributor

kkawula commented May 5, 2025

@julienbrs It is also worth mentioning that we would like to mimic cargo test and skipped tests shouldn't be displayed in test summary. Please get to know with --skip before introducing changes

@julienbrs
Copy link
Author

Hi @kkawula, I'm really sorry, but I won't be able to dedicate time to it after all. Things have become busier than expected on my end. Feel free to continue or reassign it as needed. Thanks for your understanding, and sorry again for the inconvenience.

@kkawula
Copy link
Contributor

kkawula commented May 19, 2025

Okey, we understand and appreciate your contribution. We will take care of this pr and award you when it is merged.

@kkawula kkawula closed this Jun 4, 2025
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 exclusion of the tests in CLI

4 participants