Skip to content

Commit

Permalink
Merge pull request #40 from melexis/integration-test
Browse files Browse the repository at this point in the history
Integration test start: JUnit
  • Loading branch information
SteinHeselmans authored Aug 11, 2017
2 parents fd73eb1 + c9788c8 commit d90dcc2
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/mlx/warnings.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ def return_check_limits(self, name = None):
return 0


def main():
def warnings_wrapper(args):
parser = argparse.ArgumentParser(prog='mlx-warnings')
group = parser.add_mutually_exclusive_group(required=True)
group.add_argument('-d', '--doxygen', dest='doxygen', action='store_true')
Expand All @@ -314,7 +314,7 @@ def main():
parser.add_argument('--version', action='version', version='%(prog)s {version}'.format(version=pkg_resources.require('mlx.warnings')[0].version))

parser.add_argument('logfile', nargs='+', help='Logfile that might contain warnings')
args = parser.parse_args()
args = parser.parse_args(args)

warnings = WarningsPlugin(sphinx=args.sphinx, doxygen=args.doxygen, junit=args.junit, verbose=args.verbose)
warnings.set_maximum(args.maxwarnings)
Expand All @@ -332,7 +332,11 @@ def main():
warnings.check(loghandle.read().encode('utf-8'))

warnings.return_count()
sys.exit(warnings.return_check_limits())
return warnings.return_check_limits()


def main():
sys.exit(warnings_wrapper(sys.argv[1:]))


if __name__ == '__main__':
Expand Down
37 changes: 37 additions & 0 deletions tests/test_integration.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
from unittest import TestCase

from mlx.warnings import warnings_wrapper


class TestIntegration(TestCase):

junit_warning_cnt = 3

def test_single_argument(self):
retval = warnings_wrapper(['--junit', 'tests/junit_single_fail.xml'])
self.assertEqual(1, retval)

def test_two_arguments(self):
retval = warnings_wrapper(['--junit', 'tests/junit_single_fail.xml', 'tests/junit_double_fail.xml'])
self.assertEqual(1 + 2, retval)

def test_wildcarded_arguments(self):
# note: no shell expansion simulation (e.g. as in windows)
retval = warnings_wrapper(['--junit', 'tests/junit*.xml'])
self.assertEqual(self.junit_warning_cnt, retval)

def test_max(self):
retval = warnings_wrapper(['--junit', '--maxwarnings', '2', 'tests/junit*.xml'])
self.assertEqual(self.junit_warning_cnt, retval)

def test_max_but_still_ok(self):
retval = warnings_wrapper(['--junit', '--maxwarnings', '100', 'tests/junit*.xml'])
self.assertEqual(0, retval)

def test_min(self):
retval = warnings_wrapper(['--junit', '--maxwarnings', '100', '--minwarnings', '100', 'tests/junit*.xml'])
self.assertEqual(self.junit_warning_cnt, retval)

def test_min_but_still_ok(self):
retval = warnings_wrapper(['--junit', '--maxwarnings', '100', '--minwarnings', '2', 'tests/junit*.xml'])
self.assertEqual(0, retval)

0 comments on commit d90dcc2

Please sign in to comment.