forked from OctaForge/libostd
cleaner color handling
parent
6c3db69741
commit
0954b256ee
36
run_tests.py
36
run_tests.py
|
@ -3,6 +3,8 @@ from os import listdir, remove, name as osname
|
||||||
from os.path import splitext, join as joinp
|
from os.path import splitext, join as joinp
|
||||||
import subprocess as sp
|
import subprocess as sp
|
||||||
|
|
||||||
|
# configuration - you can modify this
|
||||||
|
|
||||||
COMPILER = "c++"
|
COMPILER = "c++"
|
||||||
CXXFLAGS = [
|
CXXFLAGS = [
|
||||||
"-std=c++11",
|
"-std=c++11",
|
||||||
|
@ -12,22 +14,29 @@ CXXFLAGS = [
|
||||||
]
|
]
|
||||||
COLORS = (osname != "nt")
|
COLORS = (osname != "nt")
|
||||||
|
|
||||||
|
# don't modify past these lines
|
||||||
|
|
||||||
nsuccess = 0
|
nsuccess = 0
|
||||||
nfailed = 0
|
nfailed = 0
|
||||||
|
|
||||||
|
if COLORS:
|
||||||
|
colors = {
|
||||||
|
"red": "\033[91m",
|
||||||
|
"green": "\033[92m",
|
||||||
|
"blue": "\033[94m",
|
||||||
|
"bold": "\033[1m",
|
||||||
|
"end": "\033[0m"
|
||||||
|
}
|
||||||
|
else:
|
||||||
|
colors = { "red": "", "green": "", "blue": "", "bold": "", "end": "" }
|
||||||
|
|
||||||
def print_result(modname, fmsg = None):
|
def print_result(modname, fmsg = None):
|
||||||
global nsuccess, nfailed
|
global nsuccess, nfailed
|
||||||
if fmsg:
|
if fmsg:
|
||||||
if COLORS:
|
print modname + ("...\t%(red)s%(bold)s(" + fmsg + ")%(end)s") % colors
|
||||||
print "%s...\t\033[91m\033[1m(%s)\033[0m" % (modname, fmsg)
|
|
||||||
else:
|
|
||||||
print "%s...\t(%s)" % (modname, fmsg)
|
|
||||||
nfailed += 1
|
nfailed += 1
|
||||||
else:
|
else:
|
||||||
if COLORS:
|
print modname + "...\t%(green)s%(bold)s(success)%(end)s" % colors
|
||||||
print "%s...\t\033[92m\033[1m(success)\033[0m" % modname
|
|
||||||
else:
|
|
||||||
print "%s...\t(success)" % modname
|
|
||||||
nsuccess += 1
|
nsuccess += 1
|
||||||
|
|
||||||
for fname in listdir("tests"):
|
for fname in listdir("tests"):
|
||||||
|
@ -58,11 +67,6 @@ for fname in listdir("tests"):
|
||||||
remove(exepath)
|
remove(exepath)
|
||||||
print_result(modname)
|
print_result(modname)
|
||||||
|
|
||||||
if COLORS:
|
print "\n%(blue)s%(bold)stesting done:%(end)s" % colors
|
||||||
print "\n\033[94m\033[1mtesting done:\033[0m"
|
print "%(green)sSUCCESS: " % colors + str(nsuccess) + colors["end"]
|
||||||
print "\033[92mSUCCESS\033[0m: \033[1m%d\033[0m" % nsuccess
|
print "%(red)sFAILURE: " % colors + str(nfailed) + colors["end"]
|
||||||
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