Skip to content

regression tests: Move dot usage to textfile

More than once, i've been bit by whitespace changes that snuck into commits submitted with an MR, something I'm probably not alone in.

My typical solution to that would be to propose the addition of an .editorconfig file to the repository root, providing a means of defining project-standard parameters for code formatting, including: Line-endings, indent style (tabs or spaces) and size of indents, character set, trailing newline requirements, and trailing whitespace handling. .editorconfig files with those "core" settings enjoy widespread support in nearly all text editors typically used to edit source code, either built-in or by means of a plugin. (Some editors support a far wider range of non-standard settings, but they'll be ignored by most/all others.)

I intend to propose the creation of an .editorconfig here, as well. And one of the settings that would be helpful to define for most source code files is trim_trailing_whitespace. Having that parameter defined (and this MR merged) would've prevented both of the code-review issues linked above.

However! The trim_trailing_whitespace setting cannot be enabled for tests/test_regression.py, as long as its Python code contains embedded string data where trailing whitespace is significant and must be preserved.

The simplest solution to this problem is to move the trailing-whitespace-dependent string data out of the Python source and into a separate text file, which (a) won't be edited by anyone making code changes, and (b) for extra safety, can be explicitly configured in the .editorconfig to have its trim_trailing_whitespace option turned OFF.

So, this MR does exactly that, and only that: It takes the dot usage output previously embedded in the test_regression.py file as a """...""" string, and moves it to a separate text file in the directory. The test code then loads that file's contents into a string at runtime. This frees tests/test_regression.py from any dependence on trailing whitespace internal to its own source, and opens up the possibility of configuring it with trim_trailing_whitespace = true.

Edited by FeRD (Frank Dana)

Merge request reports