#!/usr/local/bin/tclsh


##

proc do_test {{which all}} {
    puts "doing $which tests..."
    set testfile [file join tests ${which}.tcl]
    if [catch {uplevel \#0 "source $testfile"} res] {
	puts "Error: $res"
	return 1
    } elseif {"" != $res} { puts "sourced $libsetup: $res" }
}


##

proc do_setup {{which lib}} {
    puts "doing $which setup..."
    
    # fixme for which
    
    set libsetup [file join [file dirname [info script]] lib ic_xml_setup.tcl]
    if [catch {uplevel \#0 "source $libsetup"} res] {
	puts "Error: $res"
	return 1
    } elseif {"" != $res} { puts "sourced $libsetup: $res" }
    
    return 0
}

#
# --> main
#

set setup lib

foreach {n v} $argv {
    set [string range $n 1 end] $v
}

if [info exists setup] {
    do_setup $setup
}

if [info exists test] {
    if ![info exists setup] {
	do_setup
    }
    do_test $test
}
