mailr23882 - in /branches/frame_order_cleanup: ./ test_suite/test_suite_runner.py


Others Months | Index by Date | Thread Index
>>   [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Header


Content

Posted by edward on June 12, 2014 - 15:29:
Author: bugman
Date: Thu Jun 12 15:29:14 2014
New Revision: 23882

URL: http://svn.gna.org/viewcvs/relax?rev=23882&view=rev
Log:
Merged revisions 23881 via svnmerge from 
svn+ssh://bugman@xxxxxxxxxxx/svn/relax/trunk

........
  r23881 | bugman | 2014-06-12 14:47:31 +0200 (Thu, 12 Jun 2014) | 8 lines
  
  Better handling of the control-C keyboard interrupt signal in the relax 
test suite.
  
  This includes two changes.  The Python 2.7 and higher 
unittest.installHandler() function is now
  called, when present, to terminate all tests using the unittest module 
control-C handler.  The
  second change is that the keyboard interrupt signal is caught in a 
try-except statement, a message
  printed out, and the tests terminated.  This should be an improvement for 
all systems.
........

Modified:
    branches/frame_order_cleanup/   (props changed)
    branches/frame_order_cleanup/test_suite/test_suite_runner.py

Propchange: branches/frame_order_cleanup/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Thu Jun 12 15:29:14 2014
@@ -1 +1 @@
-/trunk:1-23789
+/trunk:1-23881

Modified: branches/frame_order_cleanup/test_suite/test_suite_runner.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/frame_order_cleanup/test_suite/test_suite_runner.py?rev=23882&r1=23881&r2=23882&view=diff
==============================================================================
--- branches/frame_order_cleanup/test_suite/test_suite_runner.py        
(original)
+++ branches/frame_order_cleanup/test_suite/test_suite_runner.py        Thu 
Jun 12 15:29:14 2014
@@ -27,6 +27,7 @@
 import sys
 if dep_check.wx_module:
     import wx
+import unittest
 
 # Formatting.
 from test_suite.formatting import summary_line
@@ -87,133 +88,192 @@
         else:
             self.runner = RelaxTestRunner(stream=sys.stdout, timing=timing)
 
+        # Let the tests handle the keyboard interrupt (for Python 2.7 and 
higher).
+        if hasattr(unittest, 'installHandler'):
+            unittest.installHandler()
+
 
     def run_all_tests(self):
         """Execute all of the test suite test types."""
 
         # Execute the system/functional tests.
         if 'system' in self.categories:
-            self.run_system_tests(summary=False)
+            status = self.run_system_tests(summary=False)
+            if not status:
+                return
 
         # Execute the unit tests.
         if 'unit' in self.categories:
-            self.run_unit_tests(summary=False)
+            status = self.run_unit_tests(summary=False)
+            if not status:
+                return
 
         # Execute the GUI tests.
         if 'gui' in self.categories:
-            self.run_gui_tests(summary=False)
+            status = self.run_gui_tests(summary=False)
+            if not status:
+                return
 
         # Execute the GUI tests.
         if 'verification' in self.categories:
-            self.run_verification_tests(summary=False)
+            status = self.run_verification_tests(summary=False)
+            if not status:
+                return
 
         # Print out a summary of the test suite.
         self.summary()
 
 
