#!/bin/sh
# the next line restarts using tclsh \
    exec tclsh "$0" "$@"

# Rivet test suite, by David N. Welton <davidw@apache.org>

# See README file for more information.

package require tcltest

set auto_path [linsert $auto_path 0 [file join [pwd] rivet]]
set urlbase "http://localhost:8081/"

# Use this to start and stop the server:

set TestList {rivetlib.test shorthand.test headers.test \
              cookies.test get.test post.test tclfile.test \
              env.test hello.test include.test binary.test \
              parse.test upload.test makeurl.test commands.test}

# Test stanzas are created by giving the test a name and a
# description.  The code is then executed, and the results compared
# with the desired result, which is placed after the block of code.
# See man tcltest for more information.

set testgroup1 1
set testgroup2 1
set testgroup3 1

#lappend TestList failtest.test

# Run all tests against one server process.

if { $testgroup1 } {
    puts -nonewline "Running all tests against one server process."
    flush stdout
    apachetest::start {} {} {
        foreach Test $TestList {
            puts -nonewline "."
            flush stdout
            source $Test
        }
    }
    puts " done"
}

# Run each test in its own server.

if { $testgroup2 } {
    foreach Test $TestList {
        apachetest::start {} {} {
            puts "Running $Test"
            source $Test
        }
    }
}


# These tests start the server on their own, or don't need the server
# at all.

set group3 {
        failtest.test
        broken.test
        config.test
        parsepackage.test
        virtualhost.test
        inspect.test 
        bailout.test
        channel.test
    }

if { $testgroup3 } {
    foreach Test $group3 {
        puts "Running $Test"
        source $Test
    }
}

::tcltest::cleanupTests

