Check-in [f8e23f8a39]
Overview
Comment:Added new script to publish test results

Updated existing publish script to include failure count

Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:f8e23f8a39a1c2df28f042f945d44163fd8758f4
User & Date: rkeene on 2010-09-26 04:46:55
Other Links: manifest | tags
Context
2010-09-26
04:47
Replaced publish-tests script with HTML'ified Tcl version check-in: 824e5d844d user: rkeene tags: trunk
04:46
Added new script to publish test results

Updated existing publish script to include failure count check-in: f8e23f8a39 user: rkeene tags: trunk

04:46
Updated to clean up all log files from succesful tests check-in: 7720fda215 user: rkeene tags: trunk
Changes

Modified build/test/publish-tests from [db5cad6f63] to [6cafb5c1e8].

    12     12   rm -rf "${WEBDIR}"
    13     13   mkdir -p "${WEBDIR}" || exit 1
    14     14   
    15     15   cp -r kits/* "${WEBDIR}"
    16     16   
    17     17   ln -s ../index.ttml "${WEBDIR}/" >/dev/null 2>/dev/null
    18     18   
           19  +totaltests_count="$(ls -1 tests/*.tcl | wc -l)"
           20  +
    19     21   for file in "${WEBDIR}"/*; do
    20     22   	if [ -d "${file}" ]; then
    21     23   		continue
    22     24   	fi
    23     25   
    24     26   	if echo "${file}" | egrep '\.(log|desc|ttml)$' >/dev/null; then
    25     27   		continue
    26     28   	fi
    27     29   
           30  +	# Find out which tests failed
           31  +	failedtests_count="0"
           32  +	failedtests=""
           33  +	for faillog in "${file}"-[0-9][0-9]-*.log; do
           34  +		if [ ! -f "${faillog}" ]; then
           35  +			continue
           36  +		fi
           37  +
           38  +		failedtests_count=$[${failedtests} + 1]
           39  +		failedtests="${failedtests} $(basename "${faillog}")"
           40  +	done
           41  +
           42  +	# Generate description
    28     43   	descfile="${file}.desc"
    29     44   	shortfile="$(basename "${file}")"
    30     45   	desc=""
    31     46   
    32     47   	tclversion="$(echo "${shortfile}" | cut -f 2 -d -)"
    33     48   	parts="$(echo "${shortfile}" | cut -f 3- -d -)"
    34     49   
................................................................................
    81     96   		fi
    82     97   	done
    83     98   
    84     99   	if [ -z "${desc}" ]; then
    85    100   		continue
    86    101   	fi
    87    102   
          103  +	# Generate better Tcl version
    88    104   	case "${tclversion}" in
    89    105   		cvs_HEAD)
    90    106   			tclversion="from CVS HEAD"
    91    107   			;;
    92    108   		cvs_*)
    93    109   			tclversion="from CVS tag $(echo "${tclversion}" | cut -f 2 -d _)"
    94    110   			;;
    95    111   	esac
          112  +
          113  +	# Update description with count of failed tests
          114  +	if [ "${failedtests_count}" != "0" ]; then
          115  +		desc="${desc} (FAILED ${failedtests_count} of ${totaltests_count} tests)"
          116  +	fi
    96    117   
    97    118   	desc="is a Tclkit for Tcl ${tclversion}${desc}"
    98    119   
    99         -	echo "${desc}" > "${descfile}"
   100    120   done
   101         -
   102    121   
   103    122   rmdir "${WEBDIR}/failed" >/dev/null 2>/dev/null
   104    123   ln -s ../index.ttml "${WEBDIR}/failed/" >/dev/null 2>/dev/null
   105    124   
   106    125   exit 0

Added build/test/publish-tests.tcl version [b70c6b112e].

            1  +#! /usr/bin/env tclsh
            2  +
            3  +package require Tcl 8.5
            4  +
            5  +set WEBDIR "/web/rkeene/devel/kitcreator/kitbuild"
            6  +if {![file isdir "kits"]} {
            7  +	puts stderr "Could not find kits/ directory, aborting."
            8  +
            9  +        exit 1
           10  +}
           11  +
           12  +set noncriticaltests [list "05-locale"]
           13  +
           14  +##########################################################################
           15  +## PROCEDURES ############################################################
           16  +##########################################################################
           17  +proc pretty_print_key {key} {
           18  +	set version [lindex $key 0]
           19  +	set os [lindex $key 1]
           20  +	set cpu [lindex $key 2]
           21  +
           22  +	switch -glob -- $version {
           23  +		"cvs_HEAD" {
           24  +			set version "from CVS HEAD"
           25  +		}
           26  +		"cvs_*" {
           27  +			set tag [join [lrange [split $version _] 1 end] _]
           28  +			set version "from CVS tag $tag"
           29  +		}
           30  +		default {
           31  +			set version "version $version"
           32  +		}
           33  +	}
           34  +
           35  +	return "Tcl $version for [string totitle $os] on $cpu"
           36  +}
           37  +
           38  +proc pretty_print_buildinfo {buildinfo} {
           39  +	set desc [list]
           40  +	foreach tag [list min static notk statictk threaded zip] {
           41  +		if {[lsearch -exact $buildinfo $tag] != -1} {
           42  +			switch -- $tag {
           43  +				"min" {
           44  +					lappend desc "Minimally Built"
           45  +				}
           46  +				"static" {
           47  +					lappend desc "Statically Linked"
           48  +				}
           49  +				"notk" {
           50  +					lappend desc "Without Tk"
           51  +				}
           52  +				"statictk" {
           53  +					lappend desc "Tk linked to Kit"
           54  +				}
           55  +				"threaded" {
           56  +					lappend desc "Threaded"
           57  +				}
           58  +				"zip" {
           59  +					lappend desc "Kit Filesystem in Zip"
           60  +				}
           61  +			}
           62  +		}
           63  +	}
           64  +
           65  +	if {[llength $desc] == 0} {
           66  +		return "Default Build"
           67  +	}
           68  +
           69  +	return [join $desc {, }]
           70  +}
           71  +
           72  +proc pretty_print_size {size} {
           73  +	foreach unit [list "" K M G T P] {
           74  +		if {$size < 1024} {
           75  +			return "$size [string trim ${unit}B]"
           76  +		}
           77  +
           78  +		set size [expr {${size} / 1024}]
           79  +	}
           80  +}
           81  +
           82  +##########################################################################
           83  +## MAIN BODY #############################################################
           84  +##########################################################################
           85  +
           86  +file delete -force -- $WEBDIR
           87  +file mkdir $WEBDIR
           88  +
           89  +set fd [open [file join $WEBDIR index.html] w]
           90  +
           91  +file copy -force -- {*}[glob kits/*] $WEBDIR
           92  +
           93  +set totaltests_count [llength [glob tests/*.tcl]]
           94  +
           95  +foreach file [lsort -dictionary [glob -directory $WEBDIR *]] {
           96  +	if {[file isdirectory $file]} {
           97  +		continue
           98  +	}
           99  +
          100  +	switch -glob -- $file {
          101  +		"*.log" - "*.ttml" - "*.html" - "*.desc" {
          102  +			continue
          103  +		}
          104  +	}
          105  +
          106  +	# Derive what we can from the filename
          107  +	set shortfile [file tail $file]
          108  +	set buildfile "${shortfile}-build.log"
          109  +	set failedtests [glob -nocomplain -tails -directory $WEBDIR "${shortfile}-\[0-9\]\[0-9\]-*.log"]
          110  +
          111  +	## Split the filename into parts and store each part
          112  +	set kitbuildinfo [split $shortfile -]
          113  +	set tclversion [lindex $kitbuildinfo 1]
          114  +	set kitbuildinfo [lsort -dictionary [lrange $kitbuildinfo 2 end]]
          115  +
          116  +	## Determine Kit OS from random file names
          117  +	unset -nocomplain kitos kitcpu
          118  +	if {[lsearch -exact $kitbuildinfo "win32"] != -1} {
          119  +		set idx [lsearch -exact $kitbuildinfo "win32"]
          120  +		set kitbuildinfo [lreplace $kitbuildinfo $idx $idx]
          121  +		set kitos "windows"
          122  +		set kitcpu "i586"
          123  +	} elseif {[lsearch -exact $kitbuildinfo "arm"] != -1} {
          124  +		set idx [lsearch -exact $kitbuildinfo "arm"]
          125  +		set kitbuildinfo [lreplace $kitbuildinfo $idx $idx]
          126  +		set kitos "linux"
          127  +		set kitcpu "arm"
          128  +	} else {
          129  +		set idx [lsearch -exact $kitbuildinfo "normal"]
          130  +		if {$idx != -1} {
          131  +			set kitbuildinfo [lreplace $kitbuildinfo $idx $idx]
          132  +		}
          133  +
          134  +		set kitos [string tolower $tcl_platform(os)]
          135  +		set kitcpu [string tolower $tcl_platform(machine)]
          136  +	}
          137  +
          138  +	# Generate array to describe this kit
          139  +	unset -nocomplain kitinfo
          140  +	set kitinfo(version) $tclversion
          141  +	set kitinfo(file) $shortfile
          142  +	set kitinfo(buildfile) $buildfile
          143  +	set kitinfo(failedtests) $failedtests
          144  +	set kitinfo(buildflags) $kitbuildinfo
          145  +	set kitinfo(os) $kitos
          146  +	set kitinfo(cpu) $kitcpu
          147  +
          148  +	# Store kit information with all kits
          149  +	set key [list $tclversion $kitos $kitcpu]
          150  +	lappend allkitinfo($key) [array get kitinfo]
          151  +}
          152  +
          153  +puts $fd "<html>"
          154  +puts $fd "  <head>"
          155  +puts $fd "    <title>KitCreator Build Status</title>"
          156  +puts $fd "  </head>"
          157  +puts $fd "  <body>"
          158  +puts $fd "    <table cellpadding=\"2\" border=\"1\">"
          159  +foreach key [lsort -dictionary [array names allkitinfo]] {
          160  +	puts $fd "      <tr>"
          161  +	puts $fd "        <th><u>Tclkit for [pretty_print_key $key]</u></th>"
          162  +	puts $fd "        <th>Status</th>"
          163  +	puts $fd "        <th>Log</th>"
          164  +	puts $fd "        <th>Failed Tests</th>"
          165  +	puts $fd "      </tr>"
          166  +	foreach kitinfo_list $allkitinfo($key) {
          167  +		puts $fd "      <tr>"
          168  +		unset -nocomplain kitinfo
          169  +		array set kitinfo $kitinfo_list
          170  +
          171  +		if {[llength $kitinfo(failedtests)] == 0} {
          172  +			set status "OK"
          173  +			set bgcolor "green"
          174  +		} else {
          175  +			set status "FAILED"
          176  +			set bgcolor "yellow"
          177  +		}
          178  +
          179  +		set failedtestshtml [list]
          180  +		foreach test [lsort -dictionary $kitinfo(failedtests)] {
          181  +			set testname [file rootname $test]
          182  +			set testname [split $testname -]
          183  +
          184  +			for {set idx 0} {$idx < [llength $testname]} {incr idx} {
          185  +				set val [lindex $testname $idx]
          186  +				if {[string match {[0-9][0-9]} $val]} {
          187  +					set testname [join [lrange $testname $idx end] -]
          188  +
          189  +					break
          190  +				}
          191  +			}
          192  +
          193  +			if {[lsearch -exact $noncriticaltests $testname] == -1} {
          194  +				set bgcolor "red"
          195  +			}
          196  +
          197  +			lappend failedtestshtml "<small><a href=\"$test\">$testname</a></small>"
          198  +		}
          199  +
          200  +
          201  +		puts $fd "        <td><a href=\"$kitinfo(file)\">[pretty_print_buildinfo $kitinfo(buildflags)]</a></td>"
          202  +		puts $fd "        <td bgcolor=\"$bgcolor\">$status</td>"
          203  +		puts $fd "        <td><small><a href=\"$kitinfo(buildfile)\">([pretty_print_size [file size [file join $WEBDIR $kitinfo(buildfile)]]])</a></small></td>"
          204  +		puts $fd "        <td>[join $failedtestshtml {, }]</td>"
          205  +		puts $fd "      </tr>"
          206  +	}
          207  +
          208  +}
          209  +puts $fd "    </table>"
          210  +puts $fd "  </body>"
          211  +puts $fd "</html>"
          212  +
          213  +close $fd