mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-04-08 18:40:55 +03:00
0023992: it's required to save log information of test command in (specified) file
It is possible now to save log information of test command in specified file. Print information on count of found test cases before tests start Sound signal at the end of the test Used meminfo -h to control memory Titles of differences in images produced by testdiff command were changed.
This commit is contained in:
parent
e3414ada99
commit
433673e0dd
@ -31,27 +31,94 @@ set _test_case_regexp {^CASE\s+([\w.-]+)\s+([\w.-]+)\s+([\w.-]+)\s*:\s*([\w]+)(.
|
|||||||
# Basic command to run indicated test case in DRAW
|
# Basic command to run indicated test case in DRAW
|
||||||
help test {
|
help test {
|
||||||
Run specified test case
|
Run specified test case
|
||||||
Use: test group grid casename [echo=0]
|
Use: test group grid casename [options...]
|
||||||
- If echo is set to 0 (default), log is stored in memory and only summary
|
Allowed options are:
|
||||||
|
-echo: all commands and results are echoed immediately,
|
||||||
|
but log is not saved and summary is not produced
|
||||||
|
It is also possible to use "1" instead of "-echo"
|
||||||
|
If echo is OFF, log is stored in memory and only summary
|
||||||
is output (the log can be obtained with command "dlog get")
|
is output (the log can be obtained with command "dlog get")
|
||||||
- If echo is set to 1 or "-echo", all commands and results are echoed
|
-outfile filename: set log file (should be non-existing),
|
||||||
immediately, but log is not saved and summary is not produced
|
it is possible to save log file in text file or
|
||||||
|
in html file(with snapshot), for that "filename"
|
||||||
|
should have ".html" extension
|
||||||
|
-overwrite: force writing log in existing file
|
||||||
|
-beep: play sound signal at the end of the test
|
||||||
}
|
}
|
||||||
proc test {group grid casename {echo 0}} {
|
proc test {group grid casename {args {}}} {
|
||||||
|
# set default values of arguments
|
||||||
|
set echo 0
|
||||||
|
set logfile ""
|
||||||
|
set overwrite 0
|
||||||
|
set signal 0
|
||||||
|
|
||||||
# get test case paths (will raise error if input is invalid)
|
# get test case paths (will raise error if input is invalid)
|
||||||
_get_test $group $grid $casename dir gridname casefile
|
_get_test $group $grid $casename dir gridname casefile
|
||||||
|
|
||||||
|
# check arguments
|
||||||
|
for {set narg 0} {$narg < [llength $args]} {incr narg} {
|
||||||
|
set arg [lindex $args $narg]
|
||||||
|
|
||||||
# if echo specified as "-echo", convert it to bool
|
# if echo specified as "-echo", convert it to bool
|
||||||
if { "$echo" == "-echo" } { set echo t }
|
if { $arg == "-echo" || $arg == "1" } {
|
||||||
|
set echo t
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
# output log file
|
||||||
|
if { $arg == "-outfile" } {
|
||||||
|
incr narg
|
||||||
|
if { $narg < [llength $args] && ! [regexp {^-} [lindex $args $narg]] } {
|
||||||
|
set logfile [lindex $args $narg]
|
||||||
|
} else {
|
||||||
|
error "Option -outfile requires argument"
|
||||||
|
}
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
# allow overwrite existing log
|
||||||
|
if { $arg == "-overwrite" } {
|
||||||
|
set overwrite 1
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
# sound signal at the end of the test
|
||||||
|
if { $arg == "-beep" } {
|
||||||
|
set signal t
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
# unsupported option
|
||||||
|
error "Error: unsupported option \"$arg\""
|
||||||
|
}
|
||||||
|
|
||||||
# run test
|
# run test
|
||||||
uplevel _run_test $dir $group $gridname $casefile $echo
|
uplevel _run_test $dir $group $gridname $casefile $echo
|
||||||
|
|
||||||
# check log
|
# check log
|
||||||
if { ! $echo } {
|
if { !$echo } {
|
||||||
_check_log $dir $group $gridname $casename [dlog get]
|
_check_log $dir $group $gridname $casename [dlog get] summary html_log
|
||||||
|
|
||||||
|
# create log file
|
||||||
|
if { ! $overwrite && [file isfile $logfile] } {
|
||||||
|
error "Error: Specified log file \"$logfile\" exists; please remove it before running test or use -overwrite option"
|
||||||
|
}
|
||||||
|
if {$logfile != ""} {
|
||||||
|
if {[file extension $logfile] == ".html"} {
|
||||||
|
if {[regexp {vdump ([^\s\n]+)} $html_log dump snapshot]} {
|
||||||
|
catch {file copy -force $snapshot [file rootname $logfile][file extension $snapshot]}
|
||||||
|
}
|
||||||
|
_log_html $logfile $html_log "Test $group $grid $casename"
|
||||||
|
} else {
|
||||||
|
_log_save $logfile "[dlog get]\n$summary" "Test $group $grid $casename"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# play sound signal at the end of test
|
||||||
|
if {$signal} {
|
||||||
|
puts "\7\7\7\7"
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -65,6 +132,7 @@ help testgrid {
|
|||||||
-outdir dirname: set log directory (should be empty or non-existing)
|
-outdir dirname: set log directory (should be empty or non-existing)
|
||||||
-overwrite: force writing logs in existing non-empty directory
|
-overwrite: force writing logs in existing non-empty directory
|
||||||
-xml filename: write XML report for Jenkins (in JUnit-like format)
|
-xml filename: write XML report for Jenkins (in JUnit-like format)
|
||||||
|
-beep: play sound signal at the end of the tests
|
||||||
Groups, grids, and test cases to be executed can be specified by list of file
|
Groups, grids, and test cases to be executed can be specified by list of file
|
||||||
masks, separated by spaces or comma; default is all (*).
|
masks, separated by spaces or comma; default is all (*).
|
||||||
}
|
}
|
||||||
@ -87,6 +155,7 @@ proc testgrid {args} {
|
|||||||
set logdir ""
|
set logdir ""
|
||||||
set overwrite 0
|
set overwrite 0
|
||||||
set xmlfile ""
|
set xmlfile ""
|
||||||
|
set signal 0
|
||||||
for {set narg 0} {$narg < [llength $args]} {incr narg} {
|
for {set narg 0} {$narg < [llength $args]} {incr narg} {
|
||||||
set arg [lindex $args $narg]
|
set arg [lindex $args $narg]
|
||||||
|
|
||||||
@ -141,6 +210,12 @@ proc testgrid {args} {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# sound signal at the end of the test
|
||||||
|
if { $arg == "-beep" } {
|
||||||
|
set signal t
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
# unsupported option
|
# unsupported option
|
||||||
if { [regexp {^-} $arg] } {
|
if { [regexp {^-} $arg] } {
|
||||||
error "Error: unsupported option \"$arg\""
|
error "Error: unsupported option \"$arg\""
|
||||||
@ -288,6 +363,8 @@ proc testgrid {args} {
|
|||||||
}
|
}
|
||||||
if { [llength $tests_list] < 1 } {
|
if { [llength $tests_list] < 1 } {
|
||||||
error "Error: no tests are found, check you input arguments and variable CSF_TestScriptsPath!"
|
error "Error: no tests are found, check you input arguments and variable CSF_TestScriptsPath!"
|
||||||
|
} else {
|
||||||
|
puts "Running tests (total [llength $tests_list] test cases)..."
|
||||||
}
|
}
|
||||||
|
|
||||||
######################################################
|
######################################################
|
||||||
@ -438,7 +515,10 @@ proc testgrid {args} {
|
|||||||
_log_xml_summary $logdir $xmlfile $log 0
|
_log_xml_summary $logdir $xmlfile $log 0
|
||||||
puts "XML summary is saved to $xmlfile"
|
puts "XML summary is saved to $xmlfile"
|
||||||
}
|
}
|
||||||
|
# play sound signal at the end of test
|
||||||
|
if {$signal} {
|
||||||
|
puts "\7\7\7\7"
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -864,7 +944,7 @@ proc _run_test {scriptsdir group gridname casefile echo} {
|
|||||||
# start timer
|
# start timer
|
||||||
uplevel dchrono _timer reset
|
uplevel dchrono _timer reset
|
||||||
uplevel dchrono _timer start
|
uplevel dchrono _timer start
|
||||||
catch {uplevel meminfo w} membase
|
catch {uplevel meminfo h} membase
|
||||||
|
|
||||||
# enable commands logging; switch to old-style mode if dlog command is not present
|
# enable commands logging; switch to old-style mode if dlog command is not present
|
||||||
set dlog_exists 1
|
set dlog_exists 1
|
||||||
@ -961,7 +1041,7 @@ proc _run_test {scriptsdir group gridname casefile echo} {
|
|||||||
|
|
||||||
# add memory and timing info
|
# add memory and timing info
|
||||||
set stats ""
|
set stats ""
|
||||||
if { ! [catch {uplevel meminfo w} memuse] } {
|
if { ! [catch {uplevel meminfo h} memuse] } {
|
||||||
set stats "MEMORY DELTA: [expr ($memuse - $membase) / 1024] KiB\n"
|
set stats "MEMORY DELTA: [expr ($memuse - $membase) / 1024] KiB\n"
|
||||||
}
|
}
|
||||||
uplevel dchrono _timer stop
|
uplevel dchrono _timer stop
|
||||||
@ -1784,7 +1864,9 @@ proc _log_html_diff {file log dir1 dir2} {
|
|||||||
|
|
||||||
# print header
|
# print header
|
||||||
puts $fd "<html><head><title>Diff $dir1 vs. $dir2</title></head><body>"
|
puts $fd "<html><head><title>Diff $dir1 vs. $dir2</title></head><body>"
|
||||||
puts $fd "<h1>Comparison of test results: $dir1 vs. $dir2</h1>"
|
puts $fd "<h1>Comparison of test results:</h1>"
|
||||||
|
puts $fd "<h2>Version A - $dir1</h2>"
|
||||||
|
puts $fd "<h2>Version B - $dir2</h2>"
|
||||||
|
|
||||||
# print log body, trying to add HTML links to script files on lines like
|
# print log body, trying to add HTML links to script files on lines like
|
||||||
# "Executing <filename>..."
|
# "Executing <filename>..."
|
||||||
@ -1808,7 +1890,7 @@ proc _log_html_diff {file log dir1 dir2} {
|
|||||||
set imgd "N/A"
|
set imgd "N/A"
|
||||||
}
|
}
|
||||||
|
|
||||||
puts $fd "<table><tr><th>[file tail $dir1]</th><th>[file tail $dir2]</th><th>Different pixels</th></tr>"
|
puts $fd "<table><tr><th><abbr title=\"$dir1\">Version A</abbr></th><th><abbr title=\"$dir2\">Version B</abbr></th><th>Different pixels</th></tr>"
|
||||||
puts $fd "<tr><td>$img1</td><td>$img2</td><td>$imgd</td></tr></table>"
|
puts $fd "<tr><td>$img1</td><td>$img2</td><td>$imgd</td></tr></table>"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user