Ticket #9828: trac_9828-scripts_hudson.patch

File trac_9828-scripts_hudson.patch, 3.7 KB (added by mpatel, 12 years ago)

Ticket number in scripts repo patch. Apply only this patch to the scripts repo.

  • sage-ptest

    # HG changeset patch
    # User Robert Bradshaw <robertwb@math.washington.edu>
    # Date 1284706885 25200
    # Node ID deed6657e1a06732b96bbcc577faafe560dfe46b
    # Parent  a952de2e74934b9b4efa198a265a82a80b7b16c0
    #9828: XML test results for hudson
    
    diff -r a952de2e7493 -r deed6657e1a0 sage-ptest
    a b  
    1616                                          'lib', 'python', 'site-packages'))
    1717BUILD_DIR = os.path.realpath(os.path.join(SAGE_ROOT, 'devel', 'sage', 'build'))
    1818
     19try:
     20    XML_RESULTS = os.environ['XML_RESULTS']
     21except KeyError:
     22    XML_RESULTS = None
     23
    1924numiteration = int(os.environ.get('SAGE_TEST_ITER', 1))
    2025numglobaliteration = int(os.environ.get('SAGE_TEST_GLOBAL_ITER', 1))
    2126print 'Global iterations: ' + str(numglobaliteration)
     
    161166            ol=ol[0:len(ol)-1]
    162167        print ol
    163168    time_dict[abs_sage_path(F)] = finished_time
     169    if XML_RESULTS:
     170        t = finished_time
     171        failures = int(ret == 128)
     172        errors = int(ret and not failures)
     173        path = F.split(os.path.sep)
     174        while 'sage' in path:
     175            path = path[path.index('sage')+1:]
     176        path[-1] = os.path.splitext(path[-1])[0]
     177        module = '.'.join(path)
     178        if (failures or errors) and '#' in failed[-1]:
     179            type = "error" if errors else "failure"
     180            cause = failed[-1].split('#')[-1].strip()
     181            failure_item = "<%s type='%s'>%s</%s>" % (type, cause, cause, type)
     182        else:
     183            failure_item = ""
     184        f = open(os.path.join(XML_RESULTS, module + '.xml'), 'w')
     185        f.write("""
     186            <?xml version="1.0" ?>
     187            <testsuite name="%(module)s" errors="%(errors)s" failures="%(failures)s" tests="1" time="%(t)s">
     188            <testcase classname="%(module)s" name="test">
     189            %(failure_item)s
     190            </testcase>
     191            </testsuite>
     192        """.strip() % locals())
     193        f.close()
    164194    print "\t [%.1f s]"%(finished_time)
    165195
    166196def infiles_cmp(a,b):
  • sage-test

    diff -r a952de2e7493 -r deed6657e1a0 sage-test
    a b  
    4545SAGE_SITE = os.path.realpath(os.path.join(os.environ['SAGE_LOCAL'],
    4646                                          'lib', 'python', 'site-packages'))
    4747
     48try:
     49    XML_RESULTS = os.environ['XML_RESULTS']
     50except KeyError:
     51    XML_RESULTS = None
     52
     53
    4854if 'SAGE_TESTDIR' not in os.environ:
    4955    os.environ['SAGE_TESTDIR'] = os.path.join(SAGE_ROOT, "tmp")
    5056TMP = os.path.join(os.environ['SAGE_TESTDIR'], "tmp")
     
    101107    elif err != 0:
    102108        failed.append(sage_test_command(F))
    103109    os.system("mv -f __test* %s 2>/dev/null"%(TMP))
    104     print "\t [%.1f s]"%(time.time() - t)
     110    t = time.time() - t
     111    print "\t [%.1f s]" % t
     112    if XML_RESULTS:
     113        failures = int(err == 128)
     114        errors = int(err and not failures)
     115        path = F.split(os.path.sep)
     116        while 'sage' in path:
     117            path = path[path.index('sage')+1:]
     118        path[-1] = os.path.splitext(path[-1])[0]
     119        module = '.'.join(path)
     120        if errors and '#' in failed[-1]:
     121            cause = failed[-1].split('#')[-1].strip()
     122            failure_item = "<error type='%s'>%s</error>" % (cause, cause)
     123        else:
     124            failure_item = ""
     125        f = open(os.path.join(XML_RESULTS, module + '.xml'), 'w')
     126        f.write("""
     127            <?xml version="1.0" ?>
     128            <testsuite name="%(module)s" errors="%(errors)s" failures="%(failures)s" tests="1" time="%(t)s">
     129            <testcase classname="%(module)s" name="test">
     130            %(failure_item)s
     131            </testcase>
     132            </testsuite>
     133        """.strip() % locals())
     134        f.close()
    105135    return err
    106136
    107137