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

TST: Only skip/xfail tests whose ids exactly match #232

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

lithomas1
Copy link

No description provided.

@lithomas1 lithomas1 changed the title TST: Only xfail tests whose ids exactly match TST: Only skip/xfail tests whose ids exactly match Jan 24, 2024
@lithomas1 lithomas1 marked this pull request as ready for review January 24, 2024 23:44
@honno
Copy link
Member

honno commented Jan 25, 2024

Thanks for the PR but its intentional behaviour for skip/xfail'd tests to match multiple test cases, which is mostly useful for parametrized tests where adopters know they'll all fail.

@honno honno closed this Jan 25, 2024
@lithomas1
Copy link
Author

Thanks for the PR but its intentional behaviour for skip/xfail'd tests to match multiple test cases, which is mostly useful for parametrized tests where adopters know they'll all fail.

The problem, though is that it becomes impossible to skip some test cases without skipping other test cases that might not fail.

(e.g. skipping array_api_tests/test_array_object.py::test_setitem would also skip array_api_tests/test_array_object.py::test_setitem_masking )

@asmeurer
Copy link
Member

I asked @lithomas1 to open this PR.

Can we make it so this either matches the full test with the parameterization, or a full test name without the parameterization part? Verboseness is not an issue for a file, but specificity is.

@asmeurer asmeurer reopened this Jan 25, 2024
Copy link
Member

@honno honno left a comment

Choose a reason for hiding this comment

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

The problem, though is that it becomes impossible to skip some test cases without skipping other test cases that might not fail.

Ah I see.

Can we make it so this either matches the full test with the parameterization, or a full test name without the parameterization part? Verboseness is not an issue for a file, but specificity is.

I'll mull over but if you folks have an idea please update the PR. I don't think it's a good idea accepting this PR as-is because 1) it makes specifying parameterised tests very verbose 2) breaks existing configs without any warnings/etc.. I imagine some regex for pytest's square bracket syntax for atomic "parameter" test cases is what we'd want to look at, which would avoid the need to break existing configs too.

@asmeurer
Copy link
Member

Just to be sure, there are some warnings that are printed when an xfail doesn't match anything.

@lithomas1
Copy link
Author

I'll mull over but if you folks have an idea please update the PR. I don't think it's a good idea accepting this PR as-is because 1) it makes specifying parameterised tests very verbose 2) breaks existing configs without any warnings/etc.. I imagine some regex for pytest's square bracket syntax for atomic "parameter" test cases is what we'd want to look at, which would avoid the need to break existing configs too.

Maybe we can turn the lines of the skip file into a regex?

I think with a regex I can use $ to "end" the id I think. This works around my problem I think.

@lithomas1
Copy link
Author

I technically don't need this PR anymore (since I resolved the failures mentioned above), but this might still be a good idea regardless.

(e.g. I'm pretty sure this also happens for torch in array-api-compat
https://github.com/data-apis/array-api-compat/actions/runs/7590566384/job/20677289445#step:6:1588, where test_setitem is xfailed but test_setitem_masking xpasses)

@asmeurer
Copy link
Member

Making it a regex would be even more breaking than this. The [] in any current pattern would be treated as a character class in a regex, and so all skip files would need to be updated. We could add something like a regex: prefix to make a line match as a regex.

However, I'm currently not convinced that this change is an issue. Are there xfails files out there that are making use of this prefix logic?

@asmeurer
Copy link
Member

asmeurer commented Feb 6, 2024

Do we have reason to believe that it isn't enough to only accept

  • a test file (like array_api_tests/test_special_cases.py),
  • a test name (like array_api_tests/test_special_cases.py::test_binary), or
  • a full test with parameterization (like array_api_tests/test_special_cases.py::test_binary[__floordiv__(x1_i is +infinity and isfinite(x2_i) and x2_i > 0) -> +infinity])?

I don't see the value in accepting subsets other than those three cases, and trying to do so would risk lead to false positives like the test_setitem one.

The only thing I can think of is you might want to skip all parameterized tests for a given function like array_api_tests/test_special_cases.py::test_binary[__floordiv__], because maybe you know __floordiv__ can never work.

Another option would be to only match those three cases if the skip name starts with array_api_tests/, and do in matching only when it doesn't.

@honno
Copy link
Member

honno commented Feb 28, 2024

Do we have reason to believe that it isn't enough to only accept

  • a test file (like array_api_tests/test_special_cases.py),
  • a test name (like array_api_tests/test_special_cases.py::test_binary), or
  • a full test with parameterization (like array_api_tests/test_special_cases.py::test_binary[__floordiv__(x1_i is +infinity and isfinite(x2_i) and x2_i > 0) -> +infinity])?

I don't see the value in accepting subsets other than those three cases, and trying to do so would risk lead to false positives like the test_setitem one.

I don't have a sense of usage actually tbf, so maybe no one's currently skipping any of the parametrized tests. I am generally worried that for things like the special case tests, if you want to skip/xfail a whole test case, you'd have to manually specify 100+ cases.

I think with a regex I can use $ to "end" the id I think. This works around my problem I think.

Making it a regex would be even more breaking than this. The [] in any current pattern would be treated as a character class in a regex, and so all skip files would need to be updated. We could add something like a regex: prefix to make a line match as a regex.

I agree regex for things like this seems a bit too much esp. considering how square brackets, but it is a well-defined and well-known format in the end if we did want to skip parameterized tests (or even specifically a subset of parameters) 🤔

@asmeurer
Copy link
Member

asmeurer commented Mar 2, 2024

Maybe we could also extend it to allow skipping test_binary[__floordiv__] or something like that. Or we could rewrite the tests so that __floordiv__ is part of the test name.

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

3 participants