Changeset 1964 for trunk/tester


Ignore:
Timestamp:
Nov 25, 2010, 5:54:57 PM (14 years ago)
Author:
braffert
Message:

Developing regression tester

Location:
trunk/tester
Files:
1 deleted
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/tester/mainwin.tcl

    r1963 r1964  
    33#
    44#  This widget acts as the main window for the Rappture regression
    5 #  tester.  Constructor accepts the location of the new version to be
    6 #  tested, and the location of a directory containg test xml files.
     5#  tester.  Constructor accepts the location of the tool.xml of the new
     6#  version to be tested, and the location of a directory containg test
     7#  xml files.
    78# ======================================================================
    89#  AUTHOR:  Ben Rafferty, Purdue University
     
    2122    inherit itk::Toplevel
    2223
    23     constructor {tooldir testdir} { #defined later }
     24    constructor {toolxml testdir args} { #defined later }
    2425    public method runAll {}
    2526    public method runSelected {}
     
    2829
    2930    private variable _testdir
    30     private variable _tooldir
    3131    private variable _toolxml
    3232
     
    4242}
    4343
    44 itcl::body Rappture::Regression::MainWin::constructor {tooldir testdir} {
     44itcl::body Rappture::Regression::MainWin::constructor {toolxml testdir args} {
    4545    puts "Constructing MainWin."
    4646
    47     # TODO: Replace explicit constructor arguments with "args"
    48     #       If tooldir is not given, use current directory.
    49     #       If testdir is not given, look for it inside of tooldir.
    50     if {[file isdirectory $tooldir]} {
    51         set _tooldir $tooldir
     47    if {[file exists $toolxml]} {
     48        set _toolxml $toolxml
    5249    } else {
    53         # TODO: Properly format error messages
    54         error "Given tooldir is not a directory."
     50        error "File \"$toolxml\" does not exist."
    5551    }
     52
    5653    if {[file isdirectory $testdir]} {
    5754        set _testdir $testdir
    5855    } else {
    59         error "Given testdir is not a directory"
     56        error "Directory \"$testdir\" does not exist."
    6057    }
    6158
    62     # TODO: Check other locations for tool.xml and throw error if not found
    63     set _toolxml [file join $tooldir tool.xml]
     59    itk_component add pw {
     60        panedwindow $itk_interior.pw
     61    }
     62    pack $itk_component(pw) -expand yes -fill both
    6463
    65     itk_component add topBar {
    66         frame $itk_interior.topBar
     64    itk_component add tree {
     65        Rappture::Regression::TestTree $itk_component(pw).tree \
     66            -command "$this runSelected" -testdir $_testdir
    6767    }
    68     itk_component add cmdLabel {
    69         label $itk_component(topBar).cmdLabel -text "Tool command:"
     68    $itk_component(pw) add $itk_component(tree) -sticky nsew
     69
     70    itk_component add view {
     71        Rappture::Regression::TestView $itk_component(pw).view
    7072    }
    71     itk_component add cmdEntry {
    72         entry $itk_component(topBar).cmdEntry
    73     }
    74     itk_component add bRunAll {
    75         button $itk_component(topBar).bRunAll -text "Run all" \
    76             -command [itcl::code $itk_interior runAll]
    77     }
    78     itk_component add bRunSelected {
    79         button $itk_component(topBar).bRunSelected -text "Run selected" \
    80             -command [itcl::code $itk_interior runSelected]
    81     }
    82     pack $itk_component(cmdLabel) -side left
    83     pack $itk_component(cmdEntry) -side left -expand yes -fill x
    84     pack $itk_component(bRunAll) -side right
    85     pack $itk_component(bRunSelected) -side right
    86     pack $itk_component(topBar) -side top -fill x
     73    $itk_component(pw) add $itk_component(view) -sticky nsew
    8774
    88     itk_component add pane {
    89         panedwindow $itk_interior.pane
    90     }
    91     itk_component add tree {
    92         Rappture::Regression::TestTree $itk_component(pane).tree $testdir
    93     }
    94     itk_component add view {
    95         Rappture::Regression::TestView $itk_component(pane).view
    96     }
    97     $itk_component(pane) add  $itk_component(pane).tree -sticky nesw
    98     $itk_component(pane) add  $itk_component(pane).view -sticky nesw
    9975    # TODO: make panes scale proportionally when window grows
    100     pack $itk_component(pane) -side left -expand yes -fill both
     76
     77    eval itk_initialize $args
    10178}
    10279
     
    151128    set driver [makeDriver $testxml]
    152129
    153     set tool [Rappture::Tool ::#auto $driver $_tooldir]
     130    set tool [Rappture::Tool ::#auto $driver [file dirname $_toolxml]]
    154131    set result ""
    155132    foreach {status result} [eval $tool run] break
  • trunk/tester/tester.tcl

    r1963 r1964  
    1010# hierarchically by using dots to separate components of the test label
    1111# (example: roomtemp.1eV).  A description may optionally be located at
    12 # the path test.description.
     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?
    1318# ======================================================================
    1419#  AUTHOR:  Ben Rafferty, Purdue University
     
    2328# wish executes everything from here on...
    2429
    25 # TODO: Use tclIndex to manage classes correctly
    26 source mainwin.tcl
    27 source testtree.tcl
    28 source testview.tcl
    29 source compare.tcl
     30# TODO: Won't need this once tied in with the rest of the package
     31lappend auto_path [file dirname $argv0]
     32
     33package require Tk
     34package require Rappture
     35package require RapptureGUI
    3036
    3137wm withdraw .
    3238
    33 set testdir "example/tests"
    34 set tooldir "example"
     39Rappture::getopts argv params {
     40    value -tool ""
     41    value -testdir ""
     42}
    3543
    36 ::Rappture::Regression::MainWin .main $tooldir $testdir
     44# If tool.xml and test directory locations are not given, try to find them.
     45if {$params(-tool) == ""} {
     46    if {[file exists tool.xml]} {
     47        set params(-tool) tool.xml
     48    } elseif {[file exists [file join rappture tool.xml]]} {
     49        set params(-tool) [file join rappture tool.xml]
     50    } else {
     51        error "Cannot find tool.xml"
     52    }
     53}
     54
     55if {$params(-testdir) == ""} {
     56    set tooldir [file dirname $params(-tool)]
     57    if {[file isdirectory [file join $tooldir tests]]} {
     58        set params(-testdir) [file join $tooldir tests]
     59    } elseif {[file isdirectory [file join [file dirname $tooldir] tests]]} {
     60        set params(-testdir) [file join [file dirname $tooldir] tests]
     61    } else {
     62        error "Cannot find test directory."
     63    }
     64}
     65
     66::Rappture::Regression::MainWin .main $params(-tool) $params(-testdir)
    3767bind .main <Destroy> {exit}
    3868
  • trunk/tester/testtree.tcl

    r1963 r1964  
    33#
    44#  Used to display a collapsible view of all tests found in the test
    5 #  directory.  Essentially an Itk Widget wrapper for blt::treeview.
    6 Provides methods to get all tests or all currently selected tests.
    7 Also helps handle data stored in treeview columns.  In each test xml,
    8 a label must be located at the path test.label.  Test labels may be
    9 be organized hierarchically by using dots to separate components of
    10 the test label.  (example: roomtemp.1eV)
     5#  directory.  The -command configuration option will be called when
     6the run button is clicked. Provides methods to get all tests or all
     7currently selected tests. Also helps handle data stored in treeview
     8columns.  In each test xml, a label must be located at the path
     9test.label.  Test labels may be organized hierarchically by using
     10dots to separate components of the test label.
    1111# ======================================================================
    1212#  AUTHOR:  Ben Rafferty, Purdue University
     
    2323
    2424itcl::class Rappture::Regression::TestTree {
    25     inherit itk::Widget
    26 
    27     constructor {testdir} { #defined later }
    28     public method populate {testdir}
     25    inherit itk::Widget
     26
     27    public variable command
     28    public variable testdir
     29
     30    constructor {testdir args} { #defined later }
    2931    public method getTests {{id 0}}
    3032    public method getSelected {}
    3133    public method getData {id}
    3234    public method setData {id data}
     35    public method updateLabel {}
     36
     37    private method populate {}
    3338}
    3439
     
    4146}
    4247
    43 itcl::body Rappture::Regression::TestTree::constructor {testdir} {
     48itcl::body Rappture::Regression::TestTree::constructor {args} {
    4449    # TODO: Use separate tree data structure and insert into treeview
    45     puts "Constructing TestTree."
     50    puts "Constructinig TestTree."
     51
    4652    itk_component add treeview {
    4753        blt::treeview $itk_interior.treeview -separator . -autocreate true \
    48             -selectmode multiple
    49     }
    50     $itk_component(treeview) column insert end xmlfile ran result diffs
     54            -selectmode multiple
     55    }
     56    $itk_component(treeview) column insert 0 result
     57    $itk_component(treeview) column insert end xmlfile ran diffs
    5158    $itk_component(treeview) column configure xmlfile ran diffs -hide yes
    5259    pack $itk_component(treeview) -expand yes -fill both
    53     populate $testdir
    54     # TODO: Fix default column spacing. Column name for the main/first column?
     60
     61    itk_component add bottomBar {
     62        frame $itk_interior.bottomBar
     63    }
     64    pack $itk_component(bottomBar) -fill x
     65
     66    itk_component add bSelectAll {
     67        button $itk_component(bottomBar).bSelectAll -text "Select all" \
     68            -command "$itk_component(treeview) selection set 0 end"
     69    }
     70    pack $itk_component(bSelectAll) -side left
     71
     72    itk_component add bSelectNone {
     73        button $itk_component(bottomBar).bSelectNone -text "Select none" \
     74            -command "$itk_component(treeview) selection clearall"
     75    }
     76    pack $itk_component(bSelectNone) -side left
     77
     78    itk_component add lSelected {
     79        label $itk_component(bottomBar).lSelected -text "0 tests selected"
     80    }
     81    pack $itk_component(lSelected) -side left -expand yes -fill x
     82    $itk_component(treeview) configure -selectcommand "$this updateLabel"
     83
     84    itk_component add bRun {
     85        button $itk_component(bottomBar).bRun -text "Run" -command runHandler \
     86            -state disabled
     87    }
     88    pack $itk_component(bRun) -side left
     89
    5590    # TODO: Fix black empty space when columns are shrunk
    56 }
    57 
     91    # TODO: Scrollbar(s)
     92
     93    eval itk_initialize $args
     94}
     95
     96# Repopulate tree if test directory changed
     97itcl::configbody Rappture::Regression::TestTree::testdir {
     98    populate
     99}
     100
     101itcl::configbody Rappture::Regression::TestTree::command {
     102    $itk_component(bRun) configure -command $command
     103}
    58104
    59105# ----------------------------------------------------------------------
     
    66112# any nodes previously contained by the treeview.
    67113# ----------------------------------------------------------------------
    68 itcl::body Rappture::Regression::TestTree::populate {testdir} {
     114itcl::body Rappture::Regression::TestTree::populate {} {
    69115    puts "Populating TestTree."
    70116    $itk_component(treeview) delete 0
    71     # TODO: Make file icon background transparent.
    72     set icon [image create photo -file images/file.gif]
     117    # TODO: add an appropriate icon
     118    set icon [Rappture::icon download]
    73119    # TODO: Descend through subdirectories inside testdir?
    74120    foreach testxml [glob -nocomplain -directory $testdir *.xml] {
     
    150196}
    151197
    152 
     198# ----------------------------------------------------------------------
     199# USAGE: updateLabel
     200#
     201# Used internally to update the label which indicates how many tests
     202# are currently selected.  Also disables the run button if no tests are
     203# selected.
     204# ----------------------------------------------------------------------
     205itcl::body Rappture::Regression::TestTree::updateLabel {} {
     206    set n [llength [getSelected]]
     207    $itk_component(lSelected) configure -text "$n tests selcted"
     208    if {$n > 0} {
     209        $itk_component(bRun) configure -state normal
     210    } else {
     211        $itk_component(bRun) configure -state disabled
     212    }
     213}
     214
  • trunk/tester/testview.tcl

    r1963 r1964  
    1717    inherit itk::Widget
    1818
    19     constructor {} { #defined later }
     19    constructor {args} { #defined later }
    2020}
    2121
    22 itcl::body Rappture::Regression::TestView::constructor {} {
     22itcl::body Rappture::Regression::TestView::constructor {args} {
    2323    puts "Constructing TestView."
    2424    itk_component add txt {
     
    2828    $itk_component(txt) insert end "TestView text area..."
    2929    $itk_component(txt) configure -state disabled
     30
     31    eval itk_initialize $args
    3032}
    3133
Note: See TracChangeset for help on using the changeset viewer.