-
Notifications
You must be signed in to change notification settings - Fork 103
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
Test suite: Permit editorconfig programs to provide correct output lines in any order #375
Comments
See editorconfig/editorconfig#375. Rather than testing for multiple lines with one regex, test for them with one regex per line.
You are right they shouldn't be required. IMO this is indeed a bug in the test suite. |
Thanks! I'll finish working through the tests and then submit a PR in editorconfig-core-test, unless you have a different preference. |
Now each line of the output is tested by a separate test and a separate regex. Re. editorconfig/editorconfig#375.
@cxw42 Thanks! Shall we give it a few days in case I may miss something? @editorconfig/developers am I right that currently no one is using the specific order of output by EditorConfig cores? Once the test cases change, we will loose the output by allowing different orderings of property value pairs. |
I am not against the core idea of this proposal - i.e. to change the tests in such a way that the order in the returned set of properties is not significant. At the same time, I am against how the proposal is implemented in cxw42/editorconfig-core-test@99187fc . The strategy used there, namely
Substantially changes the semantics of the tests. Before the change, the returned results are often combined from multiple sections. After the tests the combination is not there and the combination logic in the tested editorconfig processors is not executed. Please find a different way how to reach your goal. |
I think @ppalaga 's comments make sense. In particular, you can modify new_ec_test to easily alter test cases. |
@ppalaga Thanks for your feedback! I am not sure I quite understand. Would you please look at new commit c82e1ab and see if it covers the case you are thinking of? For a target of I agree that for tests of multiple files in one run (INI-format I also agree that a test per output line is insufficient if an That said, we can use the brute-force approach of Currently, editorconfig-core-test requires CMake 2.6+ (according to its CMakeLists.txt). If we could bump that up to 3.0+, we would have more string- and list-manipulation support. With 3.0+, we might be able to generate all the different orders programmatically, which would remove the typo risk. We would just have to be careful about semicolons (CMake list separators), which I don't think would be an issue. What say you all? |
@cxw42 my vote was against splitting the tests as done in https://github.com/cxw42/editorconfig-core-test@99187fc . cxw42/editorconfig-core-test@c82e1ab adds a few tests, but the original tests are still split, and the general idea of banning tests returning multiple lines is still present, which I still do not find good.
Yes, that one is impractical.
I personally have no problem with that. Travis [1] has 3.9.2 and AppVeyor [2] has 3.11.0.
I hoped for this kind of solution. [1] https://travis-ci.org/ec4j/ec4j/jobs/369715134#L66 |
@ppalaga Two things that just occurred to me before I go off and write code that will generate 120 permutations in one test to replace the five tests in c82e1ab. So that I understand where you're coming from, is your objection philosophical or based on a failure case you've seen before? I'd still be interested to see an incorrect core that passes under test-per-line (other than a core deliberately written to output individual lines in the order expected by the tests!). 1Would you be comfortable with the one-line-per-test approach if we also tested against the expected number of lines of output? For example, if editorconfig should output
then use three tests:
That is, test that there are exactly two lines of output (the new one; keys off the 2In CMake 3.0.2+, we can use |
I do not remember any particular failure like that. I am a co-author of an EditorConfig parser written in Java that is tested using the core test suite and I occasionally contribute to the test suite. I understand your original proposal so that it imposes an informal policy for the current and future tests that at most one returned line can be tested per test. To reach that, you either have to (a) change the output of the given test (thus changing the semantics) or (b) split the tests thus worsening maintainability of the tests. I admit I have not looked properly if you did (a) or (b) and I am sorry for that. I think both (a) and (b) is bad. I prefer such a solution that allows for writing concise and correct tests. Googling for who is using the suite [1] reveals that there are at least 10 implementations there ( I hope for something like
instead of the current
I have no idea whether this is possible with the cmake scripting. |
Or even better change
|
Hi Peter!
Am 2018-10-19 um 10:24 schrieb Peter Palaga:
[...]
I hope for something like
|new_ec_test(star_matches_dot_file_after_slash star.in
Bar/.editorconfig any_order("keyb=valueb", "keyc=valuec")) |
instead of the current
|new_ec_test(star_matches_dot_file_after_slash star.in
Bar/.editorconfig "^keyb=valueb[ \t\n\r]*keyc=valuec[ \t\n\r]*$") |
I have no idea whether this is possible with the cmake scripting.
No, It's not. But cmake parameter lists can have arbitary length:
|new_ec_test(star_matches_dot_file_after_slash star.in Bar/.editorconfig
"^keyb=valueb[ \t\n\r]*$" "^keyc=valuec[ \t\n\r]*$")|
Adittionally it is possible to have self-defined keywords in the
parameter list, something like named parameters. Those or by convention
completely uppercase. This may look like
|new_ec_test(star_matches_dot_file_after_slash star.in Bar/.editorconfig
REGEXP "^keyb=valueb|||[ \t\n\r]*$|" "^keyc=valuec||||[ \t\n\r]*$|| "))|
The keyword is not really needed, but its use makes it easier to extend
the parameter list of|new_ec_test |further if necessary. For example for
full matches without regexp for easy cases:
|new_ec_test(star_matches_dot_file_after_slash star.in Bar/.editorconfig
MATCH "keyb=valueb||||" "keyc=valuec"||))|
Maybe it is useful to add other keywords, too:
|new_ec_test(TEST star_matches_dot_file_after_slash FILE star.in
EDITORCONFIG_FILE Bar/.editorconfig MATCH "keyb=valueb||||" "keyc=valuec"||))|
Herbert
|
@ppalaga Thanks for the explanation! I understand communication challenges, and why those challenges cause you to prefer keeping the existing structure. I am almost done with a core in native VimScript (to replace the current Vim plugin+Py core), so the number of projects to communicate among will be even higher in the near future :) . @hgraeber Thanks for pointing out those options! I will start with the simple case (arbitrary number of regexes) and see about more flexible argument handling later if appropriate based on feedback. |
See editorconfig/editorconfig#375. NOTE: requires CMake 3.1.0+. New function ec_test_lines() will test for up to three lines in any order. The limit of three lines is because CMake is limited to nine groups in a single regex (as far as I know), and each line requires one group in this implementation.
Uses new ec_test_lines function where appropriate. I left some tests as express alternations because I thought it made more sense given what those are testing for. editorconfig/editorconfig#375
Uses new ec_test_lines function where appropriate. I left some tests as express alternations because I thought it made more sense given what those are testing for. editorconfig/editorconfig#375
See editorconfig/editorconfig#375. NOTE: requires CMake 3.1.0+. New function ec_test_lines() will test for up to three lines in any order. The limit of three lines is because CMake is limited to nine groups in a single regex (as far as I know), and each line requires one group in this implementation.
Uses new ec_test_lines function where appropriate. I left some tests as express alternations because I thought it made more sense given what those are testing for. editorconfig/editorconfig#375
All, my next take is in the anyorder branch. On Cygwin, the C core and my Vimscript core* pass all the tests in this branch. Here's the comparison. In short:
Shall I submit a PR now and move the discussion there, or would you prefer to continue on this thread? Also, I can squash before submitting the PR if you wish, or you can squash later. Note: I decided to require CMake 3.1.0 instead of CMake 3.0.0. This is because 3.1.0 introduces the sane argument handling in Thanks!
|
Thanks, I like this. Just maybe replace |
As requested by @ppalaga in editorconfig/editorconfig#375
@ppalaga Done! All, one thing I forgot to mention - the current version is limited to three lines. That is because:
Does that concern anyone? I could permit more than three lines if we also added an option to the editorconfig to output a blank line before any other output, because then start-of-line would just be |
Assuming there is no test in the suite nowadays working with more than three lines, what happens when somebody uses more than three expressions in |
- Adds new ec_test_lines function that adds a test accepting multiple output lines in any order. - Rewrites the pertinent tests to use ec_test_lines. - Bumps the required CMake version up to 3.1.0. Fixes editorconfig/editorconfig#375.
All, PR editorconfig/editorconfig-core-test#22 is open for your consideration. Thanks! |
- Adds new ec_test_lines function that adds a test accepting multiple output lines in any order. - Rewrites the pertinent tests to use ec_test_lines. - Bumps the required CMake version up to 3.1.0. - Removes multi_section tests.* Fixes editorconfig/editorconfig#375. *See editorconfig#22 (comment) and subsequent discussion
@xuhdev editorconfig/editorconfig-core-test#22 is ready for merging per @ppalaga. It looks like you are the most common committer in that repo - do you need anything else from me before merging? Are you comfortable with the changes? Thanks! Edit for later readers - editorconfig/editorconfig-core-test#22 was closed at the maintainers' request. A different PR will be coming soon! |
- Adds new ec_test_lines function that adds a test accepting multiple output lines in any order. - Rewrites the pertinent tests to use ec_test_lines. - Bumps the required CMake version up to 3.5.0 per @xuhdev - Removes multi_section tests.* Fixes editorconfig/editorconfig#375. Also includes changes at and after editorconfig#22 (comment)
At least the lowercase-value tests beginning here check for two or more lines of output in succession using
^(line1)(line2)$
(in essence). This requires thatline1
andline2
be output in that order. (CMake regex reference)However, I cannot find any documentation here, in the editorconfig-core-test issues, in #22 , on https://editorconfig.org, or in the Doxygen output, that specifies that requirement.
As far as I can tell, the test requires the options be output in the same order they are given in the .editorconfig file. Is that indeed a requirement? It seems somewhat brittle to me.
Would it be possible to change the spec and tests so that the output lines from the
editorconfig
program can appear in any order?Edit
Adding both orders to the test case is a brute-force option, but it works. For example:
Edit 2 The linked commit is a better way to fix it, in my opinion - test for each line with a separate regex.
The text was updated successfully, but these errors were encountered: