Skip to content

Instantly share code, notes, and snippets.

@BitPuffin
Created March 27, 2015 15:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BitPuffin/35988c7cc8da7336c7df to your computer and use it in GitHub Desktop.
Save BitPuffin/35988c7cc8da7336c7df to your computer and use it in GitHub Desktop.
#
# A very simplistic test suite
#
# Author: Isak Andersson
#
import Boo.Lang.Extensions.VarMacro
import Boo.Lang.Interpreter
import System.IO
struct Test:
name as string
success as bool
status as string
exception as System.Exception
var subdirs = Directory.GetDirectories(".")
var testcount = len(subdirs)
var tests = array(Test, testcount)
var successcount = 0L
var testrootpath = Directory.GetCurrentDirectory()
var interpreter = InteractiveInterpreter()
for idx, dir in enumerate(subdirs):
var testpath = Path.Combine(dir, "Test.boo")
tests[idx].name = Path.GetFileName(dir)
unless File.Exists(testpath):
tests[idx].status = "Missing Test.boo file in test directory"
continue
var testsrc = File.ReadAllText(testpath)
Directory.SetCurrentDirectory(dir)
try:
interpreter.Eval(testsrc)
tests[idx].success = true
successcount += 1
except e:
var base = e.GetBaseException()
tests[idx].status = base.Message
tests[idx].exception = base
interpreter.Reset()
Directory.SetCurrentDirectory(testrootpath)
print "----- Test Results -----"
print "Test count: $testcount"
print "Success count: $successcount"
print "Percentage pass: $(successcount*100.0/testcount)%"
if successcount != testcount:
print ""
print "Failed tests:\n"
for test in tests:
unless test.success:
print " Name: $(test.name)"
print " Status: $(test.status)"
print " Exception: $(test.exception)" if "-v" in argv and test.exception
print ""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment