Add the --status option to the test runs using testrunner.tcl. Only works

on Unix platforms.  The "exec" command appears to interfere with VT100
escape codes on windows.

FossilOrigin-Name: 94015cda4ceb4292ceceadb951fe5d9cb3e4e20403719b7254ad094a5b749ab3
This commit is contained in:
drh 2024-08-03 15:55:25 +00:00
parent 8517b7d2b6
commit 4a36d30493
3 changed files with 168 additions and 137 deletions

View File

@ -1,5 +1,5 @@
C Make\ssure\sthe\sinput\sbuffer\sis\sbig\senough\sfor\san\smemcpy()\swhen\sdoing\sthe\nrestore\sautodetection\sin\sthe\sshell.
D 2024-08-02T18:20:10.582
C Add\sthe\s--status\soption\sto\sthe\stest\sruns\susing\stestrunner.tcl.\s\sOnly\sworks\non\sUnix\splatforms.\s\sThe\s"exec"\scommand\sappears\sto\sinterfere\swith\sVT100\nescape\scodes\son\swindows.
D 2024-08-03T15:55:25.995
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
@ -1705,7 +1705,7 @@ F test/temptable2.test 76821347810ecc88203e6ef0dd6897b6036ac788e9dd3e6b04fd4d163
F test/temptable3.test d11a0974e52b347e45ee54ef1923c91ed91e4637
F test/temptrigger.test 38f0ca479b1822d3117069e014daabcaacefffcc
F test/tester.tcl 640106bf8f7785d0ac67cda2837577eb9f2d936033bacedf9e705ca5451958ef
F test/testrunner.tcl 8a32439556e7ebba144e30c46cca95a3780647bd4f0101f3d43fbf92ef86414d
F test/testrunner.tcl 5d02deeba7a53baeadae6aa7641d90aac58fdfa3a7bcac85cfcfd752b1aab87c
F test/testrunner_data.tcl c5ae2b1f9a99210b0600d002fb3af1fee350997cee9416551e83b93501360ebf
F test/thread001.test a0985c117eab62c0c65526e9fa5d1360dd1cac5b03bde223902763274ce21899
F test/thread002.test c24c83408e35ba5a952a3638b7ac03ccdf1ce4409289c54a050ac4c5f1de7502
@ -2202,8 +2202,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
P 2151ea31632f7aa363c7d4b7205e1174a45d710783a8efad8176049d356cfc70
R 4661deca42f48a6dcbd9a9e1fd37e56e
P 1637d29d518b3b4534a1b4c0dc0eddcb770f6f71763e4177812a3e79b97d2365
R 2baa0a7875a2461a2d1db67ee8455074
U drh
Z dd91b61800449a04528ebdc3156c12eb
Z cdd1e09ba643f6fa1e24fe72f8439dd6
# Remove this line to create a well-formed Fossil manifest.

View File

@ -1 +1 @@
1637d29d518b3b4534a1b4c0dc0eddcb770f6f71763e4177812a3e79b97d2365
94015cda4ceb4292ceceadb951fe5d9cb3e4e20403719b7254ad094a5b749ab3

View File

@ -58,7 +58,7 @@ Usage:
$a0 help
$a0 njob ?NJOB?
$a0 script ?-msvc? CONFIG
$a0 status ?-d SECS?
$a0 status ?-d SECS? ?--cls?
where SWITCHES are:
--buildonly Build test exes but do not run tests
@ -67,6 +67,7 @@ Usage:
--explain Write summary to stdout
--jobs NUM Run tests using NUM separate processes
--omit CONFIGS Omit configs on comma-separated list CONFIGS
--status Show the full "status" report while running
--stop-on-coredump Stop running if any test segfaults
--stop-on-error Stop running after any reported error
--zipvfs ZIPVFSDIR ZIPVFS source directory
@ -187,6 +188,7 @@ set TRG(dryrun) 0 ;# True if --dryrun option
set TRG(explain) 0 ;# True for the --explain option
set TRG(stopOnError) 0 ;# Stop running at first failure
set TRG(stopOnCore) 0 ;# Stop on a core-dump
set TRG(fullstatus) 0 ;# Full "status" report while running
switch -nocase -glob -- $tcl_platform(os) {
*darwin* {
@ -386,6 +388,99 @@ if {[string compare -nocase script [lindex $argv 0]]==0} {
puts [trd_buildscript $config [file dirname $testdir] $bMsvc]
exit
}
# Helper routine for show_status
#
proc display_job {jobdict {tm ""}} {
array set job $jobdict
set dfname [format %-60s $job(displayname)]
set dtm ""
if {$tm!=""} {
set dtm [format %-10s "\[[expr {$tm-$job(starttime)}]ms\]"]
}
puts " $dfname $dtm"
}
# This procedure shows the "status" page. It uses the database
# connect passed in as the "db" parameter. If the "cls" parameter
# is true, then VT100 escape codes are used to format the display.
#
proc show_status {db cls} {
global TRG
$db eval BEGIN
if {[catch {
set cmdline [$db one { SELECT value FROM config WHERE name='cmdline' }]
set nJob [$db one { SELECT value FROM config WHERE name='njob' }]
} msg]} {
if {$cls} {puts "\033\[H\033\[2J"}
puts "Cannot read database: $TRG(dbname)"
return
}
set now [clock_milliseconds]
set tm [$db one {
SELECT
COALESCE((SELECT value FROM config WHERE name='end'), $now) -
(SELECT value FROM config WHERE name='start')
}]
set total 0
foreach s {"" ready running done failed} { set S($s) 0 }
$db eval {
SELECT state, count(*) AS cnt FROM jobs GROUP BY 1
} {
incr S($state) $cnt
incr total $cnt
}
set fin [expr $S(done)+$S(failed)]
if {$cmdline!=""} {set cmdline " $cmdline"}
if {$cls} {
# Move the cursor to the top-left corner. Each iteration will simply
# overwrite.
puts -nonewline "\033\[H"
flush stdout
set clreol "\033\[K"
} else {
set clreol ""
}
set f ""
if {$S(failed)>0} {
set f "$S(failed) FAILED, "
}
puts "Command line: \[testrunner.tcl$cmdline\]$clreol"
puts "Jobs: $nJob "
puts "Summary: ${tm}ms, ($fin/$total) finished,\
${f}$S(running) running "
set srcdir [file dirname [file dirname $TRG(info_script)]]
if {$S(running)>0} {
puts "Running: "
$db eval {
SELECT * FROM jobs WHERE state='running' ORDER BY starttime
} job {
display_job [array get job] $now
}
}
if {$S(failed)>0} {
puts "Failures: "
$db eval {
SELECT * FROM jobs WHERE state='failed' ORDER BY starttime
} job {
display_job [array get job]
}
set nOmit [$db one {SELECT count(*) FROM jobs WHERE state='omit'}]
if {$nOmit} {
puts "$nOmit jobs omitted due to failures$clreol"
}
}
if {$cls} {
# Clear everything else to the bottom of the screen
puts -nonewline "\033\[0J"
flush stdout
}
$db eval COMMIT
}
#--------------------------------------------------------------------------
@ -395,6 +490,7 @@ if {[llength $argv]>=1
&& [string compare -nocase status [lindex $argv 0]]==0
} {
set delay 0
set cls 0
for {set ii 1} {$ii<[llength $argv]} {incr ii} {
set a0 [lindex $argv $ii]
if {$a0=="-d" && $ii+1<[llength $argv]} {
@ -404,30 +500,13 @@ if {[llength $argv]>=1
puts "Argument to -d should be an integer"
exit 1
}
} elseif {$a0=="-cls" || $a0=="--cls"} {
set cls 1
} else {
puts "unknown option: \"$a0\""
exit 1
}
}
proc display_job {jobdict {tm ""}} {
array set job $jobdict
set dfname [format %-60s $job(displayname)]
set dtm ""
if {$tm!=""} { set dtm "\[[expr {$tm-$job(starttime)}]ms\]" }
puts " $dfname $dtm"
}
# The clreol proc returns the VT100 escape code for clear-to-end-of-line,
# if delay>0. If we are only painting the status once, it returns an
# empty string.
#
if {$delay>0} {
proc clreol {} {return ""}
} else {
proc clreol {} {return \033K}
}
if {![file readable $TRG(dbname)]} {
puts "Database missing: $TRG(dbname)"
@ -438,78 +517,10 @@ if {[llength $argv]>=1
# Clear the whole screen initially.
#
if {$delay>0} {puts -nonewline "\033\[2J"}
if {$delay>0 || $cls} {puts -nonewline "\033\[2J"}
while {1} {
mydb eval BEGIN
if {[catch {
set cmdline [mydb one { SELECT value FROM config WHERE name='cmdline' }]
set nJob [mydb one { SELECT value FROM config WHERE name='njob' }]
} msg]} {
puts "Cannot read database: $TRG(dbname)"
mydb close
exit
}
set now [clock_milliseconds]
set tm [mydb one {
SELECT
COALESCE((SELECT value FROM config WHERE name='end'), $now) -
(SELECT value FROM config WHERE name='start')
}]
set total 0
foreach s {"" ready running done failed} { set S($s) 0 }
mydb eval {
SELECT state, count(*) AS cnt FROM jobs GROUP BY 1
} {
incr S($state) $cnt
incr total $cnt
}
set fin [expr $S(done)+$S(failed)]
if {$cmdline!=""} {set cmdline " $cmdline"}
if {$delay>0} {
# Move the cursor to the top-left corner. Each iteration will simply
# overwrite.
puts -nonewline "\033\[H"
}
set f ""
if {$S(failed)>0} {
set f "$S(failed) FAILED, "
}
puts "Command line: \[testrunner.tcl$cmdline\]"
puts "Jobs: $nJob"
puts "Summary: ${tm}ms, ($fin/$total) finished,\
${f}$S(running) running "
set srcdir [file dirname [file dirname $TRG(info_script)]]
if {$S(running)>0} {
puts "Running: "
mydb eval {
SELECT * FROM jobs WHERE state='running' ORDER BY starttime
} job {
display_job [array get job] $now
}
}
if {$S(failed)>0} {
puts "Failures: "
mydb eval {
SELECT * FROM jobs WHERE state='failed' ORDER BY starttime
} job {
display_job [array get job]
}
set nOmit [mydb one {SELECT count(*) FROM jobs WHERE state='omit'}]
if {$nOmit} {
puts "$nOmit jobs omitted due to failures[clreol]"
}
}
if {$delay>0} {
# Clear everything else to the bottom of the screen
puts -nonewline "\033\[J"
flush stdout
}
mydb eval COMMIT
show_status mydb [expr {$delay>0 || $cls}]
if {$delay<=0} break
after [expr {$delay*1000}]
}
@ -616,6 +627,16 @@ for {set ii 0} {$ii < [llength $argv]} {incr ii} {
set TRG(stopOnError) 1
} elseif {[string match "$a*" --stop-on-coredump]} {
set TRG(stopOnCore) 1
} elseif {[string match "$a*" --status]} {
if {$tcl_platform(platform)=="windows"} {
puts stdout \
"The --status option is not available on Windows. A suggested work-around"
puts stdout \
"is to run the following command in a separate window:\n"
puts stdout " [info nameofexe] $argv0 status -d 2\n"
} else {
set TRG(fullstatus) 1
}
} else {
usage
}
@ -1245,49 +1266,58 @@ proc launch_another_job {iJob} {
return 1
}
proc one_line_report {} {
# Show the testing progress report
#
proc progress_report {} {
global TRG
set tm [expr [clock_milliseconds] - $TRG(starttime)]
set tm [format "%d" [expr int($tm/1000.0 + 0.5)]]
r_write_db {
trdb eval {
SELECT displaytype, state, count(*) AS cnt
FROM jobs
GROUP BY 1, 2
} {
set v($state,$displaytype) $cnt
incr t($displaytype) $cnt
if {$TRG(fullstatus)} {
if {$::tcl_platform(platform)=="windows"} {
exec [info nameofexe] $::argv0 status --cls
} else {
show_status trdb 1
}
}
set text ""
foreach j [lsort [array names t]] {
foreach k {done failed running} { incr v($k,$j) 0 }
set fin [expr $v(done,$j) + $v(failed,$j)]
lappend text "${j}($fin/$t($j))"
if {$v(failed,$j)>0} {
lappend text "f$v(failed,$j)"
}
if {$v(running,$j)>0} {
lappend text "r$v(running,$j)"
}
}
if {[info exists TRG(reportlength)]} {
puts -nonewline "[string repeat " " $TRG(reportlength)]\r"
}
set report "${tm} [join $text { }]"
set TRG(reportlength) [string length $report]
if {[string length $report]<100} {
puts -nonewline "$report\r"
flush stdout
} else {
puts $report
set tm [expr [clock_milliseconds] - $TRG(starttime)]
set tm [format "%d" [expr int($tm/1000.0 + 0.5)]]
r_write_db {
trdb eval {
SELECT displaytype, state, count(*) AS cnt
FROM jobs
GROUP BY 1, 2
} {
set v($state,$displaytype) $cnt
incr t($displaytype) $cnt
}
}
set text ""
foreach j [lsort [array names t]] {
foreach k {done failed running} { incr v($k,$j) 0 }
set fin [expr $v(done,$j) + $v(failed,$j)]
lappend text "${j}($fin/$t($j))"
if {$v(failed,$j)>0} {
lappend text "f$v(failed,$j)"
}
if {$v(running,$j)>0} {
lappend text "r$v(running,$j)"
}
}
if {[info exists TRG(reportlength)]} {
puts -nonewline "[string repeat " " $TRG(reportlength)]\r"
}
set report "${tm} [join $text { }]"
set TRG(reportlength) [string length $report]
if {[string length $report]<100} {
puts -nonewline "$report\r"
flush stdout
} else {
puts $report
}
}
after $TRG(reporttime) one_line_report
after $TRG(reporttime) progress_report
}
proc launch_some_jobs {} {
@ -1312,13 +1342,14 @@ proc run_testset {} {
launch_some_jobs
one_line_report
if {$TRG(fullstatus)} {puts "\033\[2J"}
progress_report
while {[dirs_nHelper]>0} {
after 500 {incr ::wakeup}
vwait ::wakeup
}
close $TRG(log)
one_line_report
progress_report
r_write_db {
set tm [clock_milliseconds]