Changeset 1966 for trunk/tester


Ignore:
Timestamp:
Nov 25, 2010 11:32:59 PM (9 years ago)
Author:
braffert
Message:

Developing regression tester

Location:
trunk/tester
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/tester/mainwin.tcl

    r1965 r1966  
    1919namespace eval Rappture::Regression::MainWin { #forward declaration }
    2020
    21 # ----------------------------------------------------------------------
    22 # CONSTRUCTOR
    23 # ----------------------------------------------------------------------
    2421itcl::class Rappture::Regression::MainWin {
    2522    inherit itk::Toplevel
     
    2825    public method runAll {args}
    2926    public method runSelected {args}
     27    public method selectionHandler {}
    3028    private method runTest {id args}
    31     private method makeDriver {testxml {path input}}
    3229
    3330    private variable _testdir
     
    3633}
    3734
    38 # TODO: figure out exactly what should go in here.
    39 itk::usual TestView {
    40     keep -background -foreground -font
    41 }
    42 
    43 itk::usual Panedwindow {
    44     keep -background
    45 }
    46 
     35# ----------------------------------------------------------------------
     36# CONSTRUCTOR
     37# ----------------------------------------------------------------------
    4738itcl::body Rappture::Regression::MainWin::constructor {toolxml testdir args} {
    48     puts "Constructing MainWin."
    49 
    5039    if {[file exists $toolxml]} {
    5140        set _toolxml $toolxml
     
    6251    itk_component add pw {
    6352        panedwindow $itk_interior.pw
     53    } {
    6454    }
    6555    pack $itk_component(pw) -expand yes -fill both
     
    6757    itk_component add tree {
    6858        Rappture::Regression::TestTree $itk_component(pw).tree \
    69             -command "$this runSelected" -testdir $_testdir
     59            -command "$this runSelected" -testdir $_testdir \
     60            -selectcommand "$this selectionHandler"
    7061    }
    7162    $itk_component(pw) add $itk_component(tree) -sticky nsew
     
    8879# ----------------------------------------------------------------------
    8980itcl::body Rappture::Regression::MainWin::runAll {args} {
    90     puts "Running all tests."
    9181    set tests [$itk_component(tree) getTests]
    9282    foreach id $tests {
     
    10393# ----------------------------------------------------------------------
    10494itcl::body Rappture::Regression::MainWin::runSelected {args} {
    105     puts "Running selected tests."
    10695    set selected [$itk_component(tree) getSelected]
    10796    foreach id $selected {
     
    122111    array set data [$itk_component(tree) getData $id]
    123112    if {$data(ran) && [lsearch -exact $args "-force"]==-1} {
    124         puts "Skipping test at node $id."
     113        # Already ran.  Skip.
    125114        return
    126115    }
    127     puts "Running test at node $id."
    128116    set data(result) "Running"
    129117    $itk_component(tree) setData $id [array get data]
     
    147135    }
    148136    $itk_component(tree) setData $id [array get data]
     137
     138    # Call selectionHandler to refresh right hand side view
     139    selectionHandler
     140
    149141    # TODO: Remove runfile
    150142}
    151143
     144# ----------------------------------------------------------------------
     145# USAGE: selectionHandler
     146#
     147# Used internally to communicate between the test tree and the right
     148# hand side whenever the tree's selection has changed.
     149# ----------------------------------------------------------------------
     150itcl::body Rappture::Regression::MainWin::selectionHandler {} {
     151    array set data [$itk_component(tree) getData focus]
     152    # Data array is empty for branch nodes
     153    if {[array names data] != ""} {
     154        if {$data(ran)} {
     155            switch $data(result) {
     156                Pass {$itk_component(view) showText "Test passed."}
     157                Fail {$itk_component(view) showText "Diffs: $data(diffs)"}
     158                Error {$itk_component(view) showText "Error while running test"}
     159            }
     160        } else {
     161            $itk_component(view) showText "Test has not ben ran."
     162        }
     163    } else {
     164        $itk_component(view) showDefault
     165    }
     166}
     167
  • trunk/tester/testtree.tcl

    r1965 r1966  
    2222namespace eval Rappture::Regression::TestTree { #forward declaration }
    2323
    24 # ----------------------------------------------------------------------
    25 # CONSTRUCTOR
    26 # ----------------------------------------------------------------------
    2724itcl::class Rappture::Regression::TestTree {
    2825    inherit itk::Widget
    2926
    3027    public variable command
     28    public variable selectcommand
    3129    public variable testdir
    3230
     
    4139}
    4240
    43 # TODO: figure out exactly what should go in here.
    4441itk::usual TestTree {
    4542    keep -background -foreground -font
    4643}
    47 itk::usual TreeView {
    48     keep -background -foreground -font
    49 }
    50 
     44
     45# ----------------------------------------------------------------------
     46# CONSTRUCTOR
     47# ----------------------------------------------------------------------
    5148itcl::body Rappture::Regression::TestTree::constructor {args} {
    52     # TODO: Use separate tree data structure and insert into treeview
    53     puts "Constructing TestTree."
    54 
    5549    itk_component add treeview {
    5650        blt::treeview $itk_interior.treeview -separator . -autocreate true \
    5751            -selectmode multiple
     52    } {
    5853    }
    5954    $itk_component(treeview) column insert 0 result
     
    6661    }
    6762    pack $itk_component(bottomBar) -fill x
     63    # TODO: Adjust spacing in bottom bar
    6864
    6965    itk_component add bSelectAll {
     
    8379    }
    8480    pack $itk_component(lSelected) -side left -expand yes -fill x
    85     $itk_component(treeview) configure -selectcommand "$this updateLabel"
    8681
    8782    itk_component add bRun {
     
    10196itcl::configbody Rappture::Regression::TestTree::testdir {
    10297    populate
     98}
     99
     100# Forward the TestTree's selectcommand to the treeview, and update the label
     101# as well.
     102itcl::configbody Rappture::Regression::TestTree::selectcommand {
     103    $itk_component(treeview) configure -selectcommand \
     104        "$this updateLabel; $selectcommand"
    103105}
    104106
     
    113115# ----------------------------------------------------------------------
    114116itcl::body Rappture::Regression::TestTree::populate {} {
    115     puts "Populating TestTree."
    116117    $itk_component(treeview) delete 0
    117118    # TODO: add an appropriate icon
     
    205206itcl::body Rappture::Regression::TestTree::updateLabel {} {
    206207    set n [llength [getSelected]]
    207     $itk_component(lSelected) configure -text "$n tests selcted"
     208    if {$n == 1} {
     209        $itk_component(lSelected) configure -text "1 test selcted"
     210    } else {
     211        $itk_component(lSelected) configure -text "$n tests selected"
     212    }
     213
    208214    if {$n > 0} {
    209215        $itk_component(bRun) configure -state normal
  • trunk/tester/testview.tcl

    r1965 r1966  
    1717    inherit itk::Widget
    1818
     19    public method showDefault {}
     20    public method showText {text}
     21
    1922    constructor {args} { #defined later }
    2023}
     
    2427# ----------------------------------------------------------------------
    2528itcl::body Rappture::Regression::TestView::constructor {args} {
    26     puts "Constructing TestView."
    2729    itk_component add txt {
    2830        text $itk_interior.txt
    2931    }
    3032    pack $itk_component(txt) -expand yes -fill both
    31     $itk_component(txt) insert end "TestView text area..."
    32     $itk_component(txt) configure -state disabled
     33    showDefault
    3334
    3435    eval itk_initialize $args
    3536}
    3637
     38itk::usual TestView {
     39    keep -background -foreground -font
     40}
     41
     42itcl::body Rappture::Regression::TestView::showDefault {} {
     43    $itk_component(txt) configure -state normal
     44    $itk_component(txt) delete 0.0 end
     45    $itk_component(txt) insert end "Default"
     46    $itk_component(txt) configure -state disabled
     47}
     48
     49itcl::body Rappture::Regression::TestView::showText {text} {
     50    $itk_component(txt) configure -state normal
     51    $itk_component(txt) delete 0.0 end
     52    $itk_component(txt) insert end "$text"
     53    $itk_component(txt) configure -state disabled
     54}
Note: See TracChangeset for help on using the changeset viewer.