proc testAndDiff { prefix args } {
    if { $::tcl_platform(platform) eq "windows" } {
        set tclsh "tclsh.exe"
    } else {
        set tclsh "tclsh"
    }

    puts "Running tests for $prefix ..."
    set catchVal [catch {eval exec $tclsh $prefix.tcl $args > testOut/$prefix.out} retVal]
    if { $catchVal } {
        puts "ERROR: Test $prefix failed"
    }
    set catchVal [catch {eval exec diff -w testRef/$prefix.out testOut/$prefix.out} retVal]
    if { $catchVal } {
        puts "ERROR: Diff $prefix failed"
        puts $retVal
    }
}

proc diffOnly { fileName } {
    puts "Diffing file $fileName ..."
    set catchVal [catch {eval exec diff -w testRef/$fileName testOut/$fileName} retVal]
    if { $catchVal } {
        puts "ERROR: Diff $prefix failed"
        puts $retVal
    }
}

file mkdir testOut

testAndDiff testOsgArgumentParser --asd --help-all cow.osg
testAndDiff testOsgArray
testAndDiff testOsgBVs
testAndDiff testOsgGeode
testAndDiff testOsgMatrix
testAndDiff testOsgMixinVector
testAndDiff testOsgNodeVisitor
diffOnly    testOsgNodeVisitor.osg
testAndDiff testOsgPlane
testAndDiff testOsgQuat
testAndDiff testOsgVec
testAndDiff testStdVec

exit 0
