Changeset 1965 for trunk/tester


Ignore:
Timestamp:
Nov 25, 2010, 10:15:45 PM (14 years ago)
Author:
braffert
Message:

Developing regression tester

Location:
trunk/tester
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/tester/compare.tcl

    r1963 r1965  
     1# ----------------------------------------------------------------------
     2#  COMPONENT: compare - comparison procedures for regression testing
     3# ======================================================================
     4#  AUTHOR:  Ben Rafferty, Purdue University
     5#  Copyright (c) 2010  Purdue Research Foundation
     6#
     7#  See the file "license.terms" for information on usage and
     8#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
     9# ======================================================================
    110package require Rappture
    211
    312namespace eval Rappture::Regression { #forward declaration }
    413
    5 # For now, just check if equal
     14# ----------------------------------------------------------------------
     15# USAGE: compare_elements lib1 lib2 path
     16#
     17# Compare data found in two library objects at the given path.  Returns
     18# 1 if match, 0 if no match.  For now, just check if ascii identical.
     19# Later, we can do something more sophisticated for different types of
     20# elements.
     21# ----------------------------------------------------------------------
    622proc Rappture::Regression::compare_elements {lib1 lib2 path} {
    723    set val1 [$lib1 get $path]
     
    1026}
    1127
    12 # return a list of paths that differ
     28# ----------------------------------------------------------------------
     29# USAGE: compare lib1 lib2 ?path?
     30#
     31# Compares two library objects and returns a list of paths that do not
     32# match.  Paths are relative to lib1 (i.e. if a path exists in lib2 but
     33# not lib1, it will not be included in the result.  Result will contain
     34# all differences that occur as descendants of an optional starting
     35# path.  If the path argument is not given, then only the output
     36# sections will be compared.
     37# ----------------------------------------------------------------------
    1338proc Rappture::Regression::compare {lib1 lib2 {path output}} {
    1439    set diffs [list]
     
    2752}
    2853
     54# ----------------------------------------------------------------------
     55# USAGE: makeDriver tool.xml test.xml
     56#
     57# Builds and returns a driver library object to be used for running the
     58# test specified by testxml.  Copy current values from test xml into the
     59# newly created driver.  If any inputs are present in the new tool.xml
     60# which do not exist in the test xml, use the default value.
     61# ----------------------------------------------------------------------
     62proc Rappture::Regression::makeDriver {toolxml testxml} {
     63    # TODO: Test with various cases, especially with missing input elements
     64    set toolobj [Rappture::library $toolxml]
     65    set golden [Rappture::library $testxml]
     66    set driver [Rappture::library $toolxml]
     67    return [Rappture::Regression::merge $toolobj $golden $driver]
     68}
     69
     70# ----------------------------------------------------------------------
     71# USAGE: merge toolobj golden driver ?path?
     72#
     73# Used to recursively build up a driver library object for running a
     74# test.  Should not be called directly - see makeDriver.
     75# ----------------------------------------------------------------------
     76proc Rappture::Regression::merge {toolobj golden driver {path input}} {
     77    set clist [$toolobj children $path]
     78    foreach child $clist {
     79        set val [$golden get $path.$child.current]
     80        if {$val != ""} {
     81            $driver put $path.$child.current $val
     82        } else {
     83            set def [$toolobj get $path.$child.default]
     84            if {$def != ""} {
     85                $driver put $path.$child.current $def
     86            }
     87        }
     88        Rappture::Regression::merge $toolobj $golden $driver $path.$child
     89    }
     90    return $driver
     91}
     92
     93
  • trunk/tester/mainwin.tcl

    r1964 r1965  
    1919namespace eval Rappture::Regression::MainWin { #forward declaration }
    2020
     21# ----------------------------------------------------------------------
     22# CONSTRUCTOR
     23# ----------------------------------------------------------------------
    2124itcl::class Rappture::Regression::MainWin {
    2225    inherit itk::Toplevel
    2326
    2427    constructor {toolxml testdir args} { #defined later }
    25     public method runAll {}
    26     public method runSelected {}
    27     private method runTest {id}
    28     private method makeDriver {testxml}
     28    public method runAll {args}
     29    public method runSelected {args}
     30    private method runTest {id args}
     31    private method makeDriver {testxml {path input}}
    2932
    3033    private variable _testdir
     
    7982
    8083# ----------------------------------------------------------------------
    81 # USAGE: runAll
     84# USAGE: runAll ?-force?
    8285#
    8386# When this method is invoked, all tests contained in the TestTree will
    8487# be ran sequentially.
    8588# ----------------------------------------------------------------------
    86 itcl::body Rappture::Regression::MainWin::runAll {} {
    87     # TODO: Add force or ifneeded flag and propagate to runTest
     89itcl::body Rappture::Regression::MainWin::runAll {args} {
    8890    puts "Running all tests."
    8991    set tests [$itk_component(tree) getTests]
    9092    foreach id $tests {
    91         runTest $id
     93        runTest $id $args
    9294    }
    9395}
    9496
    9597# ----------------------------------------------------------------------
    96 # USAGE: runSelected
     98# USAGE: runSelected ?-force?
    9799#
    98100# When this method is invoked, all tests that are currently selected
     
    100102# descendant tests will be ran as well.
    101103# ----------------------------------------------------------------------
    102 itcl::body Rappture::Regression::MainWin::runSelected {} {
    103     # TODO: Add force or ifneeded flag and propagate to runTest
     104itcl::body Rappture::Regression::MainWin::runSelected {args} {
    104105    puts "Running selected tests."
    105106    set selected [$itk_component(tree) getSelected]
    106107    foreach id $selected {
    107         runTest $id
     108        runTest $id $args
    108109    }
    109110}
    110111
    111112# ----------------------------------------------------------------------
    112 # USAGE: runTest id
     113# USAGE: runTest id ?-force?
    113114#
    114115# Called by runAll and runSelected to run a single test at tree node
    115116# specified by the given id.  In most cases, this method should not be
    116 # called directly.  Results given by the new version are compared to
    117 # the test xml by the compare procedure in compare.tcl
     117# called directly.  A driver object is generated by the makeDriver
     118# procedure in compare.tcl, and the results given by the new version are
     119# compared to the test xml by the compare procedure in compare.tcl
    118120# ----------------------------------------------------------------------
    119 itcl::body Rappture::Regression::MainWin::runTest {id} {
    120     # TODO: Add force or ifneeded flag and check the "ran" element of the
    121     #       data array
     121itcl::body Rappture::Regression::MainWin::runTest {id args} {
     122    array set data [$itk_component(tree) getData $id]
     123    if {$data(ran) && [lsearch -exact $args "-force"]==-1} {
     124        puts "Skipping test at node $id."
     125        return
     126    }
    122127    puts "Running test at node $id."
    123     array set data [$itk_component(tree) getData $id]
    124     set data(result) "In progress"
     128    set data(result) "Running"
    125129    $itk_component(tree) setData $id [array get data]
    126130
    127     set testxml $data(xmlfile)
    128     set driver [makeDriver $testxml]
    129 
     131    set driver [Rappture::Regression::makeDriver $_toolxml $data(testxml)]
     132    #set driver [makeDriver $data(testxml)]
    130133    set tool [Rappture::Tool ::#auto $driver [file dirname $_toolxml]]
    131     set result ""
    132134    foreach {status result} [eval $tool run] break
    133135    set data(ran) yes
    134136    if {$status == 0 && [Rappture::library isvalid $result]} {
    135         set golden [Rappture::library $testxml]
    136         set diffs [Rappture::Regression::compare $golden $result output]
     137        set golden [Rappture::library $data(testxml)]
     138        set diffs [Rappture::Regression::compare $golden $result "output"]
    137139        if {$diffs != ""} {
    138             set data(result) fail
     140            set data(result) Fail
    139141            set data(diffs) $diffs
    140142        } else {
    141             set data(result) pass
     143            set data(result) Pass
    142144        }
    143145    } else {
    144         set data(result) error
     146        set data(result) Error
    145147    }
    146148    $itk_component(tree) setData $id [array get data]
     
    148150}
    149151
    150 # ----------------------------------------------------------------------
    151 # USAGE: makeDriver testxml
    152 #
    153 # Creates and returns a driver Rappture::library object to be used for
    154 # running the test specified by testxml.  If any input elements are
    155 # present in the new tool.xml which do not exist in the test xml, use
    156 # the default value specified in the new tool.xml.
    157 # ----------------------------------------------------------------------
    158 itcl::body Rappture::Regression::MainWin::makeDriver {testxml} {
    159     # Construct a driver file.
    160     # TODO: Pass through all inputs in the new tool.xml.  If present in the
    161     #       test xml, copy the value.  If not, use the default from the new
    162     #       tool.xml.
    163     # For now, just use test xml with the output deleted and command replaced
    164     set driver [Rappture::library $testxml]
    165     set cmd [[Rappture::library $_toolxml] get tool.command]
    166     $driver put tool.command $cmd
    167     $driver remove output
    168     return $driver
    169 }
  • trunk/tester/tclIndex

    r1963 r1965  
    1515set auto_index(::Rappture::Regression::compare_elements) [list source [file join $dir compare.tcl]]
    1616set auto_index(::Rappture::Regression::compare) [list source [file join $dir compare.tcl]]
     17set auto_index(::Rappture::Regression::makeDriver) [list source [file join $dir compare.tcl]]
     18set auto_index(::Rappture::Regression::merge) [list source [file join $dir compare.tcl]]
    1719set auto_index(::Rappture::Regression::TestTree) [list source [file join $dir testtree.tcl]]
    1820set auto_index(::Rappture::Regression::TestTree::constructor) [list source [file join $dir testtree.tcl]]
     21set auto_index(::Rappture::Regression::TestTree::testdir) [list source [file join $dir testtree.tcl]]
    1922set auto_index(::Rappture::Regression::TestTree::populate) [list source [file join $dir testtree.tcl]]
    2023set auto_index(::Rappture::Regression::TestTree::getTests) [list source [file join $dir testtree.tcl]]
     
    2225set auto_index(::Rappture::Regression::TestTree::getData) [list source [file join $dir testtree.tcl]]
    2326set auto_index(::Rappture::Regression::TestTree::setData) [list source [file join $dir testtree.tcl]]
     27set auto_index(::Rappture::Regression::TestTree::updateLabel) [list source [file join $dir testtree.tcl]]
    2428set auto_index(::Rappture::Regression::TestView) [list source [file join $dir testview.tcl]]
    2529set auto_index(::Rappture::Regression::TestView::constructor) [list source [file join $dir testview.tcl]]
  • trunk/tester/testtree.tcl

    r1964 r1965  
    2222namespace eval Rappture::Regression::TestTree { #forward declaration }
    2323
     24# ----------------------------------------------------------------------
     25# CONSTRUCTOR
     26# ----------------------------------------------------------------------
    2427itcl::class Rappture::Regression::TestTree {
    2528    inherit itk::Widget
     
    4851itcl::body Rappture::Regression::TestTree::constructor {args} {
    4952    # TODO: Use separate tree data structure and insert into treeview
    50     puts "Constructinig TestTree."
     53    puts "Constructing TestTree."
    5154
    5255    itk_component add treeview {
     
    5558    }
    5659    $itk_component(treeview) column insert 0 result
    57     $itk_component(treeview) column insert end xmlfile ran diffs
    58     $itk_component(treeview) column configure xmlfile ran diffs -hide yes
     60    $itk_component(treeview) column insert end testxml ran diffs
     61    $itk_component(treeview) column configure testxml ran diffs -hide yes
    5962    pack $itk_component(treeview) -expand yes -fill both
    6063
     
    8386
    8487    itk_component add bRun {
    85         button $itk_component(bottomBar).bRun -text "Run" -command runHandler \
    86             -state disabled
     88        button $itk_component(bottomBar).bRun -text "Run" -state disabled
     89    } {
     90        keep -command
    8791    }
    8892    pack $itk_component(bRun) -side left
     
    97101itcl::configbody Rappture::Regression::TestTree::testdir {
    98102    populate
    99 }
    100 
    101 itcl::configbody Rappture::Regression::TestTree::command {
    102     $itk_component(bRun) configure -command $command
    103103}
    104104
     
    123123        if {$testpath != ""} {
    124124            $itk_component(treeview) insert end $testpath -data \
    125                  [list xmlfile $testxml ran no result "" diffs ""] \
     125                 [list testxml $testxml ran no result "" diffs ""] \
    126126                 -icons "$icon $icon" -activeicons "$icon $icon"
    127127            }
  • trunk/tester/testview.tcl

    r1964 r1965  
    2020}
    2121
     22# ----------------------------------------------------------------------
     23# CONSTRUCTOR
     24# ----------------------------------------------------------------------
    2225itcl::body Rappture::Regression::TestView::constructor {args} {
    2326    puts "Constructing TestView."
Note: See TracChangeset for help on using the changeset viewer.