source: trunk/tester/scripts/auto.tcl @ 4503

Last change on this file since 4503 was 4127, checked in by mmc, 7 years ago

Added a "-auto" option to "rappture -tester" so you can run all tests
without the GUI in the background. This is needed as we try to run
regressions automatically during the contribtool process. In order to
do this, I had to split the Tool object into a "Task" that can run
without the GUI, and the "Tool" that acts as a ControlOwner?. I also
had to support for resource file processing into the generic Rappture
package. As a result, "rappture -tester -auto" can run without an
X window connection.

Added support for "job_protocol mx" in the resources file. If you
specify this, then Rappture will execute "mx cmd arg arg..." to run
each job.

  • Property svn:executable set to *
File size: 3.5 KB
Line 
1#! /bin/sh
2# ----------------------------------------------------------------------
3#  RAPPTURE REGRESSION TESTER
4#
5#  This program will read a set of test xml files typically located in
6#  a tool's "tests" subdirectory, and provide an automatic test suite.
7#  Similar to main.tcl, but runs all tests automatically and exits with
8#  status code zero if all tests pass.
9#
10#  USAGE: auto.tcl ?-tool tool.xml? ?-testdir tests?
11# ======================================================================
12#  AUTHORS:  Michael McLennan, Purdue University
13#  Copyright (c) 2004-2012  HUBzero Foundation, LLC
14#
15#  See the file "license.terms" for information on usage and
16#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
17# ======================================================================
18#\
19exec tclsh "$0" $*
20# ----------------------------------------------------------------------
21# tclsh executes everything from here on...
22
23set testerdir [file dirname [file normalize [info script]]]
24lappend auto_path $testerdir
25
26# bring in the Rappture object system
27package require Rappture
28Rappture::objects::init
29Rappture::resources::load
30
31Rappture::getopts argv params {
32    value -tool ""
33    value -testdir ""
34}
35
36# If tool.xml and test directory locations are not given, try to find them.
37if {$params(-tool) == ""} {
38    if {[file isfile tool.xml]} {
39        set params(-tool) tool.xml
40    } elseif {[file isfile [file join rappture tool.xml]]} {
41        set params(-tool) [file join rappture tool.xml]
42    } else {
43        puts "Cannot find tool.xml"
44        exit 1
45    }
46} elseif {![file isfile $params(-tool)]} {
47    puts "Tool \"$params(-tool)\" does not exist"
48    exit 1
49}
50
51if {$params(-testdir) == ""} {
52    set tooldir [file dirname $params(-tool)]
53    if {[file isdirectory [file join $tooldir tests]]} {
54        set params(-testdir) [file join $tooldir tests]
55    } elseif {[file isdirectory [file join [file dirname $tooldir] tests]]} {
56        set params(-testdir) [file join [file dirname $tooldir] tests]
57    } else {
58        puts "Cannot find test directory"
59        exit 1
60    }
61} elseif {![file isdirectory $params(-testdir)]} {
62    puts "Test directory \"$params(-testdir)\" does not exist"
63    exit 1
64}
65
66set installdir [file dirname [file normalize $params(-tool)]]
67set xmlobj [Rappture::library $params(-tool)]
68set TaskObj [Rappture::Task ::#auto $xmlobj $installdir]
69
70# tasks in the tester run quietly and discard results
71$TaskObj configure -jobstats "" -resultdir ""
72
73# Load all tests in the test directory
74# ----------------------------------------------------------------------
75set testlist [glob -nocomplain -directory $params(-testdir) *.xml]
76if {[llength $testlist] == 0} {
77    puts stderr "ERROR:  no tests found in $params(-testdir)"
78    exit 1
79}
80
81set nerrors 0
82foreach file [glob -nocomplain -directory $params(-testdir) *.xml] {
83    set testobj [Rappture::Tester::Test ::#auto $TaskObj $file]
84    if {[$testobj getTestInfo test.label] eq ""} {
85        puts stderr "ERROR:  Missing test label in $file"
86        incr nerrors
87        continue
88    }
89
90    set status [$testobj run]
91
92    if {$status ne "finished"} {
93        puts stderr "ERROR:  test $file didn't finish -- $status"
94        incr nerrors
95        continue
96    }
97    if {[$testobj getResult] ne "Pass"} {
98        set diffs [$testobj getDiffs]
99        puts stderr "FAILED:  $file ([llength $diffs] differences)"
100        incr nerrors
101        continue
102    }
103}
104
105if {$nerrors > 0} {
106    set errs [expr {($nerrors == 1) ? "ERROR" : "ERRORS"}]
107    puts stderr "\n$nerrors $errs TOTAL"
108}
Note: See TracBrowser for help on using the repository browser.