Ticket #8641: trac_8641-sage-test.patch

File trac_8641-sage-test.patch, 1.8 KB (added by John Palmieri, 13 years ago)

scripts repo

  • sage-test

    # HG changeset patch
    # User J. H. Palmieri <palmieri@math.washington.edu>
    # Date 1271198018 25200
    # Node ID ccbbf839e9e732f832ea8967ce8e7cc1086288d1
    # Parent  b188e5632b929c182b0ea182ba6ef99292996a4a
    trac 8641: return nonzero code if tests fail
    
    diff -r b188e5632b92 -r ccbbf839e9e7 sage-test
    a b  
    7676failed = []
    7777
    7878def test(F, cmd):
     79    from subprocess import check_call
    7980    t = time.time()
    8081    if skip(F):
    8182        return 0
    8283    s = os.path.join(SAGE_ROOT, 'local', 'bin', 'sage-%s' % cmd) + ' "%s"' % F
    83     err = os.system(s)
     84    err = check_call(s, shell=True)
    8485    # On unix systems, the return value of os.system has the process return
    8586    # value in the second byte.
    8687    err = err // 256
     
    121122
    122123    base, ext = os.path.splitext(F)
    123124    if ext in ['.py', '.spyx', '.pyx', '.tex', '.pxi', '.sage', '.rst']:
    124         test(F, 'doctest ' + opts + extra_opts)
     125        err = test(F, 'doctest ' + opts + extra_opts)
    125126    elif os.path.isdir(F) and not (F[:1] == '.') \
    126127            and not '#' in F and not os.sep + 'notes' in F:
    127128        ld = os.listdir(F)
     129        err = 0
    128130        if not ('__nodoctest__' in ld):
    129131            for L in ld:
    130                 k = test_file(os.path.join(F, L))
    131     return 0
     132                err = err | test_file(os.path.join(F, L))
     133    else:
     134        err = 0
     135    return err
    132136
    133137files = argv[1:]
    134138
     
    170174       
    171175for F in files:
    172176    try:
    173         test_file(F)
     177        err = test_file(F)
    174178    except KeyboardInterrupt:
    175179        print "Aborting further tests."
     180        err = 2
    176181        break
    177182   
    178183print " "
     
    185190    print "\n\t" + "\n\t".join(failed)
    186191
    187192print "Total time for all tests: %.1f seconds"%(time.time() - t0)
     193sys.exit(err)