forked from OctaForge/libostd
no color test output on windows + other testrunner changes
parent
d10cdfebbb
commit
1019462d60
41
run_tests.py
41
run_tests.py
|
@ -1,6 +1,6 @@
|
||||||
from sys import stdout, exit
|
from sys import stdout, exit
|
||||||
from os import listdir, remove
|
from os import listdir, remove, name as osname
|
||||||
from os.path import splitext
|
from os.path import splitext, join as joinp
|
||||||
import subprocess as sp
|
import subprocess as sp
|
||||||
|
|
||||||
COMPILER = "c++"
|
COMPILER = "c++"
|
||||||
|
@ -10,38 +10,59 @@ CXXFLAGS = [
|
||||||
"-Wno-missing-braces", # clang false positive
|
"-Wno-missing-braces", # clang false positive
|
||||||
"-I."
|
"-I."
|
||||||
]
|
]
|
||||||
|
COLORS = (osname != "nt")
|
||||||
|
|
||||||
nsuccess = 0
|
nsuccess = 0
|
||||||
nfailed = 0
|
nfailed = 0
|
||||||
|
|
||||||
|
def print_result(modname, fmsg = None):
|
||||||
|
if fmsg:
|
||||||
|
if COLORS:
|
||||||
|
print "%s...\t\033[91m\033[1m(%s)\033[0m" % (modname, fmsg)
|
||||||
|
else:
|
||||||
|
print "%s...\t(%s)" % (modname, fmsg)
|
||||||
|
else:
|
||||||
|
if COLORS:
|
||||||
|
print "%s...\t\033[92m\033[1m(success)\033[0m" % modname
|
||||||
|
else:
|
||||||
|
print "%s...\t(success)" % modname
|
||||||
|
|
||||||
for fname in listdir("tests"):
|
for fname in listdir("tests"):
|
||||||
(modname, modext) = splitext(fname)
|
(modname, modext) = splitext(fname)
|
||||||
|
|
||||||
if modext != ".cpp":
|
if modext != ".cpp":
|
||||||
continue
|
continue
|
||||||
|
|
||||||
pc = sp.Popen([ COMPILER, "tests/%s" % fname, "-o", "tests/%s" % modname ]
|
srcpath = joinp("tests", fname)
|
||||||
+ CXXFLAGS, stdout = sp.PIPE, stderr = sp.STDOUT)
|
exepath = joinp("tests", modname)
|
||||||
|
|
||||||
|
pc = sp.Popen([ COMPILER, srcpath, "-o", exepath ] + CXXFLAGS,
|
||||||
|
stdout = sp.PIPE, stderr = sp.STDOUT)
|
||||||
stdout.write(pc.communicate()[0])
|
stdout.write(pc.communicate()[0])
|
||||||
|
|
||||||
if pc.returncode != 0:
|
if pc.returncode != 0:
|
||||||
print "%s...\t\033[91m\033[1m(compile error)\033[0m" % modname
|
print_result(modname, "compile error")
|
||||||
nfailed += 1
|
nfailed += 1
|
||||||
continue
|
continue
|
||||||
|
|
||||||
pc = sp.Popen("tests/%s" % modname, stdout = sp.PIPE, stderr = sp.STDOUT)
|
pc = sp.Popen(exepath, stdout = sp.PIPE, stderr = sp.STDOUT)
|
||||||
stdout.write(pc.communicate()[0])
|
stdout.write(pc.communicate()[0])
|
||||||
|
|
||||||
if pc.returncode != 0:
|
if pc.returncode != 0:
|
||||||
remove("tests/%s" % modname)
|
remove(exepath)
|
||||||
print "%s...\t\033[91m\033[1m(runtime error)\033[0m" % modname
|
print_result(modname, "runtime error")
|
||||||
nfailed += 1
|
nfailed += 1
|
||||||
continue
|
continue
|
||||||
|
|
||||||
remove("tests/%s" % modname)
|
remove(exepath)
|
||||||
print "%s...\t\033[92m\033[1m(success)\033[0m" % modname
|
print_result(modname)
|
||||||
nsuccess += 1
|
nsuccess += 1
|
||||||
|
|
||||||
|
if COLORS:
|
||||||
print "\n\033[94m\033[1mtesting done:\033[0m"
|
print "\n\033[94m\033[1mtesting done:\033[0m"
|
||||||
print "\033[92mSUCCESS\033[0m: \033[1m%d\033[0m" % nsuccess
|
print "\033[92mSUCCESS\033[0m: \033[1m%d\033[0m" % nsuccess
|
||||||
print "\033[91mFAILURE\033[0m: \033[1m%d\033[0m" % nfailed
|
print "\033[91mFAILURE\033[0m: \033[1m%d\033[0m" % nfailed
|
||||||
|
else:
|
||||||
|
print "\ntesting done:"
|
||||||
|
print "SUCCESS: %d" % nsuccess
|
||||||
|
print "FAILURE: %d" % nfailed
|
Loading…
Reference in New Issue