[Mumps2Py:] [52] added support for adding a test case to the regression test suite, and for running the test suite.

[ Thread Index | Date Index | More lists.mumps2py.org/discuss Archives ]


Revision: 52
Author:   pgallot
Date:     2008-01-24 21:42:49 +0000 (Thu, 24 Jan 2008)

Log Message:
-----------
added support for adding a test case to the regression test suite, and for running the test suite.  Also did a bit of clean-up, separating out the more generic UI constructs to a GenericUI class which Mumps2pyUI inherits from.

Modified Paths:
--------------
    trunk/mumps2py_ui.pyw


Modified: trunk/mumps2py_ui.pyw
===================================================================
--- trunk/mumps2py_ui.pyw	2008-01-24 21:27:34 UTC (rev 51)
+++ trunk/mumps2py_ui.pyw	2008-01-24 21:42:49 UTC (rev 52)
@@ -19,6 +19,7 @@
 
 import os, re, fileinput
 import mumps2py.mumps_module, mumps2py.mumps2tok, mumps2py.tok2python
+import mumps2py_test
 
 
 from Tkinter import *
@@ -28,42 +29,23 @@
 if os.path.isfile('optionDB'):
     ROOT.option_readfile('optionDB')
 
-class Mumps2pyUI:
-    """The class which provides the User Interface to Mumps2Py"""
+class GenericUI:
+    """ class for providing misc. UI shortcuts."""
     def __init__(self, my_root):
-        self.modules = None
+        """initialize a Generic_UI object"""
         self.root = my_root
-        self.before_window = None
-        self.after_window = None
-   
-    def help_about(self):
-        """pop up a dialog showing licensing/waranty information"""
+
+    def message(self, msg):
+        """pop up a dialog showing a message"""
         popup = Toplevel(self.root)
         popup.transient(self.root)
-        popup.title = "About Mumps2Py"
-        msg = """
-Mumps2Py Copyright (C) 2008  Patrick Gallot
-
-Mumps2Py is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-Mumps2Py is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with Mumps2Py.  If not, see <http://www.gnu.org/licenses/>.
-"""
         Label(popup, text = msg).grid(row = 1, column = 1)
         btn = Button(popup, text = "OK", takefocus = YES)
         btn.grid(row = 2, column = 1)
         btn.bind('<Button-1>', lambda event, p = popup: (p.destroy()))
         btn.bind('<KeyPress-Return>', lambda event, p = popup: (p.destroy())) 
         btn.focus_set()
-
+        
     def popup_entry(self, msg, entry_width, callback):
         """ generic pop-up query for a single value."""
         popup = Toplevel(self.root)
@@ -112,6 +94,36 @@
 
         return info_window
 
+    
+class Mumps2pyUI(GenericUI):
+    """The class which provides the User Interface to Mumps2Py"""
+    def __init__(self, my_root):
+        """ initialize a Mumps2pyUI object"""
+        GenericUI.__init__(self, my_root)
+        self.modules = None
+        self.before_window = None
+        self.after_window = None
+   
+    def help_about(self):
+        """pop up a dialog showing licensing/waranty information"""
+        msg = """
+Mumps2Py Copyright (C) 2008  Patrick Gallot
+
+Mumps2Py is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+Mumps2Py is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with Mumps2Py.  If not, see <http://www.gnu.org/licenses/>.
+"""
+        self.message(msg)
+        
     def display_before(self, filename, line_start = 1, line_end = -1):
         """populate the before window with the Mumps module's raw source code"""
         self.before_window.delete(0.0, END)
@@ -289,12 +301,25 @@
             print "*** Output from %s ***" % exec_file
             execfile(exec_file, {}, {})
 
+    def regr_test_run(self):
+        """ launches the regression tests, displays the results."""
+        mumps2py_test.run_regression_tests()
+        
+        result_file = open("test_results.txt", "r")
+        results_window = self.info_window()
+        for line in result_file:
+            results_window.insert(END, line)
 
-    def make_dialog(self):
-        """Set up the User Interface"""
-        self.root.title('Mumps2Py')
-        menu_bar = Frame( self.root, relief = RAISED, borderwidth = 2)
-        menu_bar.pack(fill = X)
+    def add_regr_test(self):
+        """ adds a file to the regression test suite."""
+        if self.modules and len(self.modules) == 1:
+            test_file = self.modules[0].input_file
+
+            mumps2py_test.add_regression_test(test_file)
+            self.message(test_file + " added.")
+    
+    def make_dialog_menus(self, menu_bar):
+        """Set up the User Interface's menus"""
         file_btn = Menubutton(menu_bar, text = 'File', underline = 0,
                              takefocus = TRUE)
         file_btn.pack(side = LEFT, padx = "2m")
@@ -342,6 +367,12 @@
         run_btn.menu.add_command( label="Save and run", \
                                   underline = 1, \
                                   command = (lambda s = self: s.save_and_run()))
+        run_btn.menu.add_command( label="Regression test run", \
+                                  underline = 1, \
+                                  command = (lambda s = self: s.regr_test_run()))
+        run_btn.menu.add_command( label="Add regression test", \
+                                  underline = 1, \
+                                  command = (lambda s = self: s.add_regr_test()))
         run_btn['menu'] = run_btn.menu
         menu_bar.tk_menuBar(run_btn)
 
@@ -354,6 +385,13 @@
                                   command = (lambda s = self: s.help_about()))
         help_btn['menu'] = help_btn.menu
         menu_bar.tk_menuBar(help_btn)
+        
+    def make_dialog(self):
+        """Set up the User Interface"""
+        self.root.title('Mumps2Py')
+        menu_bar = Frame( self.root, relief = RAISED, borderwidth = 2)
+        menu_bar.pack(fill = X)
+        self.make_dialog_menus(menu_bar)
 
         before_frame = Frame(self.root, borderwidth = 2)
         self.before_window = Text( before_frame, \


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/