set tests [lsort [glob -nocomplain *.test]]

source defs

set auto_index(x) ""
set auto_oldpath ""

namespace eval all {
    proc added {old now msg} {
	set new {}
	foreach var $now {
	    if {[lsearch -exact $old $var] < 0} {
		lappend new $var
	    }
	}
	if {[llength $new]} {
	    puts "---leaking $msg: $new"
	}
	return $new
    }
}

foreach all::test $tests {
    puts stdout $all::test
    flush stdout

    set all::vars [info vars]
    set all::procs [info procs]

    if {[catch {source $all::test} all::msg]} {
	puts $all::msg
    }

    set errorInfo ""
    set errorCode ""

    set all::vars [all::added $all::vars [info vars] variables]
    if {[llength $all::vars] > 0} {
	eval unset $all::vars
    }
    set all::procs [all::added $all::procs [info proc] procedures]
    foreach all::proc $all::procs {
	rename $all::proc {}
    }
}
