From f9bf51480159172c3eada06c57e3f8f81ae9f7ff Mon Sep 17 00:00:00 2001 From: Bruno da Silva de Oliveira Date: Sun, 23 Mar 2003 18:23:09 +0000 Subject: [PATCH] - Added unittests for linux [SVN r18065] --- pyste/example/operators.h | 2 +- pyste/example/wrappertest_wrappers.h | 2 +- pyste/tests/test_all_linux.py | 53 ++++++++++++++++++++++++++++ 3 files changed, 55 insertions(+), 2 deletions(-) create mode 100644 pyste/tests/test_all_linux.py diff --git a/pyste/example/operators.h b/pyste/example/operators.h index 286401a0..65ea68e1 100644 --- a/pyste/example/operators.h +++ b/pyste/example/operators.h @@ -15,7 +15,7 @@ struct C } operator int() const { - return value; + return (int)value; } double operator()() diff --git a/pyste/example/wrappertest_wrappers.h b/pyste/example/wrappertest_wrappers.h index 7aec7309..46bf65ec 100644 --- a/pyste/example/wrappertest_wrappers.h +++ b/pyste/example/wrappertest_wrappers.h @@ -11,7 +11,7 @@ template list VectorToList(const std::vector & v) { list res; - std::vector::const_iterator it; + typename std::vector::const_iterator it; for(it = v.begin(); it != v.end(); ++it){ res.append(*it); } diff --git a/pyste/tests/test_all_linux.py b/pyste/tests/test_all_linux.py new file mode 100644 index 00000000..c203704c --- /dev/null +++ b/pyste/tests/test_all_linux.py @@ -0,0 +1,53 @@ +#!/usr/bin/python + +import os +import glob + +def build_pyste_files(): + # list all pyste files in the example directory + examples = glob.glob('../example/*.pyste') + # generate the cpp file for each example + for example in examples: + path, filename = os.path.split(example) + module = os.path.splitext(filename)[0] + os.system('python ../src/pyste.py -I%s --module=%s %s' % (path, module, example)) + + +def compile_pyste_files(): + # list all cpp files in this directory + cpps = glob.glob('*.cpp') + # compile each cpp into a shared library + for cpp in cpps: + print + print 'compiling', cpp + out = os.path.splitext(cpp)[0] + '.so' + cmdline = 'g++ -shared -o %s -I../example ' \ + '-I/usr/include/python2.2 -lboost_python %s' % (out, cpp) + os.system(cmdline) + + +def run_tests(): + if os.system('python runtests.py') != 0: + raise RuntimeError, 'tests failed' + + +def cleanup(): + extensions = '*.cpp *.so *.pyc' + files = [] + for ext in extensions.split(): + files += glob.glob(ext) + for file in files: + os.remove(file) + + +def main(): + build_pyste_files() + compile_pyste_files() + run_tests() + cleanup() + +if __name__ == '__main__': + try: + main() + except RuntimeError, e: + print e