Changeset 2017 for trunk/tester


Ignore:
Timestamp:
Dec 21, 2010 9:41:54 PM (9 years ago)
Author:
braffert
Message:

Regression tester: added ability to track missing and new outputs

Location:
trunk/tester
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/tester/compare.tcl

    r2013 r2017  
    3030#
    3131# 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.
     32# match.  Only paths which exist in both libraries are considered.
     33# Return value will contain all differences that occur as descendants of
     34# an optional starting path.  If the path argument is not given, then
     35# only the output sections will be compared.
    3736# ----------------------------------------------------------------------
    3837proc Rappture::Tester::compare {lib1 lib2 {path output}} {
    39     set diffs [list]
    40     foreach child [$lib1 children $path] {
    41         foreach diff [compare $lib1 $lib2 $path.$child] {
    42             lappend diffs $diff
     38    set paths [list]
     39    set clist1 [$lib1 children $path]
     40    set clist2 [$lib2 children $path]
     41    foreach child $clist1 {
     42        # Ignore if not present in both libraries
     43        if {[lsearch -exact $clist2 $child] != -1} {
     44            foreach p [compare $lib1 $lib2 $path.$child] {
     45                lappend paths $p
     46            }
    4347        }
    4448    }
     
    4650        # Ignore output.time and output.user
    4751        if {$path != "output.time" && $path != "output.user"} {
    48             lappend diffs $path
     52            lappend paths $path
    4953        }
    5054    }
    51     return $diffs
     55    return $paths
    5256}
    5357
     58# TODO: Should we report differences in input side as well?
     59
     60proc Rappture::Tester::missing {lib1 lib2 {path output}} {
     61    set paths [list]
     62    foreach child [$lib1 children $path] {
     63        foreach p [missing $lib1 $lib2 $path.$child] {
     64            lappend paths $p
     65        }
     66    }
     67    if {[$lib1 get $path] != "" && [$lib2 get $path] == ""} {
     68        lappend paths $path
     69    }
     70    return $paths
     71}
     72
     73proc Rappture::Tester::added {lib1 lib2 {path output}} {
     74    set paths [list]
     75    foreach child [$lib2 children $path] {
     76        foreach p [added $lib1 $lib2 $path.$child] {
     77            lappend paths $p
     78        }
     79    }
     80    if {[$lib1 get $path] == "" && [$lib2 get $path] != ""} {
     81        lappend paths $path
     82    }
     83    return $paths
     84}
     85
  • trunk/tester/example/tests/test7.xml

    r2012 r2017  
    22<run>
    33    <test>
    4         <label>multiple|levels|of|separators</label>
     4        <label>multiple|levels|spaces are allowed|</label>
    55    </test>
    66    <tool>
  • trunk/tester/tester.tcl

    r2013 r2017  
    121121    if {$status == 0 && [Rappture::library isvalid $result]} {
    122122        set golden [Rappture::library $darray(testxml)]
    123         set diffs [Rappture::Tester::compare $golden $result output]
    124         if {$diffs == ""} {
     123        set diffs [Rappture::Tester::compare $golden $result]
     124        set missing [Rappture::Tester::missing $golden $result]
     125        set added [Rappture::Tester::added $golden $result]
     126        if {$diffs == "" && $missing == "" && $added == ""} {
    125127            set darray(result) Pass
    126128        } else {
     
    128130        }
    129131        set darray(diffs) $diffs
     132        set darray(missing) $missing
     133        set darray(added) $added
    130134        set darray(runfile) [$tool getRunFile]
    131135    } else {
     
    203207
    204208# ----------------------------------------------------------------------
    205 # TODO
     209# USAGE: regoldenize
     210#
     211# Regoldenizes the currently focused test case.  Displays a warning
     212# message.  If confirmed, copy the test information from the existing
     213# test xml into the new result, and write the new data into the test
     214# xml.
    206215# ----------------------------------------------------------------------
    207216proc Rappture::Tester::regoldenize {} {
  • trunk/tester/testtree.tcl

    r2013 r2017  
    1919package require BLT
    2020package require Rappture
    21 # TODO: pipe separator allow spaces
     21
    2222namespace eval Rappture::Tester::TestTree { #forward declaration }
    2323
     
    6969    }
    7070    $itk_component(treeview) column insert 0 result -width 75
    71     $itk_component(treeview) column insert end testxml ran diffs runfile
    72     $itk_component(treeview) column configure testxml ran diffs runfile \
    73         -hide yes
     71    $itk_component(treeview) column insert end testxml ran diffs missing \
     72        added runfile
     73    $itk_component(treeview) column configure testxml ran diffs missing \
     74        added runfile -hide yes
    7475    $itk_component(scrollbars) contents $itk_component(treeview)
    7576
  • trunk/tester/testview.tcl

    r2013 r2017  
    204204        if {$darray(result) == "Fail"} {
    205205            $itk_component(result) insert end "Diffs: $darray(diffs)\n"
     206            $itk_component(result) insert end "Missing: $darray(missing)\n"
     207            $itk_component(result) insert end "Added: $darray(added)\n"
    206208        }
    207209    } else {
Note: See TracChangeset for help on using the changeset viewer.