From: Marek VavruĊĦa Date: Mon, 19 Jan 2015 11:12:05 +0000 (+0100) Subject: tests/integration: mandatory self-checks before running X-Git-Tag: v1.0.0-beta1~363^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=40d4f768beb792cdd81a121dfb7a415ca5f61cb3;p=thirdparty%2Fknot-resolver.git tests/integration: mandatory self-checks before running --- diff --git a/tests/pydnstest/test.py b/tests/pydnstest/test.py index 8e64e294d..afbe66d98 100644 --- a/tests/pydnstest/test.py +++ b/tests/pydnstest/test.py @@ -14,6 +14,8 @@ class Test: """ Run planned tests. """ planned = len(self.tests) passed = 0 + if planned == 0: + return print('[==========] Running %d test(s).' % planned) for name, test_callback, args in self.tests: @@ -25,10 +27,12 @@ class Test: except Exception as e: print('[ FAIL ] %s (%s)' % (name, str(e))) + # Clear test set + self.tests = [] print('[==========] %d test(s) run.' % planned) if passed == planned: print('[ PASSED ] %d test(s).' % passed) return 0 else: print('[ FAILED ] %d test(s).' % (planned - passed)) - return 1 + return 1 \ No newline at end of file diff --git a/tests/pydnstest/testserver.py b/tests/pydnstest/testserver.py index de2e1077f..0d72ebbde 100644 --- a/tests/pydnstest/testserver.py +++ b/tests/pydnstest/testserver.py @@ -124,16 +124,17 @@ def test_sendrecv(): if __name__ == '__main__': # Self-test code - if '--test' in sys.argv: - test = test.Test() - test.add('testserver/sendrecv', test_sendrecv) - sys.exit(test.run()) + test = test.Test() + test.add('testserver/sendrecv', test_sendrecv) + if test.run() != 0: + sys.exit(1) # Mirror server server = TestServer(None, socket.AF_INET, '127.0.0.1') - print('mirror server running at %s' % str(server.address())) + print('[==========] Mirror server running at %s' % str(server.address())) try: server.run() except KeyboardInterrupt: - pass + print('[==========] Shutdown.') + pass server.stop() diff --git a/tests/test_integration.py b/tests/test_integration.py index 82c43f3a3..53fccc303 100755 --- a/tests/test_integration.py +++ b/tests/test_integration.py @@ -150,16 +150,15 @@ def test_ipc(*args): if __name__ == '__main__': + # Self-tests first test = test.Test() - - # Self-test code - if '--test' in sys.argv: - test.add('integration/ipc', test_ipc) + test.add('integration/ipc', test_ipc) + if test.run() != 0: + sys.exit(1) else: # Scan for scenarios for arg in sys.argv[1:]: objects = find_objects(arg) for path in objects: test.add(path, play_object, path) - - sys.exit(test.run()) + sys.exit(test.run())