]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
tests/integration: mandatory self-checks before running
authorMarek Vavruša <marek.vavrusa@nic.cz>
Mon, 19 Jan 2015 11:12:05 +0000 (12:12 +0100)
committerMarek Vavruša <marek.vavrusa@nic.cz>
Mon, 19 Jan 2015 11:12:05 +0000 (12:12 +0100)
tests/pydnstest/test.py
tests/pydnstest/testserver.py
tests/test_integration.py

index 8e64e294df2dbf457841f66d6c05374ee4dcbef1..afbe66d982215965340b77b5a88700d918a3e557 100644 (file)
@@ -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
index de2e1077fd469e7b979304d252afe4d69b90ed05..0d72ebbdebae8d953e821d27589d65181435d44f 100644 (file)
@@ -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()
index 82c43f3a3bc2f9e9c6e5b11ed69b693c63caa90b..53fccc3031bb040fe1c2c6e4d5a3cac84ca0b9dc 100755 (executable)
@@ -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())