2015-05-30 03:51:37 +02:00
|
|
|
from sys import stdout, exit
|
|
|
|
from os import listdir, remove
|
|
|
|
from os.path import splitext
|
|
|
|
import subprocess as sp
|
|
|
|
|
|
|
|
COMPILER = "c++"
|
2015-05-31 16:50:09 +02:00
|
|
|
# -Wno-missing-braces because clang false positive
|
|
|
|
CXXFLAGS="-std=c++11 -Wall -Wextra -Wno-missing-braces -I."
|
2015-05-30 03:51:37 +02:00
|
|
|
|
2015-05-31 17:03:43 +02:00
|
|
|
nsuccess = 0
|
|
|
|
nfailed = 0
|
|
|
|
|
2015-05-30 03:51:37 +02:00
|
|
|
for fname in listdir("./tests"):
|
2015-05-31 16:50:09 +02:00
|
|
|
(modname, modext) = splitext(fname)
|
|
|
|
|
|
|
|
if modext != ".cpp":
|
|
|
|
continue
|
|
|
|
|
|
|
|
pc = sp.Popen("%s tests/%s -o tests/%s %s"
|
|
|
|
% (COMPILER, fname, modname, CXXFLAGS), shell = True,
|
2015-05-30 03:51:37 +02:00
|
|
|
stdout = sp.PIPE, stderr = sp.STDOUT)
|
2015-05-31 16:50:09 +02:00
|
|
|
stdout.write(pc.communicate()[0])
|
|
|
|
|
|
|
|
if pc.returncode != 0:
|
|
|
|
print "%s...\t\033[91m\033[1m(compile error)\033[0m" % modname
|
2015-05-31 17:03:43 +02:00
|
|
|
nfailed += 1
|
|
|
|
continue
|
2015-05-31 16:50:09 +02:00
|
|
|
|
|
|
|
pc = sp.Popen("./tests/%s" % modname, shell = True,
|
|
|
|
stdout = sp.PIPE, stderr = sp.STDOUT)
|
|
|
|
stdout.write(pc.communicate()[0])
|
|
|
|
|
|
|
|
if pc.returncode != 0:
|
2015-05-30 03:51:37 +02:00
|
|
|
remove("./tests/%s" % modname)
|
2015-05-31 16:50:09 +02:00
|
|
|
print "%s...\t\033[91m\033[1m(runtime error)\033[0m" % modname
|
2015-05-31 17:03:43 +02:00
|
|
|
nfailed += 1
|
|
|
|
continue
|
2015-05-31 16:50:09 +02:00
|
|
|
|
|
|
|
remove("./tests/%s" % modname)
|
|
|
|
print "%s...\t\033[92m\033[1m(success)\033[0m" % modname
|
2015-05-31 17:03:43 +02:00
|
|
|
nsuccess += 1
|
2015-05-30 03:51:37 +02:00
|
|
|
|
2015-05-31 17:03:43 +02:00
|
|
|
print "\n\033[94m\033[1mtesting done:\033[0m"
|
|
|
|
print "\033[92mSUCCESS\033[0m: %d" % nsuccess
|
|
|
|
print "\033[91mFAILURE\033[0m: %d" % nfailed
|