Index: openacs-4/packages/acs-automated-testing/tcl/aa-test-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-automated-testing/tcl/aa-test-procs.tcl,v diff -u -r1.29 -r1.30 --- openacs-4/packages/acs-automated-testing/tcl/aa-test-procs.tcl 16 Feb 2004 16:49:21 -0000 1.29 +++ openacs-4/packages/acs-automated-testing/tcl/aa-test-procs.tcl 17 Feb 2004 08:44:01 -0000 1.30 @@ -600,6 +600,9 @@ } } set aa_in_init_class "" + + # Generate the XML report file + aa_test::write_test_file } @@ -1082,6 +1085,78 @@ set service(rebuild_cmd) "sh [file join $service(script_path) recreate.sh]" } +ad_proc -private aa_test::get_test_doc {} { + Returns an XML doc with statistics for the most recent test results + on the server. + + @author Peter Marklund +} { + # Open XML document + set xml_doc " + \n" + + set testcase_count [llength [nsv_get aa_test cases]] + append xml_doc " $testcase_count\n" + + db_foreach result_counts { + select result, + count(*) as result_count + from aa_test_results + group by result + } { + set result_counts($result) $result_count + } + + foreach result [array names result_counts] { + append xml_doc " $result_counts($result)\n" + } + + db_foreach failure_counts { + select testcase_id, + count(*) as failure_count + from aa_test_results + where result = 'fail' + group by testcase_id + } { + set failure_counts($testcase_id) $failure_count + } + + foreach testcase_id [array names failure_counts] { + append xml_doc " $failure_counts($testcase_id)\n" + } + + # Close XML document + append xml_doc "\n" + + return $xml_doc +} + +ad_proc -private aa_test::write_test_file {} { + Writes an XML file with statistics for the most recent test results + on the server. + + @author Peter Marklund + +} { + set xml_doc [get_test_doc] + + set hostname [exec hostname] + set server [ns_info server] + + set report_dir [aa_test::xml_report_dir] + + if { ![file isdirectory $report_dir] } { + if { [catch {exec mkdir -p $report_dir} errmsg] } { + ns_log Error "Could not create directory $report_dir to write xml test report to. Not generating report" + return "" + } + } + + template::util::write_file "$report_dir/${hostname}-${server}-testreport.xml" $xml_doc + + return $xml_doc +} + ad_proc -public aa_test::parse_test_file { {-path:required} {-array:required}