# 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
|
|
16 | 16 | 'lib', 'python', 'site-packages')) |
17 | 17 | BUILD_DIR = os.path.realpath(os.path.join(SAGE_ROOT, 'devel', 'sage', 'build')) |
18 | 18 | |
| 19 | try: |
| 20 | XML_RESULTS = os.environ['XML_RESULTS'] |
| 21 | except KeyError: |
| 22 | XML_RESULTS = None |
| 23 | |
19 | 24 | numiteration = int(os.environ.get('SAGE_TEST_ITER', 1)) |
20 | 25 | numglobaliteration = int(os.environ.get('SAGE_TEST_GLOBAL_ITER', 1)) |
21 | 26 | print 'Global iterations: ' + str(numglobaliteration) |
… |
… |
|
161 | 166 | ol=ol[0:len(ol)-1] |
162 | 167 | print ol |
163 | 168 | 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() |
164 | 194 | print "\t [%.1f s]"%(finished_time) |
165 | 195 | |
166 | 196 | def infiles_cmp(a,b): |
diff -r a952de2e7493 -r deed6657e1a0 sage-test
a
|
b
|
|
45 | 45 | SAGE_SITE = os.path.realpath(os.path.join(os.environ['SAGE_LOCAL'], |
46 | 46 | 'lib', 'python', 'site-packages')) |
47 | 47 | |
| 48 | try: |
| 49 | XML_RESULTS = os.environ['XML_RESULTS'] |
| 50 | except KeyError: |
| 51 | XML_RESULTS = None |
| 52 | |
| 53 | |
48 | 54 | if 'SAGE_TESTDIR' not in os.environ: |
49 | 55 | os.environ['SAGE_TESTDIR'] = os.path.join(SAGE_ROOT, "tmp") |
50 | 56 | TMP = os.path.join(os.environ['SAGE_TESTDIR'], "tmp") |
… |
… |
|
101 | 107 | elif err != 0: |
102 | 108 | failed.append(sage_test_command(F)) |
103 | 109 | 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() |
105 | 135 | return err |
106 | 136 | |
107 | 137 | |