Index: openacs-4/packages/acs-bootstrap-installer/bootstrap.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-bootstrap-installer/bootstrap.tcl,v diff -u -N -r1.12 -r1.13 --- openacs-4/packages/acs-bootstrap-installer/bootstrap.tcl 10 Sep 2002 22:22:05 -0000 1.12 +++ openacs-4/packages/acs-bootstrap-installer/bootstrap.tcl 15 Nov 2002 13:07:50 -0000 1.13 @@ -130,14 +130,45 @@ nsv_set apm_enabled_package $package_key 1 } + # + # Check for the presence of the automated testing package. + # + set load_tests_p 0 + foreach enabled_p [db_list automated_test_enabled_select { + select attr_value as enabled_p + from apm_parameter_values, apm_parameters + where apm_parameter_values.parameter_id = apm_parameters.parameter_id and + apm_parameters.parameter_name = 'enabled_p' and + apm_parameter_values.package_id in + (select package_id from apm_packages, site_nodes + where package_key = 'acs-automated-testing' and + apm_packages.package_id = site_nodes.object_id); + }] { + if {$enabled_p} { + set load_tests_p 1 + } + } + + # Load *-procs.tcl and *-init.tcl files for enabled packages. apm_load_libraries -procs # Load up the Queries (OpenACS, ben@mit.edu) apm_load_queries + # Load up the Automated Tests and associated Queries if necessary + if {$load_tests_p} { + apm_load_libraries -test_procs + apm_load_queries -test_queries + } + apm_load_libraries -init + # Load up the Automated Tests initialisation scripts is necessary + if {$load_tests_p} { + apm_load_libraries -test_init + } + if { ![nsv_exists rp_properties request_count] } { # security-init.tcl has not been invoked, so it's safe to say that the # core has not been properly initialized and the server will probably Index: openacs-4/packages/acs-tcl/tcl/apm-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-tcl/tcl/apm-procs.tcl,v diff -u -N -r1.24 -r1.25 --- openacs-4/packages/acs-tcl/tcl/apm-procs.tcl 7 Oct 2002 15:15:54 -0000 1.24 +++ openacs-4/packages/acs-tcl/tcl/apm-procs.tcl 15 Nov 2002 13:07:24 -0000 1.25 @@ -253,6 +253,8 @@ {-callback apm_dummy_callback} {-procs:boolean} {-init:boolean} + {-test_procs:boolean} + {-test_init:boolean} } { Loads all -procs.tcl (if $procs_or_init is "procs") or -init.tcl (if $procs_or_init is @@ -293,8 +295,16 @@ set paths [concat $paths [glob -nocomplain "$dir/*init.tcl"]] set paths [concat $paths [glob -nocomplain "$dir/*init-[db_type].tcl"]] } + if {$test_procs_p} { + set paths [concat $paths [glob -nocomplain "$dir/test/*procs.tcl"]] + set paths [concat $paths [glob -nocomplain "$dir/test/*procs-[db_type].tcl"]] + } + if {$test_init_p} { + set paths [concat $paths [glob -nocomplain "$dir/test/*init.tcl"]] + set paths [concat $paths [glob -nocomplain "$dir/test/*init-[db_type].tcl"]] + } } - + foreach path [lsort $paths] { set rel_path [string range $path $base_len end] lappend files [list $package $rel_path] @@ -314,6 +324,7 @@ # but is only loading query information ad_proc -private apm_load_queries { {-callback apm_dummy_callback} + {-test_queries:boolean} } { set packages [db_list apm_enabled_packages_q { select distinct package_key @@ -330,12 +341,33 @@ ns_log Error "apm_load_queries: Unable to locate [acs_root_dir]/packages/$package/*. when scanning for SQL queries to load." } + set testdir "[acs_root_dir]/packages/$package/tcl/test" + set testlength [string length $testdir] + foreach file [lsort $files] { set file_db_type [apm_guess_db_type $package $file] set file_type [apm_guess_file_type $package $file] - if {[string equal $file_type query_file] && + if {![string compare -length $testlength $testdir $file]} { + set is_test_file_p 1 + } else { + set is_test_file_p 0 + } + + # + # Note this exclusive or represents the following: + # test_queries_p - Load normal xql files or load test xql files + # is_test_file_p - Current file is a test file or not. + # + # !(test_queries_p ^ is_test_file_p) = Load it or not? + # !( 0 ^ 0 ) = Yep + # !( 0 ^ 1 ) = Nope + # !( 1 ^ 0 ) = Nope + # !( 1 ^ 1 ) = Yep + # + if {![expr $test_queries_p ^ $is_test_file_p] && + [string equal $file_type query_file] && ([empty_string_p $file_db_type] || [string equal $file_db_type [db_type]])} { db_qd_load_query_file $file }