Difference between revisions of "Test"
From OdaWiki
Line 3: | Line 3: | ||
==Writing tests== | ==Writing tests== | ||
Tests are written in TCL, as this is a portable scripting language. It is best to start by copying an existing test. Tests should output lines containing the words "PASS" or "FAIL". | Tests are written in TCL, as this is a portable scripting language. It is best to start by copying an existing test. Tests should output lines containing the words "PASS" or "FAIL". | ||
+ | |||
+ | |||
+ | ==Example== | ||
+ | |||
+ | <pre> | ||
+ | #!/bin/bash | ||
+ | # Do not change these first three lines \ | ||
+ | exec tclsh "$0" "$@" | ||
+ | |||
+ | # Create a list of demos to test | ||
+ | lappend demos "DOOM2.WAD DEMO1 {15eb4720 3ccc7a1 3fc7e27 800000}" | ||
+ | lappend demos "DOOM2.WAD DEMO2 {cea29400 289b9c2 fece4356 600000}" | ||
+ | lappend demos "DOOM2.WAD DEMO3 {dca00040 fd6a4b9c ff7bee0a ff000000}" | ||
+ | |||
+ | foreach demo $demos { | ||
+ | # Run this demo | ||
+ | set stdout [exec ./odamex -nosound -novideo \ | ||
+ | -iwad [lindex $demo 1] \ | ||
+ | +demotest [lindex $demo 1]] | ||
+ | |||
+ | # Take the last line of output | ||
+ | set result [lindex [split $stdout "\n"] end] | ||
+ | |||
+ | # Take the last item in this demo line (see top of test) | ||
+ | set expected [lindex $demo 2] | ||
+ | |||
+ | # Compare them | ||
+ | if { $result != $expected} { | ||
+ | puts "FAIL $demo | $result" | ||
+ | } else { | ||
+ | puts "PASS $demo | $result" | ||
+ | } | ||
+ | } | ||
+ | </pre> |
Revision as of 14:24, 5 May 2008
Since 0.3, Odamex has a lot of working features. The doom engine is sensitive to change, so to preserve functionality we have a set of tests to run on every submission. They are located in the tests directory
Writing tests
Tests are written in TCL, as this is a portable scripting language. It is best to start by copying an existing test. Tests should output lines containing the words "PASS" or "FAIL".
Example
#!/bin/bash # Do not change these first three lines \ exec tclsh "$0" "$@" # Create a list of demos to test lappend demos "DOOM2.WAD DEMO1 {15eb4720 3ccc7a1 3fc7e27 800000}" lappend demos "DOOM2.WAD DEMO2 {cea29400 289b9c2 fece4356 600000}" lappend demos "DOOM2.WAD DEMO3 {dca00040 fd6a4b9c ff7bee0a ff000000}" foreach demo $demos { # Run this demo set stdout [exec ./odamex -nosound -novideo \ -iwad [lindex $demo 1] \ +demotest [lindex $demo 1]] # Take the last line of output set result [lindex [split $stdout "\n"] end] # Take the last item in this demo line (see top of test) set expected [lindex $demo 2] # Compare them if { $result != $expected} { puts "FAIL $demo | $result" } else { puts "PASS $demo | $result" } }