Blame view

software/cython_test/runTestSuite.in 1.76 KB
Boxiang Sun committed
1
#!${buildout:directory}/bin/${eggs:interpreter}
Boxiang Sun committed
2 3 4 5 6
# 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.
"""
gsamain committed
7
import os, subprocess, sys, traceback
Boxiang Sun committed
8
from time import gmtime, strftime
Boxiang Sun committed
9
import datetime
Boxiang Sun committed
10 11

def main():
Boxiang Sun committed
12 13 14

  is_browser_running = False

gsamain committed
15
  try:
Boxiang Sun committed
16 17 18

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

gsamain committed
19 20 21
    ###########################
    # Run Cython's test suite #
    ###########################
Boxiang Sun committed
22

gsamain committed
23 24
    # We need to screw up the working directory because Cython's runtests script relies on it
    os.chdir("${cython_nogil:location}")
Boxiang Sun committed
25 26
    path_var = os.pathsep.join([os.environ.get('PATH', os.defpath), '${python3.5:location}/bin/python3/bin/'])
    env = dict(os.environ, PATH=path_var)
gsamain committed
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
    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
Boxiang Sun committed
42 43 44 45

  except:
    # Catch any exception here, to warn user instead of being silent,
    # by generating fake error result
gsamain committed
46
    print(traceback.format_exc())
Boxiang Sun committed
47 48 49 50 51 52
    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)
Boxiang Sun committed
53 54

if __name__ == "__main__":
gsamain committed
55
    main()