Skip to content

Conversation

@hanneskaeufler
Copy link
Contributor

@hanneskaeufler hanneskaeufler commented Dec 13, 2019

Reference to a related issue in the repository

None - These are out of context quality of life improvements in the automated test suite

This PR contains #359 except from the branch pushed to the osi organization instead of to my fork. Maybe travis isn't configured to build fork PRs (I think this is the default due to potentially leaking env secrets into forks.)

Add a description

I saw some long-hanging fruit in improving these tests. I hope the commit messages do
well enough to explain the change/intention behind it. If not, feel free to comment on details :)
This PR switches the build to python3. Python2 is EOL in just a few days so I think it is reasonable to makes this switch (let me know if there are reasons not to do this!).

Check the checklist

  • My code and comments follow the style guidelines and contributors guidelines of this project.
  • I have performed a self-review of my own code.
  • I have made corresponding changes to the documentation.
  • My changes generate no new warnings.
  • I have added tests that prove my fix is effective or that my feature works.
  • New and existing unit tests / travis ci pass locally with my changes.

When forgetting to install the protobuf compiler,
an error message is shown which had a missing
space between two words.
There is no reason to traverse the file
line by line if all we care about is the
last character.

This also uses unittests subTest to show
the file which fails the test.
When one file is failing, due to the
fact that all tests contain for loops,
the other failures are swallowed because python
stops running the test on the first assertion.
With subTest one can introduce a subcontext which
allows showing all of the failed files as well a
diagnostic as to which file failed.
Python provides mechanisms for that, no
reason to manually track a count.
The globs where repeated a whole bunch of times
which is both information duplication as well
as unneccessary work.
There is no reason to guard the assertions
in the conditional.
for file in DOC_FILES:
with open(file, "rt") as fin, self.subTest(file=file):
for i, line in enumerate(fin, start=1):
self.assertNotRegex(line, r"([\s>]|^)#\w(\S)*", file + " in line " + str(i) + ": not permitted hash found.")
Copy link
Contributor Author

Choose a reason for hiding this comment

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

FAIL: test_hash (test_doxygen_output.TestDoxygenOutput) (file='doc/html/windows.html')
Test case is checking if there are illegal hash chars in the documentation. -> doxygen link not found.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "open-simulation-interface/tests/test_doxygen_output.py", line 17, in test_hash
    self.assertNotRegex(line, r"([\s>]|^)#\w(\S)*", file + " in line " + str(i) + ": not permitted hash found.")
AssertionError: Regex matched: '#lol' matches '([\\s>]|^)#\\w(\\S)*' in '#lol\n' : doc/html/windows.html in line 5: not permitted hash found.

I think the assertion message is good enough so that we dont need to manually add the offending section again.

Copy link
Contributor

Choose a reason for hiding this comment

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

You may be right!

Copy link
Contributor

Choose a reason for hiding this comment

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

Good point.

@hanneskaeufler hanneskaeufler force-pushed the hk-improve-tests branch 2 times, most recently from 63dfbd2 to 1a0dc73 Compare December 13, 2019 18:58
Python2 is end of life in just a few days
and should not be recommended anymore.
The error message is quite good when using the
provided regex matcher.
on:
branch: master
on:
branch: master
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Seems like this was indented incorrectly which caused PRs to deploy the docs :)

Copy link
Contributor

Choose a reason for hiding this comment

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

I think we have a new maintainer 💃

Copy link
Contributor

Choose a reason for hiding this comment

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

True thanks for finding :)

@jdsika jdsika added this to the v3.1.3 milestone Dec 13, 2019
@jdsika jdsika added the Quality Quality improvements. label Dec 13, 2019
Copy link
Contributor

@vkresch vkresch left a comment

Choose a reason for hiding this comment

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

LGTM

@vkresch vkresch merged commit cadbfe6 into master Dec 17, 2019
@hanneskaeufler hanneskaeufler deleted the hk-improve-tests branch December 17, 2019 09:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Quality Quality improvements.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants