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.1 -r1.1.4.1 --- openacs-4/packages/acs-automated-testing/tcl/aa-test-procs.tcl 11 Nov 2001 18:03:52 -0000 1.1 +++ openacs-4/packages/acs-automated-testing/tcl/aa-test-procs.tcl 1 May 2003 09:59:03 -0000 1.1.4.1 @@ -730,6 +730,43 @@ } } +ad_proc aa_run_with_teardown { + {-test_code:required} + {-teardown_code:required} +} { + Execute code in test_code and guarantee that code in + teardown_code will be executed even if error is thrown. Will catch + errors in teardown_code as well and provide stack traces for both code blocks. + + @param test_code Tcl code that sets up the test case and executes tests + @param teardown_code Tcl code that tears down database data etc. that needs to execute + after testing even if error is thrown. + + @author Peter Marklund +} { + # Testing + set setup_error_p [catch $test_code setup_error] + global errorInfo + set setup_error_stack $errorInfo + + # Teardown + set teardown_error_p [catch $teardown_code teardown_error] + global errorInfo + set teardown_error_stack $errorInfo + + # Provide meaningful error messages and stack traces + set error_text "" + if { $setup_error_p } { + append error_text "Setup failed with error $setup_error\n\n$setup_error_stack" + } + if { $teardown_error_p } { + append error_text "\n\nTeardown failed with error $teardown_error\n\n$teardown_error_stack" + } + if { ![empty_string_p $error_text] } { + error $error_text + } +} + # # Set the valid testcase categories list, and testcase/component lists. # Index: openacs-4/packages/acs-tcl/tcl/utilities-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-tcl/tcl/utilities-procs.tcl,v diff -u -r1.19.2.14 -r1.19.2.15 --- openacs-4/packages/acs-tcl/tcl/utilities-procs.tcl 28 Apr 2003 08:48:57 -0000 1.19.2.14 +++ openacs-4/packages/acs-tcl/tcl/utilities-procs.tcl 1 May 2003 09:59:23 -0000 1.19.2.15 @@ -2709,6 +2709,30 @@ return $set_id } +ad_proc -public util_sets_equal_p { list1 list2 } { + Tests whether each unique string in list1 occurs as many + times in list1 as in list2 and vice versa (regarless of order). + + @return 1 if the lists have identical sets and 0 otherwise + + @author Peter Marklund +} { + if { [llength $list1] != [llength $list2] } { + return 0 + } + + set sorted_list1 [lsort $list1] + set sorted_list2 [lsort $list2] + + for { set index1 0 } { $index1 < [llength $sorted_list1] } { incr index1 } { + if { ![string equal [lindex $sorted_list1 $index1] [lindex $sorted_list2 $index1]] } { + return 0 + } + } + + return 1 +} + ad_proc -public ad_tcl_list_list_to_ns_set { -set_id -put:boolean