Ticket #8641: trac_8641.patch

File trac_8641.patch, 2.3 KB (added by Dan Drake, 13 years ago)

apply to scripts repo. Replaces previous.

  • sage-test

    # HG changeset patch
    # User J. H. Palmieri <palmieri@math.washington.edu>
    # Date 1271198018 25200
    # Node ID ed0ca1432324e93a956ca2875b37d9a14faf0b62
    # Parent  1d4a872f4c52a4e074f12fb3a20c49fa0a5c9e1c
    trac 8641: return nonzero code if tests fail
    
    diff --git a/sage-test b/sage-test
    a b  
    2323    """
    2424    Strip prefixes added on automounted filesystems in some cases,
    2525    which make the absolute path appear hidden.
    26    
     26
    2727    AUTHOR:
    2828        -- Kate Minola
    2929    """
     
    7676failed = []
    7777
    7878def test(F, cmd):
     79    from subprocess import call
    7980    t = time.time()
    8081    if skip(F):
    8182        return 0
    82     s = os.path.join(SAGE_ROOT, 'local', 'bin', 'sage-%s' % cmd) + ' "%s"' % F
    83     err = os.system(s)
    84     # On unix systems, the return value of os.system has the process return
    85     # value in the second byte.
    86     err = err // 256
     83    err = call([os.path.join(SAGE_ROOT, 'local', 'bin', 'sage-%s' % cmd), F])
    8784
    8885    # Check the process exit code that sage-doctest returns
    8986
     
    120117        extra_opts = ' -force_lib'
    121118
    122119    base, ext = os.path.splitext(F)
     120    err = 0
    123121    if ext in ['.py', '.spyx', '.pyx', '.tex', '.pxi', '.sage', '.rst']:
    124         test(F, 'doctest ' + opts + extra_opts)
     122        err = err | test(F, 'doctest' + opts + extra_opts)
    125123    elif os.path.isdir(F) and not (F[:1] == '.') \
    126124            and not '#' in F and not os.sep + 'notes' in F:
    127125        ld = os.listdir(F)
    128126        if not ('__nodoctest__' in ld):
    129127            for L in ld:
    130                 k = test_file(os.path.join(F, L))
    131     return 0
     128                err = err | test_file(os.path.join(F, L))
     129    else:
     130        err = 0
     131    return err
    132132
    133133files = argv[1:]
    134134
     
    163163    print "     -randorder     -- if given, randomize *order* of tests"
    164164    print "     -randorder=seed-- use seed to get same random order"
    165165    print "     -sagenb        -- test all sagenb files"
    166    
     166
    167167    sys.exit(1)
    168168
    169169files.sort()
    170        
     170
     171err = 0
    171172for F in files:
    172173    try:
    173         test_file(F)
     174        err = err | test_file(F)
    174175    except KeyboardInterrupt:
    175176        print "Aborting further tests."
     177        err = 2
    176178        break
    177    
     179
    178180print " "
    179181print "-"*int(70)
    180182
     
    185187    print "\n\t" + "\n\t".join(failed)
    186188
    187189print "Total time for all tests: %.1f seconds"%(time.time() - t0)
     190sys.exit(err)