#!/bin/env python '''Testlet to run the 'test_all.py' ANUGA script.''' import os import time import test_utils as util name = 'Running ANUGA test_all.py' def test(logfile): result = True (cluster, domain) = util.get_hostname() # get python to run python_env_var = os.getenv('PYTHON') # remember the directory we are in and go to ANUGA test directory home_directory = os.getcwd() pythonpath = os.getenv('PYTHONPATH') os.chdir(os.path.join(pythonpath, 'anuga')) # compile C code util.log_print_nl(logfile, '%s compile_all.py' % python_env_var) (_, fd) = os.popen4('%s compile_all.py' % python_env_var) compile_result = fd.read() status = fd.close() util.log_print(logfile, compile_result) # run test_all.py util.log_print_nl(logfile, '%s test_all.py' % python_env_var) (_, fd) = os.popen4('%s test_all.py' % python_env_var) test_result = fd.read() status = fd.close() util.log_print(logfile, test_result) # return to original directory os.chdir(home_directory) return result if __name__ == '__main__': import sys home_directory = os.getcwd() logfile = os.path.join(home_directory, 'test.log') if len(sys.argv) > 1: logfile = sys.argv[1] try: os.remove(logfile) except: pass if not test(logfile): sys.exit(10) sys.exit(0)