Skip to content

Commit

Permalink
Add test_labelme_1.py
Browse files Browse the repository at this point in the history
  • Loading branch information
wkentaro committed Jul 16, 2019
1 parent e02f2ee commit 11520c2
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 5 deletions.
8 changes: 3 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,17 +91,15 @@ script:
# Run flake8
- flake8 examples labelme setup.py tests

# Run help2man
- conda install -y help2man

# Run pytest
- pytest -v tests

- labelme --help
- labelme --version

# Run help2man
- conda install -y help2man
- help2man labelme > /tmp/labelme.1
- diff docs/man/labelme.1 /tmp/labelme.1 -I '^\.TH' -I '^\.\\"' -I '^config file'

# Run examples
- (cd examples/primitives && labelme_json_to_dataset primitives.json && rm -rf primitives_json)
- (cd examples/tutorial && rm -rf apc2016_obj3_json && labelme_json_to_dataset apc2016_obj3.json && python load_label_png.py && git checkout -- .)
Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@
sys.exit(1)

commands = [
'python tests/docs_tests/man_tests/test_labelme.1.py',
'git tag v{:s}'.format(version),
'git push origin master --tag',
'python setup.py sdist',
Expand Down
36 changes: 36 additions & 0 deletions tests/docs_tests/man_tests/test_labelme_1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/usr/bin/env python

from __future__ import print_function

import os.path as osp
import re
import shlex
import subprocess
import sys


here = osp.dirname(osp.abspath(__file__))

cmd = 'help2man labelme'
man_expected = subprocess.check_output(shlex.split(cmd)).decode().splitlines()

with open(osp.join(here, '../../../docs/man/labelme.1')) as f:
man_actual = f.read().splitlines()

patterns_exclude = [
r'^\.TH .*',
r'^config file.*',
]

FAIL = 0
for line_expected, line_actual in zip(man_expected, man_actual):
for pattern in patterns_exclude:
if re.match(pattern, line_expected) or re.match(pattern, line_actual):
break
else:
if line_expected != line_actual:
print(repr('> {}'.format(line_expected)), file=sys.stderr)
print(repr('< {}'.format(line_actual)), file=sys.stderr)
FAIL = 1

sys.exit(FAIL)

0 comments on commit 11520c2

Please sign in to comment.