source: trunk/tester/tester.tcl @ 2027

Last change on this file since 2027 was 2027, checked in by braffert, 13 years ago
  • Property svn:executable set to *
File size: 4.7 KB
Line 
1#! /bin/sh
2# ----------------------------------------------------------------------
3#  RAPPTURE REGRESSION TESTER
4#
5#  This program will read a set of test xml files typically located in
6#  a tool's "tests" subdirectory, and provide an interactive test suite.
7#  The test xml files should contain a complete set of inputs and
8#  outputs for one run of an application.  In each test xml, a label
9#  must be located at the path test.label.  Test labels may be organized
10#  hierarchically by using dots to separate components of the test label
11#  (example: roomtemp.1eV).  A description may optionally be located at
12#  the path test.description.  Input arguments are the path to the
13#  tool.xml of the version being tested, and the path the the directory
14#  containing a set of test xml files.  If the arguments are missing,
15#  the program will attempt to locate them automatically.
16#
17#  USAGE: tester.tcl ?-tool tool.xml? ?-testdir tests?
18# ======================================================================
19#  AUTHOR:  Ben Rafferty, Purdue University
20#  Copyright (c) 2010  Purdue Research Foundation
21#
22#  See the file "license.terms" for information on usage and
23#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
24# ======================================================================
25#\
26exec tclsh "$0" $*
27# ----------------------------------------------------------------------
28# wish executes everything from here on...
29
30# TODO: Won't need this once tied in with the rest of the package
31lappend auto_path [file dirname $argv0]
32
33package require Itk
34package require Rappture
35package require RapptureGUI
36
37Rappture::getopts argv params {
38    value -tool ""
39    value -testdir ""
40}
41
42# If tool.xml and test directory locations are not given, try to find them.
43if {$params(-tool) == ""} {
44    if {[file exists tool.xml]} {
45        set params(-tool) tool.xml
46    } elseif {[file exists [file join rappture tool.xml]]} {
47        set params(-tool) [file join rappture tool.xml]
48    } else {
49        error "Cannot find tool.xml"
50    }
51}
52
53if {$params(-testdir) == ""} {
54    set tooldir [file dirname $params(-tool)]
55    if {[file isdirectory [file join $tooldir tests]]} {
56        set params(-testdir) [file join $tooldir tests]
57    } elseif {[file isdirectory [file join [file dirname $tooldir] tests]]} {
58        set params(-testdir) [file join [file dirname $tooldir] tests]
59    } else {
60        error "Cannot find test directory."
61    }
62}
63
64# ----------------------------------------------------------------------
65# INITIALIZE WINDOW
66# ----------------------------------------------------------------------
67wm title . "Rappture Regression Tester"
68panedwindow .pw
69.pw add [Rappture::Tester::TestTree .tree \
70    -testdir $params(-testdir) \
71    -toolxml $params(-tool) \
72    -selectcommand Rappture::Tester::selectionHandler]
73.pw add [frame .right]
74Rappture::Tester::TestView .right.view
75button .right.regoldenize -text "Regoldenize" -state disabled \
76    -command Rappture::Tester::regoldenize
77pack .right.regoldenize -side bottom -anchor e
78pack .right.view -side bottom -expand yes -fill both
79pack .pw -expand yes -fill both
80set lastsel ""
81
82# TODO: Handle resizing better
83# TODO: Fix error that occurs only when you click and hold on a test
84#       while the right hand side is empty
85
86# ----------------------------------------------------------------------
87# USAGE: selectionHandler
88#
89# Used internally to communicate between the test tree and the right
90# hand side viewer.  Upon selecting a new tree node, pass the focused
91# node's data to the right hand side.
92# ----------------------------------------------------------------------
93proc Rappture::Tester::selectionHandler {args} {
94    global lastsel
95    set test [.tree getTest]
96    if {$test != $lastsel} {
97        .right.view configure -test $test
98        if {$test != "" && [$test hasRan] && [$test getResult] != "Error"} {
99            .right.regoldenize configure -state normal
100        } else {
101            .right.regoldenize configure -state disabled
102        }
103        set lastsel $test
104    }
105}
106
107# ----------------------------------------------------------------------
108# USAGE: regoldenize
109#
110# Regoldenizes the currently focused test case.  Displays a warning
111# message.  If confirmed, copy the test information from the existing
112# test xml into the new result, and write the new data into the test
113# xml.
114# ----------------------------------------------------------------------
115proc Rappture::Tester::regoldenize {} {
116    set test [.tree getTest]
117    set testxml [$test getTestxml]
118    if {[tk_messageBox -type yesno -icon warning -message "Are you sure you want to regoldenize?\n$testxml will be overwritten."]} {
119        $test regoldenize
120        .tree refresh
121        selectionHandler
122    }
123}
124
Note: See TracBrowser for help on using the repository browser.