Changeset 2008 for trunk/tester


Ignore:
Timestamp:
Dec 15, 2010 9:06:51 PM (9 years ago)
Author:
braffert
Message:

Developing regression tester.

Location:
trunk/tester
Files:
1 deleted
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/tester/tclIndex

    r1977 r2008  
    77# a script that loads the command.
    88
    9 set auto_index(::Rappture::Tester::MainWin) [list source [file join $dir mainwin.tcl]]
    10 set auto_index(::Rappture::Tester::MainWin::constructor) [list source [file join $dir mainwin.tcl]]
    11 set auto_index(::Rappture::Tester::MainWin::runAll) [list source [file join $dir mainwin.tcl]]
    12 set auto_index(::Rappture::Tester::MainWin::runSelected) [list source [file join $dir mainwin.tcl]]
    13 set auto_index(::Rappture::Tester::MainWin::runTest) [list source [file join $dir mainwin.tcl]]
    14 set auto_index(::Rappture::Tester::MainWin::selectionHandler) [list source [file join $dir mainwin.tcl]]
    159set auto_index(::Rappture::Tester::compare_elements) [list source [file join $dir compare.tcl]]
    1610set auto_index(::Rappture::Tester::compare) [list source [file join $dir compare.tcl]]
    1711set auto_index(::Rappture::Tester::makeDriver) [list source [file join $dir compare.tcl]]
    1812set auto_index(::Rappture::Tester::merge) [list source [file join $dir compare.tcl]]
     13set auto_index(::Rappture::Tester::runAll) [list source [file join $dir tester.tcl]]
     14set auto_index(::Rappture::Tester::runSelected) [list source [file join $dir tester.tcl]]
     15set auto_index(::Rappture::Tester::runTest) [list source [file join $dir tester.tcl]]
     16set auto_index(::Rappture::Tester::selectionHandler) [list source [file join $dir tester.tcl]]
    1917set auto_index(::Rappture::Tester::TestAnalyzer) [list source [file join $dir testanalyzer.tcl]]
    2018set auto_index(::Rappture::Tester::TestAnalyzer::constructor) [list source [file join $dir testanalyzer.tcl]]
     
    3331set auto_index(::Rappture::Tester::TestView::constructor) [list source [file join $dir testview.tcl]]
    3432set auto_index(::Rappture::Tester::TestView::clear) [list source [file join $dir testview.tcl]]
    35 set auto_index(::Rappture::Tester::TestView::display) [list source [file join $dir testview.tcl]]
     33set auto_index(::Rappture::Tester::TestView::showTest) [list source [file join $dir testview.tcl]]
    3634set auto_index(::Rappture::Tester::TestView::showResult) [list source [file join $dir testview.tcl]]
    37 set auto_index(::Rappture::Tester::TestView::showDefault) [list source [file join $dir testview.tcl]]
    3835set auto_index(::Rappture::Tester::TestView::showText) [list source [file join $dir testview.tcl]]
     36set auto_index(::Rappture::Tester::TestView::update) [list source [file join $dir testview.tcl]]
  • trunk/tester/testanalyzer.tcl

    r1968 r2008  
    44# notebook as a separate widget.
    55
     6# Strange errors are thrown when I try to swap in and out different result
     7# sets with the same analyzer widget.  For now, I get around this by destroying
     8# the analyzer and creating a new one every time a new result should be
     9# displayed.
     10
     11# TODO: Make a new widget with (only) the result viewing capabilites of the
     12# Rappture analyzer.  Also, should be able to keep a single widget and swap
     13# in and out new result sets.
     14
    615package require Itk
     16package require RapptureGUI
    717
    818namespace eval Rappture::Tester::TestAnalyzer { # forward declaration}
  • trunk/tester/tester.tcl

    r1968 r2008  
    3131lappend auto_path [file dirname $argv0]
    3232
    33 package require Tk
     33package require Itk
    3434package require Rappture
    3535package require RapptureGUI
    36 
    37 wm withdraw .
    3836
    3937Rappture::getopts argv params {
     
    6462}
    6563
    66 Rappture::Tester::MainWin .main $params(-tool) $params(-testdir)
    67 wm protocol .main WM_DELETE_WINDOW exit
    68 wm title .main "Rappture Regression Tester"
     64# ----------------------------------------------------------------------
     65# INITIALIZE WINDOW
     66# ----------------------------------------------------------------------
     67wm title . "Rappture Regression Tester"
     68panedwindow .pw
     69.pw add [Rappture::Tester::TestTree .tree \
     70    -testdir $params(-testdir) \
     71    -command Rappture::Tester::runSelected \
     72    -selectcommand Rappture::Tester::selectionHandler]
     73.pw add [Rappture::Tester::TestView .view $params(-tool)]
     74pack .pw -expand yes -fill both
    6975
     76# ----------------------------------------------------------------------
     77# USAGE: runAll ?-force?
     78#
     79# When this method is invoked, all tests contained in the TestTree will
     80# be ran sequentially.
     81# ----------------------------------------------------------------------
     82proc Rappture::Tester::runAll {args} {
     83    foreach id [.tree getTests] {
     84        runTest $id $args
     85    }
     86    .view update [.tree getData focus]
     87}
     88
     89# ----------------------------------------------------------------------
     90# USAGE: runSelected ?-force?
     91#
     92# When this method is invoked, all tests that are currently selected
     93# will be ran.  If a branch node (folder) is selected, all of its
     94# descendant tests will be ran as well.
     95# TODO: Parallel exection
     96# ----------------------------------------------------------------------
     97proc Rappture::Tester::runSelected {args} {
     98    foreach id [.tree getSelected] {
     99        runTest $id $args
     100    }
     101    .view update [.tree getData focus]
     102}
     103
     104# ----------------------------------------------------------------------
     105# USAGE: runTest id ?-force?
     106#
     107# Called by runAll and runSelected to run a single test at the tree node
     108# specified by the given ide.  In most cases, this method should not be
     109# called directly.  A driver object is generated by the makeDriver
     110# procedure in compare.tcl, and the results given by the new version are
     111# compared to the golden result by the compare procedure in compare.tcl
     112# ----------------------------------------------------------------------
     113proc Rappture::Tester::runTest {id args} {
     114    array set data [.tree getData $id]
     115    global params
     116    if {$data(ran) && [lsearch -exact $args "-force"] == -1} {
     117        # Already ran. Skip.
     118        return
     119    }
     120    set data(result) "Running"
     121    .tree setData $id [array get data]
     122
     123    set driver [Rappture::Tester::makeDriver $params(-tool) $data(testxml)]
     124    set tool [Rappture::Tool ::#auto $driver [file dirname $params(-tool)]]
     125    foreach {status result} [eval $tool run] break
     126    set data(ran) yes
     127    if {$status == 0 && [Rappture::library isvalid $result]} {
     128        set golden [Rappture::library $data(testxml)]
     129        set diffs [Rappture::Tester::compare $golden $result output]
     130        if {$diffs == ""} {
     131            set data(result) Pass
     132        } else {
     133            set data(result) Fail
     134        }
     135        set data(diffs) $diffs
     136        set data(runfile) [$tool getRunFile]
     137    } else {
     138        set data(result) Error
     139        set data(runfile) ""
     140    }
     141    .tree setData $id [array get data]
     142}
     143
     144# ----------------------------------------------------------------------
     145# USAGE: selectionHandler
     146#
     147# Used internally to communicate between the test tree and the right
     148# hand side viewer.  Upon selecting a new tree node, pass the focused
     149# node's data to the right hand side.
     150# ----------------------------------------------------------------------
     151proc Rappture::Tester::selectionHandler {} {
     152    .view update [.tree getData focus]
     153}
     154
  • trunk/tester/testtree.tcl

    r1977 r2008  
    134134    $itk_component(treeview) delete 0
    135135    # TODO: add an appropriate icon
    136     set icon [Rappture::icon download]
     136    set icon [Rappture::icon molvis-3dorth]
    137137    # TODO: Descend through subdirectories inside testdir?
    138138    foreach testxml [glob -nocomplain -directory $testdir *.xml] {
  • trunk/tester/testview.tcl

    r1977 r2008  
    22# COMPONENT: testview - display the results of a test
    33#
    4 # Doesn't do anything yet.  TODO: Fill this in later.
     4# Entire right hand side of the regression tester.  Contains a small
     5# text widget, plus two TestAnalyzer widgets.  The analyzers are used to
     6# show the golden set of results, and the new results if the test has
     7# been ran.  Constructor requires a tool.xml for the tool being tested.
    58# ======================================================================
    69#  AUTHOR:  Ben Rafferty, Purdue University
     
    2629    inherit itk::Widget
    2730
    28     public method clearTest {}
    29     public method clearResult {}
     31    public method clear {}
    3032    public method showTest {testxml}
    3133    public method showResult {runfile}
    32     public method showDefault {}
    3334    public method showText {text}
     35    public method update {datapairs}
    3436
    35     constructor {tool args} { #defined later }
     37    private variable _toolobj
     38
     39    constructor {toolxml args} { #defined later }
    3640}
    3741
     
    3943# CONSTRUCTOR
    4044# ----------------------------------------------------------------------
    41 itcl::body Rappture::Tester::TestView::constructor {tool args} {
    42    
     45itcl::body Rappture::Tester::TestView::constructor {toolxml args} {
     46   
     47    set _toolobj [Rappture::Tool ::#auto [Rappture::library $toolxml] \
     48         [file dirname $toolxml]]
     49 
    4350    itk_component add txt {
    4451        text $itk_interior.txt -height 1
    4552    }
    46     pack $itk_component(txt) -expand yes -fill x
     53    pack $itk_component(txt) -expand no -fill x -side top
    4754
    4855    itk_component add analyzer1 {
    49         Rappture::Tester::TestAnalyzer $itk_interior.analyzer1 $tool
     56        Rappture::Tester::TestAnalyzer $itk_interior.analyzer1 $_toolobj
    5057    }
    51     pack $itk_component(analyzer1) -expand yes -fill both
     58    pack $itk_component(analyzer1) -expand no -fill both -side top
    5259
    5360    itk_component add analyzer2 {
    54         Rappture::Tester::TestAnalyzer $itk_interior.analyzer2 $tool
     61        Rappture::Tester::TestAnalyzer $itk_interior.analyzer2 $_toolobj
    5562    }
    56     pack $itk_component(analyzer2) -expand yes -fill both
     63    pack $itk_component(analyzer2) -expand no -fill both -side top
    5764
    5865    eval itk_initialize $args
    59 
    60     showDefault
    6166}
    6267
     
    6570}
    6671
    67 itcl::body Rappture::Tester::TestView::clearTest {} {
    68     $itk_component(analyzer1) clear
     72# ----------------------------------------------------------------------
     73# USAGE: clear
     74#
     75# Clears both result viewers by deleting the testanalyzer widgets.
     76# Eventually, this should clear the results from the analyzer without
     77# needing to destroy it.
     78# ----------------------------------------------------------------------
     79itcl::body Rappture::Tester::TestView::clear {} {
     80    #$itk_component(analyzer1) clear
     81    catch {destroy $itk_component(analyzer1)}
     82    catch {destroy $itk_component(analyzer2)}
     83    $itk_component(txt) delete 0.0 end
    6984}
    7085
    71 itcl::body Rappture::Tester::TestView::clearResult {} {
    72     $itk_component(analyzer2) clear
    73 }
    74 
     86# ----------------------------------------------------------------------
     87# USAGE: showTest <testxml>
     88#
     89# Displays a new set of golden results by deleting the existing
     90# analyzer and creating a new one.  Eventually, this should be able to
     91# swap the currently visible set of resuls without needing to destroy
     92# the widget.
     93# ----------------------------------------------------------------------
    7594itcl::body Rappture::Tester::TestView::showTest {testxml} {
     95    itk_component add analyzer1 {
     96        Rappture::Tester::TestAnalyzer $itk_interior.analyzer1 $_toolobj
     97    }
     98    pack $itk_component(analyzer1) -expand no -fill both -side top
    7699    $itk_component(analyzer1) display $testxml
    77100}
    78101
     102# ----------------------------------------------------------------------
     103# USAGE: showResult <runfile>
     104#
     105# Displays a new test result by deleting the existing analyzer and
     106# creating a new one.  Eventually, this should be able to swap the
     107# currently visible set of results without needing to destroy the
     108# widget.
     109# ----------------------------------------------------------------------
    79110itcl::body Rappture::Tester::TestView::showResult {runfile} {
     111    itk_component add analyzer2 {
     112        Rappture::Tester::TestAnalyzer $itk_interior.analyzer2 $_toolobj
     113    }
     114    pack $itk_component(analyzer2) -expand no -fill both -side top
    80115    $itk_component(analyzer2) display $runfile
    81116}
    82117
    83 itcl::body Rappture::Tester::TestView::showDefault {} {
    84     $itk_component(txt) configure -state normal
    85     $itk_component(txt) delete 0.0 end
    86     $itk_component(txt) insert end "Default"
    87     $itk_component(txt) configure -state disabled
    88     clearTest
    89     clearResult
    90 }
    91 
     118# ----------------------------------------------------------------------
     119# USAGE: showText <text>
     120#
     121# Displays a string in the text space at the top of the widget.
     122# ----------------------------------------------------------------------
    92123itcl::body Rappture::Tester::TestView::showText {text} {
    93124    $itk_component(txt) configure -state normal
     
    96127    $itk_component(txt) configure -state disabled
    97128}
     129
     130# ----------------------------------------------------------------------
     131# USAGE: update <datapairs>
     132#
     133# Given a list of key value pairs from the test tree, shows the
     134# golden result, plus the new result if the test has been ran.
     135# ----------------------------------------------------------------------
     136itcl::body Rappture::Tester::TestView::update {datapairs} {
     137    clear
     138    array set data $datapairs
     139    # Data array is empty for branch nodes.
     140    if {[array names data] != ""} {
     141        if {$data(testxml) != ""} {
     142            # Display golden results.
     143            showTest $data(testxml)
     144        }
     145        if {$data(ran)} {
     146            switch $data(result) {
     147                Pass {showText "Test passed."}
     148                Fail {showText "Diffs: $data(diffs)"}
     149                Error {showText "Error while running test."}
     150            }
     151            if {$data(runfile) != ""} {
     152                # Display new results.
     153                showResult $data(runfile)
     154            }
     155        } else {
     156            showText "Test has not yet ran."
     157        }
     158    }
     159}
     160
Note: See TracChangeset for help on using the changeset viewer.