runTestSuite.in 1.76 KB
#!${buildout:directory}/bin/${eggs:interpreter}
# BEWARE: This file is operated by slapgrid
# BEWARE: It will be overwritten automatically
"""
  Script to run Cython test suite using Nexedi's test node framework.
"""
import os, subprocess, sys, traceback
from time import gmtime, strftime
import datetime

def main():

  is_browser_running = False

  try:

    date = strftime("%Y/%m/%d %H:%M:%S", gmtime())

    ###########################
    # Run Cython's test suite #
    ###########################

    # We need to screw up the working directory because Cython's runtests script relies on it
    os.chdir("${cython_nogil:location}")
    path_var = os.pathsep.join([os.environ.get('PATH', os.defpath), '${python3.5:location}/bin/python3/bin/'])
    env = dict(os.environ, PATH=path_var)
    python_path = '${python3.5:location}/bin/python3'

    print("Setup is:")
    print("python_path=", python_path)
    print("test location: ${cython_nogil:location}/runtests.py")
    start_time = datetime.datetime.now()
    print("Starting at", start_time)
    result = subprocess.run([python_path + " runtests.py"],
          env=env,
          shell=True,
          )
    end_time = datetime.datetime.now()
    duration = (end_time - start_time).total_seconds()
    print("Ending at", end_time, " (duration: %s seconds)" % duration)
    return result.returncode

  except:
    # Catch any exception here, to warn user instead of being silent,
    # by generating fake error result
    print(traceback.format_exc())
    result = dict(status_code=-1,
                  command='python3 -c "import test"', # url
                  stderr=traceback.format_exc(),
                  stdout='')
    # XXX: inform test node master of error
    raise EnvironmentError(result)

if __name__ == "__main__":
    main()