From 4dc42a1270966a35c4bfa43a6b097c83e1a2ea81 Mon Sep 17 00:00:00 2001 From: q66 Date: Sat, 30 May 2015 02:51:37 +0100 Subject: [PATCH] initial testing stuff --- run_tests.py | 32 ++++++++++++++++++++++++++++++++ tests/array.cpp | 5 +++++ tests/vector.cpp | 5 +++++ 3 files changed, 42 insertions(+) create mode 100644 run_tests.py create mode 100644 tests/array.cpp create mode 100644 tests/vector.cpp diff --git a/run_tests.py b/run_tests.py new file mode 100644 index 0000000..81c0805 --- /dev/null +++ b/run_tests.py @@ -0,0 +1,32 @@ +from sys import stdout, exit +from os import listdir, remove +from os.path import splitext +import subprocess as sp + +COMPILER = "c++" +CXXFLAGS="-std=c++11 -Wall -Wextra -I." + +for fname in listdir("./tests"): + if fname.endswith(".cpp"): + modname = splitext(fname)[0] + stdout.write("%s...\t" % modname) + pc = sp.Popen("%s tests/%s -o tests/%s %s" + % (COMPILER, fname, modname, CXXFLAGS), shell = True, + stdout = sp.PIPE, stderr = sp.STDOUT) + pcdata = pc.communicate()[0] + if pc.returncode != 0: + print "\033[91m(compile error)\033[0m" + stdout.write(pcdata) + exit(1) + pc = sp.Popen("./tests/%s" % modname, shell = True, + stdout = sp.PIPE, stderr = sp.STDOUT) + pcdata = pc.communicate()[0] + if pc.returncode != 0: + remove("./tests/%s" % modname) + print "\033[91m(runtime error)\033[0m" + stdout.write(pcdata) + exit(1) + remove("./tests/%s" % modname) + print "\033[92m(success)\033[0m" + +print "testing successful" \ No newline at end of file diff --git a/tests/array.cpp b/tests/array.cpp new file mode 100644 index 0000000..ee74bcb --- /dev/null +++ b/tests/array.cpp @@ -0,0 +1,5 @@ +#include "octa/array.h" + +int main() { + return 0; +} \ No newline at end of file diff --git a/tests/vector.cpp b/tests/vector.cpp new file mode 100644 index 0000000..001e2d1 --- /dev/null +++ b/tests/vector.cpp @@ -0,0 +1,5 @@ +#include "octa/vector.h" + +int main() { + return 0; +} \ No newline at end of file