+
     def run_gui_tests(self, summary=True):
         """Execute the GUI tests.
+
+        @keyword summary:   A flag which if True will cause a summary to be 
printed.
+        @type summary:      bool
+        @return:            True if the tests were run, False if a 
KeyboardInterrupt occurred.
+        @rtype:             bool
+        """
+
+        # Run the tests, catching the keyboard interrupt.
+        try:
+            # Print a header.
+            title(file=sys.stdout, text='GUI tests')
+
+            # Run the tests.
+            if dep_check.wx_module:
+                # Set up the GUI if needed (i.e. not in GUI mode already).
+                app = wx.GetApp()
+                if app == None:
+                    # Initialise.
+                    app = wx.App(redirect=False)
+
+                    # Build the GUI.
+                    app.gui = relax_gui.Main(parent=None, id=-1, title="")
+
+                # Execute the GUI tests.
+                gui_runner = GUI_test_runner()
+                self.runner.category = 'gui'
+                self.gui_result = gui_runner.run(self.tests, 
runner=self.runner)
+
+                # Clean up for the GUI, if not in GUI mode.
+                if status.test_mode:
+                    # Terminate the interpreter thread to allow the tests to 
cleanly exit.
+                    interpreter_thread = interpreter.Interpreter()
+                    interpreter_thread.exit()
+
+                    # Stop the GUI main loop.
+                    app.ExitMainLoop()
+
+            # No wx module installed.
+            else:
+                print("All GUI tests skipped due to the missing/broken wx 
module.\n")
+                self.gui_result = 'skip'
+
+            # Print out a summary of the test suite.
+            if summary:
+                self.summary()
+
+        # Catch the keyboard interrupt.
+        except KeyboardInterrupt:
+            print("\nKeyboardInterrupt:  Terminating all tests.\n")
+            return False
+
+        # All tests were run successfully.
+        return True
+
+
+    def run_system_tests(self, summary=True):
+        """Execute the system/functional tests.
+
+        @keyword summary:   A flag which if True will cause a summary to be 
printed.
+        @type summary:      bool
+        @return:            True if the tests were run, False if a 
KeyboardInterrupt occurred.
+        @rtype:             bool
+        """
+
+        # Run the tests, catching the keyboard interrupt.
+        try:
+            # Print a header.
+            title(file=sys.stdout, text='System / functional tests')
+
+            # Run the tests.
+            system_runner = System_test_runner()
+            self.runner.category = 'system'
+            self.system_result = system_runner.run(self.tests, 
runner=self.runner)
+
+            # Print out a summary of the test suite.
+            if summary:
+                self.summary()
+
+        # Catch the keyboard interrupt.
+        except KeyboardInterrupt:
+            print("\nKeyboardInterrupt:  Terminating all tests.\n")
+            return False
+
+        # All tests were run successfully.
+        return True
+
+
+    def run_unit_tests(self, summary=True):
+        """Execute the unit tests.
+
+        @keyword summary:   A flag which if True will cause a summary to be 
printed.
+        @type summary:      bool
+        @return:            True if the tests were run, False if a 
KeyboardInterrupt occurred.
+        @rtype:             bool
+        """
+
+        # Run the tests, catching the keyboard interrupt.
+        try:
+            # Print a header.
+            title(file=sys.stdout, text='Unit tests')
+
+            # Run the tests.
+            unit_runner = 
Unit_test_runner(root_path=status.install_path+os.sep+'test_suite'+os.sep+'unit_tests')
+            self.runner.category = 'unit'
+            self.unit_result = unit_runner.run(runner=self.runner)
+
+            # Print out a summary of the test suite.
+            if summary:
+                self.summary()
+
+        # Catch the keyboard interrupt.
+        except KeyboardInterrupt:
+            print("\nKeyboardInterrupt:  Terminating all tests.\n")
+            return False
+
+        # All tests were run successfully.
+        return True
+
+
+    def run_verification_tests(self, summary=True):
+        """Execute the software verification tests.
 
         @keyword summary:   A flag which if True will cause a summary to be 
printed.
         @type summary:      bool
         """
 
-        # Print a header.
-        title(file=sys.stdout, text='GUI tests')
-
-        # Run the tests.
-        if dep_check.wx_module:
-            # Set up the GUI if needed (i.e. not in GUI mode already).
-            app = wx.GetApp()
-            if app == None:
-                # Initialise.
-                app = wx.App(redirect=False)
-
-                # Build the GUI.
-                app.gui = relax_gui.Main(parent=None, id=-1, title="")
-
-            # Execute the GUI tests.
-            gui_runner = GUI_test_runner()
-            self.runner.category = 'gui'
-            self.gui_result = gui_runner.run(self.tests, runner=self.runner)
-
-            # Clean up for the GUI, if not in GUI mode.
-            if status.test_mode:
-                # Terminate the interpreter thread to allow the tests to 
cleanly exit.
-                interpreter_thread = interpreter.Interpreter()
-                interpreter_thread.exit()
-
-                # Stop the GUI main loop.
-                app.ExitMainLoop()
-
-        # No wx module installed.
-        else:
-            print("All GUI tests skipped due to the missing/broken wx 
module.\n")
-            self.gui_result = 'skip'
-
-        # Print out a summary of the test suite.
-        if summary:
-            self.summary()
-
-
-    def run_system_tests(self, summary=True):
-        """Execute the system/functional tests.
-
-        @keyword summary:   A flag which if True will cause a summary to be 
printed.
-        @type summary:      bool
-        """
-
-        # Print a header.
-        title(file=sys.stdout, text='System / functional tests')
-
-        # Run the tests.
-        system_runner = System_test_runner()
-        self.runner.category = 'system'
-        self.system_result = system_runner.run(self.tests, 
runner=self.runner)
-
-        # Print out a summary of the test suite.
-        if summary:
-            self.summary()
-
-
-    def run_unit_tests(self, summary=True):
-        """Execute the unit tests.
-
-        @keyword summary:   A flag which if True will cause a summary to be 
printed.
-        @type summary:      bool
-        """
-
-        # Print a header.
-        title(file=sys.stdout, text='Unit tests')
-
-        # Run the tests.
-        unit_runner = 
Unit_test_runner(root_path=status.install_path+os.sep+'test_suite'+os.sep+'unit_tests')
-        self.runner.category = 'unit'
-        self.unit_result = unit_runner.run(runner=self.runner)
-
-        # Print out a summary of the test suite.
-        if summary:
-            self.summary()
-
-
-    def run_verification_tests(self, summary=True):
-        """Execute the software verification tests.
-
-        @keyword summary:   A flag which if True will cause a summary to be 
printed.
-        @type summary:      bool
-        """
-
-        # Print a header.
-        title(file=sys.stdout, text='Software verification tests')
-
-        # Run the tests.
-        verification_runner = Verification_test_runner()
-        self.runner.category = 'verification'
-        self.verification_result = verification_runner.run(self.tests, 
runner=self.runner)
-
-        # Print out a summary of the test suite.
-        if summary:
-            self.summary()
+        # Run the tests, catching the keyboard interrupt.
+        try:
+            # Print a header.
+            title(file=sys.stdout, text='Software verification tests')
+
+            # Run the tests.
+            verification_runner = Verification_test_runner()
+            self.runner.category = 'verification'
+            self.verification_result = verification_runner.run(self.tests, 
runner=self.runner)
+
+            # Print out a summary of the test suite.
+            if summary:
+                self.summary()
+
+        # Catch the keyboard interrupt.
+        except KeyboardInterrupt:
+            print("\nKeyboardInterrupt:  Terminating all tests.\n")
+            return False
+
+        # All tests were run successfully.
+        return True
 
 
     def summary(self):




Related Messages


Powered by MHonArc, Updated Thu Jun 12 16:00:02 2014