/Users/maurits/Documents/studie/afstuderen/biosphere/build/runtestsuite.py

Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 #
00003 # Run the testsuite located in the tests directory.
00004 # This script searches the given directory for executables
00005 # starting with test_ and executes those. It stops when
00006 # one of these executables returns with a nonzero exit code.
00007 #
00008 #
00009 # Copyright (c) 2006 Maurits Hartman
00010 #
00011 # Permission is hereby granted, free of charge, to any person
00012 # obtaining a copy of this software and associated documentation
00013 # files (the "Software"), to deal in the Software without
00014 # restriction, including without limitation the rights to use,
00015 # copy, modify, merge, publish, distribute, sublicense, and/or sell
00016 # copies of the Software, and to permit persons to whom the
00017 # Software is furnished to do so, subject to the following
00018 # conditions:
00019 # 
00020 # The above copyright notice and this permission notice shall be
00021 # included in all copies or substantial portions of the Software.
00022 # 
00023 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
00024 # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
00025 # OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
00026 # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
00027 # HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
00028 # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
00029 # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
00030 # OTHER DEALINGS IN THE SOFTWARE.
00031 #
00032 
00033 import os, sys
00034 from stat import *
00035 
00036 # Determine the directory to process:
00037 if (len(sys.argv) < 2):
00038     sys.stderr.write("Expecting a path argument for the testsuite directory\n")
00039     sys.exit(1)
00040 else:
00041     sys.stdout.write("\n***************************************************\n")
00042     sys.stdout.write("*                                                 *\n")
00043     sys.stdout.write("*          Starting Bio-SPHERE testsuite          *\n")
00044     sys.stdout.write("*                                                 *\n")
00045     sys.stdout.write("***************************************************\n")
00046     testdir = sys.argv[1]
00047 
00048 # Save the current working directory and change to the test dir:
00049 old_cwd = os.getcwd()
00050 os.chdir(testdir)
00051 
00052 # Process all tests:
00053 error_count = 0
00054 for file in os.listdir("."):
00055     st = os.stat(file)
00056     prefix = file.split("_")[0]
00057     if (prefix == "test" and st[0] & (S_IXUSR | S_IXGRP | S_IXOTH) != 0 and not S_ISDIR(st[0])):
00058         num_dots = 39 - len(file)
00059         sys.stdout.write("executing " + file + "." * num_dots)
00060         rv = os.spawnl(os.P_WAIT, file, file)
00061         if rv == 0:
00062             sys.stdout.write("OK\n")
00063         else:
00064             sys.stdout.write("error code %d\n" % rv)
00065             error_count += 1
00066 
00067 # Go back to the original directory:
00068 os.chdir(old_cwd)
00069 if error_count > 0:
00070     sys.stdout.write("\nThere were some errors.\nPlease take a look at the individual testcases that went wrong\n")
00071     sys.exit(1)
00072 else:
00073     sys.stdout.write("\nAll tests passed successfully!\n")
00074     sys.exit()

Generated on Tue Jul 17 09:50:52 2007 for Bio-SPHERE by  doxygen 1.5.1