Changeset 1965 for trunk/tester
- Timestamp:
- Nov 25, 2010, 10:15:45 PM (14 years ago)
- 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 # ====================================================================== 1 10 package require Rappture 2 11 3 12 namespace eval Rappture::Regression { #forward declaration } 4 13 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 # ---------------------------------------------------------------------- 6 22 proc Rappture::Regression::compare_elements {lib1 lib2 path} { 7 23 set val1 [$lib1 get $path] … … 10 26 } 11 27 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 # ---------------------------------------------------------------------- 13 38 proc Rappture::Regression::compare {lib1 lib2 {path output}} { 14 39 set diffs [list] … … 27 52 } 28 53 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 # ---------------------------------------------------------------------- 62 proc 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 # ---------------------------------------------------------------------- 76 proc 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 19 19 namespace eval Rappture::Regression::MainWin { #forward declaration } 20 20 21 # ---------------------------------------------------------------------- 22 # CONSTRUCTOR 23 # ---------------------------------------------------------------------- 21 24 itcl::class Rappture::Regression::MainWin { 22 25 inherit itk::Toplevel 23 26 24 27 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}} 29 32 30 33 private variable _testdir … … 79 82 80 83 # ---------------------------------------------------------------------- 81 # USAGE: runAll 84 # USAGE: runAll ?-force? 82 85 # 83 86 # When this method is invoked, all tests contained in the TestTree will 84 87 # be ran sequentially. 85 88 # ---------------------------------------------------------------------- 86 itcl::body Rappture::Regression::MainWin::runAll {} { 87 # TODO: Add force or ifneeded flag and propagate to runTest 89 itcl::body Rappture::Regression::MainWin::runAll {args} { 88 90 puts "Running all tests." 89 91 set tests [$itk_component(tree) getTests] 90 92 foreach id $tests { 91 runTest $id 93 runTest $id $args 92 94 } 93 95 } 94 96 95 97 # ---------------------------------------------------------------------- 96 # USAGE: runSelected 98 # USAGE: runSelected ?-force? 97 99 # 98 100 # When this method is invoked, all tests that are currently selected … … 100 102 # descendant tests will be ran as well. 101 103 # ---------------------------------------------------------------------- 102 itcl::body Rappture::Regression::MainWin::runSelected {} { 103 # TODO: Add force or ifneeded flag and propagate to runTest 104 itcl::body Rappture::Regression::MainWin::runSelected {args} { 104 105 puts "Running selected tests." 105 106 set selected [$itk_component(tree) getSelected] 106 107 foreach id $selected { 107 runTest $id 108 runTest $id $args 108 109 } 109 110 } 110 111 111 112 # ---------------------------------------------------------------------- 112 # USAGE: runTest id 113 # USAGE: runTest id ?-force? 113 114 # 114 115 # Called by runAll and runSelected to run a single test at tree node 115 116 # 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 118 120 # ---------------------------------------------------------------------- 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 121 itcl::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 } 122 127 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" 125 129 $itk_component(tree) setData $id [array get data] 126 130 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)] 130 133 set tool [Rappture::Tool ::#auto $driver [file dirname $_toolxml]] 131 set result ""132 134 foreach {status result} [eval $tool run] break 133 135 set data(ran) yes 134 136 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"] 137 139 if {$diffs != ""} { 138 set data(result) fail140 set data(result) Fail 139 141 set data(diffs) $diffs 140 142 } else { 141 set data(result) pass143 set data(result) Pass 142 144 } 143 145 } else { 144 set data(result) error146 set data(result) Error 145 147 } 146 148 $itk_component(tree) setData $id [array get data] … … 148 150 } 149 151 150 # ----------------------------------------------------------------------151 # USAGE: makeDriver testxml152 #153 # Creates and returns a driver Rappture::library object to be used for154 # running the test specified by testxml. If any input elements are155 # present in the new tool.xml which do not exist in the test xml, use156 # 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 the161 # test xml, copy the value. If not, use the default from the new162 # tool.xml.163 # For now, just use test xml with the output deleted and command replaced164 set driver [Rappture::library $testxml]165 set cmd [[Rappture::library $_toolxml] get tool.command]166 $driver put tool.command $cmd167 $driver remove output168 return $driver169 } -
trunk/tester/tclIndex
r1963 r1965 15 15 set auto_index(::Rappture::Regression::compare_elements) [list source [file join $dir compare.tcl]] 16 16 set auto_index(::Rappture::Regression::compare) [list source [file join $dir compare.tcl]] 17 set auto_index(::Rappture::Regression::makeDriver) [list source [file join $dir compare.tcl]] 18 set auto_index(::Rappture::Regression::merge) [list source [file join $dir compare.tcl]] 17 19 set auto_index(::Rappture::Regression::TestTree) [list source [file join $dir testtree.tcl]] 18 20 set auto_index(::Rappture::Regression::TestTree::constructor) [list source [file join $dir testtree.tcl]] 21 set auto_index(::Rappture::Regression::TestTree::testdir) [list source [file join $dir testtree.tcl]] 19 22 set auto_index(::Rappture::Regression::TestTree::populate) [list source [file join $dir testtree.tcl]] 20 23 set auto_index(::Rappture::Regression::TestTree::getTests) [list source [file join $dir testtree.tcl]] … … 22 25 set auto_index(::Rappture::Regression::TestTree::getData) [list source [file join $dir testtree.tcl]] 23 26 set auto_index(::Rappture::Regression::TestTree::setData) [list source [file join $dir testtree.tcl]] 27 set auto_index(::Rappture::Regression::TestTree::updateLabel) [list source [file join $dir testtree.tcl]] 24 28 set auto_index(::Rappture::Regression::TestView) [list source [file join $dir testview.tcl]] 25 29 set auto_index(::Rappture::Regression::TestView::constructor) [list source [file join $dir testview.tcl]] -
trunk/tester/testtree.tcl
r1964 r1965 22 22 namespace eval Rappture::Regression::TestTree { #forward declaration } 23 23 24 # ---------------------------------------------------------------------- 25 # CONSTRUCTOR 26 # ---------------------------------------------------------------------- 24 27 itcl::class Rappture::Regression::TestTree { 25 28 inherit itk::Widget … … 48 51 itcl::body Rappture::Regression::TestTree::constructor {args} { 49 52 # TODO: Use separate tree data structure and insert into treeview 50 puts "Constructin ig TestTree."53 puts "Constructing TestTree." 51 54 52 55 itk_component add treeview { … … 55 58 } 56 59 $itk_component(treeview) column insert 0 result 57 $itk_component(treeview) column insert end xmlfileran diffs58 $itk_component(treeview) column configure xmlfileran diffs -hide yes60 $itk_component(treeview) column insert end testxml ran diffs 61 $itk_component(treeview) column configure testxml ran diffs -hide yes 59 62 pack $itk_component(treeview) -expand yes -fill both 60 63 … … 83 86 84 87 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 87 91 } 88 92 pack $itk_component(bRun) -side left … … 97 101 itcl::configbody Rappture::Regression::TestTree::testdir { 98 102 populate 99 }100 101 itcl::configbody Rappture::Regression::TestTree::command {102 $itk_component(bRun) configure -command $command103 103 } 104 104 … … 123 123 if {$testpath != ""} { 124 124 $itk_component(treeview) insert end $testpath -data \ 125 [list xmlfile$testxml ran no result "" diffs ""] \125 [list testxml $testxml ran no result "" diffs ""] \ 126 126 -icons "$icon $icon" -activeicons "$icon $icon" 127 127 } -
trunk/tester/testview.tcl
r1964 r1965 20 20 } 21 21 22 # ---------------------------------------------------------------------- 23 # CONSTRUCTOR 24 # ---------------------------------------------------------------------- 22 25 itcl::body Rappture::Regression::TestView::constructor {args} { 23 26 puts "Constructing TestView."
Note: See TracChangeset
for help on using the changeset viewer.