aa_check_leftovers (public)

 aa_check_leftovers [ -silent ] [ msg ]

Defined in packages/acs-automated-testing/tcl/aa-test-procs.tcl

# # Perform cleanup tests to check for object/command leaks in # either the called functions or in the test itself. #

Switches:
-silent (optional, boolean)
Parameters:
msg (optional, defaults to "final")

Partial Call Graph (max 5 caller/called nodes):
%3 test_webtest_example webtest_example (test acs-automated-testing) aa_check_leftovers aa_check_leftovers test_webtest_example->aa_check_leftovers aa_equals aa_equals (public) aa_check_leftovers->aa_equals aa_log aa_log (public) aa_check_leftovers->aa_log aa_used_application_memory aa_used_application_memory (private) aa_check_leftovers->aa_used_application_memory acs::icanuse acs::icanuse (public) aa_check_leftovers->acs::icanuse nsf::dispatch nsf::dispatch aa_check_leftovers->nsf::dispatch aa_run_testcase aa_run_testcase (private) aa_run_testcase->aa_check_leftovers

Testcases:
webtest_example
Source code:
    if {[namespace which ::xo::at_cleanup] ne ""} {
        ::xo::at_cleanup
    }

    set domNodes   [list {*}[info commands domNode0*] {*}[info commands domDoc0x*]]
    set xotclObjs  [::xotcl::Object info instances -closure]
    set nxObjs     [::nx::Object info instances  -closure]
    set tmpObjs    [info commands ::nsf::__#*]
    set nsSets     [expr {[acs::icanuse "ns_set stats"] ? [list [ns_set stats]] : [llength [ns_set list]]}]

    dict set stats tdom    [llength $domNodes]
    dict set stats nssets  [llength $nsSets]
    dict set stats xotcl   [llength $xotclObjs]
    dict set stats nx      [llength $nxObjs]
    dict set stats tmpobjs [llength $tmpObjs]

    dict with stats {
        aa_equals "$msg leftover temp objects"     $tmpobjs 0
        if {$tmpobjs > 0} {
            foreach obj $tmpObjs {
                set isXotcl [::nsf::dispatch $obj ::nsf::methods::object::info::hastype ::xotcl::Object]
                set isNx    [::nsf::dispatch $obj ::nsf::methods::object::info::hastype ::nx::Object]
                aa_log obj $obj (isXotcl $isXotcl isNx $isNx)
                aa_log <pre>[$obj serialize]</pre>
                $obj destroy
            }
        }
        aa_equals "$msg leftover tdom cmds"        $tdom 0
        foreach n $domNodes {
            if {[string match domDoc0x* $n]} {
                aa_log node:$n\n<pre>[ns_quotehtml [$n asXML -indent 4]]</pre>
                $n delete
            }
        }
        if {$silent_p} {
            aa_log    "$msg XOTcl objects: $xotcl nx objects: $nx nssets: $nssets"
            set mem_info [aa_used_application_memory]
            if {$mem_info ne ""} {
                dict with mem_info {
                    aa_log "current memory: [format %.6f [expr {$current/1000000.0}]] MB "  "difference to begin of this case: [format %.3f [expr {$diff/1000.0}]] KB"
                }
            }
        }
    }
XQL Not present:
Generic, PostgreSQL, Oracle
[ hide source ] | [ make this the default ]
Show another procedure: