Page MenuHomeSoftware Heritage

Make command-line tests a bit more resilient
ClosedPublic

Authored by olasd on Nov 27 2020, 4:40 PM.

Details

Summary

We now match the command line output per section, in a fuzzier way than before.

Test Plan

tox tests updated

Diff Detail

Repository
rDCORE Foundations and core functionalities
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

Build is green

Patch application report for D4626 (id=16414)

Rebasing onto 6f9779f4ab...

Current branch diff-target is up to date.
Changes applied before test
commit 4be641cb96af2f29b073f4199c206230709d6beb
Author: Nicolas Dandrimont <nicolas@dandrimont.eu>
Date:   Fri Nov 27 15:16:30 2020 +0100

    Make command-line tests a bit more resilient
    
    We now match the command line output per section, in a fuzzier way than before.

See https://jenkins.softwareheritage.org/job/DCORE/job/tests-on-diff/170/ for more details.

vlorentz added inline comments.
swh/core/tests/test_cli.py
29–45

That's equivalent to this code: re.match(f"^{re.escape(section)}.*?\n\n", cli_output, re.MULTILINE).group(0).splitlines() (assuming there is a match), right?

The regexp is easier to read IMO; but either is fine.

29–45

and with re.DOTALL *

swh/core/tests/test_cli.py
29–45

Well the code only keeps indented lines as section contents, so it's a bit more subtle than the regexp. I've done this because the Usage section has an empty line between the header and the contents, which breaks that regexp approach.

This revision is now accepted and ready to land.Dec 2 2020, 10:39 AM