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

132 Add test match with spaces in braces #47

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions glob/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,12 @@ new_ec_test(braces_word_choice2 braces.in test.js "^choice=true[ \t\n\r]*$")
new_ec_test(braces_word_choice3 braces.in test.html "^choice=true[ \t\n\r]*$")
new_ec_test(braces_word_choice4 braces.in test.pyc "^[ \t\n\r]*$")

# word choice with spaces
new_ec_test(braces_word_choice5 braces.in test.py "^choice=true[ \t\n\r]*$")
cxw42 marked this conversation as resolved.
Show resolved Hide resolved
new_ec_test(braces_word_choice6 braces.in test.js "^choice=true[ \t\n\r]*$")
new_ec_test(braces_word_choice7 braces.in test.html "^choice=true[ \t\n\r]*$")
new_ec_test(braces_word_choice8 braces.in test.pyc "^[ \t\n\r]*$")
Copy link
Member

Choose a reason for hiding this comment

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

Remove line 132, which duplicates line 126.

Copy link
Author

Choose a reason for hiding this comment

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

Removed, how can i test that a extension is not matched based on choice=spaces might be nice to add a test like that what do you think?

Copy link
Member

@cxw42 cxw42 Sep 6, 2022

Choose a reason for hiding this comment

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

Ah! Sorry for misunderstanding. Yes, we can test for non-matching. However, the test filename has to be one that is not matched anywhere in the .in file. How about?---

-new_ec_test(braces_word_choice8 braces.in test.pyc "^[ \t\n\r]*$")
+new_ec_test(braces_word_choice8 braces.in test.NOMATCH "^[ \t\n\r]*$")

Edit why "has to be one that is not matched" --- the new_ec_test() function runs the core with the given inputs filename and returns all matching key/value pairs. So, if the .in file has multiple sections, you can't test for whether only one section matches.

Copy link
Author

Choose a reason for hiding this comment

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

Ah oke make sense, I thought it might be good idea to test a case that didn't match a specific selector as I had a case that didn't work for me see: editorconfig-checker/editorconfig-checker#198

If you think current test are enough I can agree :)


# single choice
new_ec_test(braces_single_choice braces.in {single}.b "^choice=single[ \t\n\r]*$")
new_ec_test(braces_single_choice_negative braces.in .b "^[ \t\n\r]*$")
Expand Down
4 changes: 4 additions & 0 deletions glob/braces.in
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ root=true
[*.{py,js,html}]
choice=true

; word choice with spaces
[*.{py, js, html}]
cxw42 marked this conversation as resolved.
Show resolved Hide resolved
choice=true
cxw42 marked this conversation as resolved.
Show resolved Hide resolved

; single choice
[{single}.b]
choice=single
Expand Down