##// END OF EJS Templates
run-tests: support per-line conditional output in tests...
Matt Harbison -
r31829:4eec2f04 default
parent child Browse files
Show More
@@ -497,6 +497,12 b' def vlog(*msg):'
497 # sans \t, \n and \r
497 # sans \t, \n and \r
498 CDATA_EVIL = re.compile(br"[\000-\010\013\014\016-\037]")
498 CDATA_EVIL = re.compile(br"[\000-\010\013\014\016-\037]")
499
499
500 # Match feature conditionalized output lines in the form, capturing the feature
501 # list in group 2, and the preceeding line output in group 1:
502 #
503 # output..output (feature !)\n
504 optline = re.compile(b'(.+) \((.+?) !\)\n$')
505
500 def cdatasafe(data):
506 def cdatasafe(data):
501 """Make a string safe to include in a CDATA block.
507 """Make a string safe to include in a CDATA block.
502
508
@@ -1271,8 +1277,19 b' class TTest(Test):'
1271 if r:
1277 if r:
1272 els.pop(i)
1278 els.pop(i)
1273 break
1279 break
1274 if el and el.endswith(b" (?)\n"):
1280 if el:
1281 if el.endswith(b" (?)\n"):
1275 optional.append(i)
1282 optional.append(i)
1283 else:
1284 m = optline.match(el)
1285 if m:
1286 conditions = [c for c in m.group(2).split(' ')]
1287
1288 if self._hghave(conditions)[0]:
1289 lout = el
1290 else:
1291 optional.append(i)
1292
1276 i += 1
1293 i += 1
1277
1294
1278 if r:
1295 if r:
@@ -1298,7 +1315,9 b' class TTest(Test):'
1298 # clean up any optional leftovers
1315 # clean up any optional leftovers
1299 while expected.get(pos, None):
1316 while expected.get(pos, None):
1300 el = expected[pos].pop(0)
1317 el = expected[pos].pop(0)
1301 if el and not el.endswith(b" (?)\n"):
1318 if el:
1319 if (not optline.match(el)
1320 and not el.endswith(b" (?)\n")):
1302 break
1321 break
1303 postout.append(b' ' + el)
1322 postout.append(b' ' + el)
1304
1323
@@ -1371,6 +1390,12 b' class TTest(Test):'
1371 if el.endswith(b" (?)\n"):
1390 if el.endswith(b" (?)\n"):
1372 retry = "retry"
1391 retry = "retry"
1373 el = el[:-5] + b"\n"
1392 el = el[:-5] + b"\n"
1393 else:
1394 m = optline.match(el)
1395 if m:
1396 el = m.group(1) + b"\n"
1397 retry = "retry"
1398
1374 if el.endswith(b" (esc)\n"):
1399 if el.endswith(b" (esc)\n"):
1375 if PYTHON3:
1400 if PYTHON3:
1376 el = el[:-7].decode('unicode_escape') + '\n'
1401 el = el[:-7].decode('unicode_escape') + '\n'
@@ -39,6 +39,19 b' error paths'
39 $ rm hg
39 $ rm hg
40 #endif
40 #endif
41
41
42 Features for testing optional lines
43 ===================================
44
45 $ cat > hghaveaddon.py <<EOF
46 > import hghave
47 > @hghave.check("custom", "custom hghave feature")
48 > def has_custom():
49 > return True
50 > @hghave.check("missing", "missing hghave feature")
51 > def has_missing():
52 > return False
53 > EOF
54
42 an empty test
55 an empty test
43 =======================
56 =======================
44
57
@@ -67,6 +80,13 b' a succesful test'
67 > def (?)
80 > def (?)
68 > 456 (?)
81 > 456 (?)
69 > xyz
82 > xyz
83 > $ printf 'zyx\nwvu\ntsr\n'
84 > abc (?)
85 > zyx (custom !)
86 > wvu
87 > no_print (no-custom !)
88 > tsr (no-missing !)
89 > missing (missing !)
70 > EOF
90 > EOF
71
91
72 $ rt
92 $ rt
@@ -341,6 +361,12 b' Running In Debug Mode'
341 xyz
361 xyz
342 + echo *SALT* 15 0 (glob)
362 + echo *SALT* 15 0 (glob)
343 *SALT* 15 0 (glob)
363 *SALT* 15 0 (glob)
364 + printf *zyx\nwvu\ntsr\n* (glob)
365 zyx
366 wvu
367 tsr
368 + echo *SALT* 22 0 (glob)
369 *SALT* 22 0 (glob)
344 .
370 .
345 # Ran 2 tests, 0 skipped, 0 warned, 0 failed.
371 # Ran 2 tests, 0 skipped, 0 warned, 0 failed.
346
372
General Comments 0
You need to be logged in to leave comments. Login now