##// END OF EJS Templates
tests: add support for emitting trace events to run-tests...
Augie Fackler -
r39289:c496e8c1 default
parent child Browse files
Show More
@@ -64,6 +64,7 b' import tempfile'
64 64 import threading
65 65 import time
66 66 import unittest
67 import uuid
67 68 import xml.dom.minidom as minidom
68 69
69 70 try:
@@ -1070,6 +1071,8 b' class Test(unittest.TestCase):'
1070 1071 env["HGENCODINGMODE"] = "strict"
1071 1072 env["HGHOSTNAME"] = "test-hostname"
1072 1073 env['HGIPV6'] = str(int(self._useipv6))
1074 if 'HGCATAPULTSERVERPIPE' not in env:
1075 env['HGCATAPULTSERVERPIPE'] = '/dev/null'
1073 1076
1074 1077 extraextensions = []
1075 1078 for opt in self._extraconfigopts:
@@ -1344,6 +1347,20 b' class TTest(Test):'
1344 1347 script.append(b'%s %d 0\n' % (salt, line))
1345 1348 else:
1346 1349 script.append(b'echo %s %d $?\n' % (salt, line))
1350 active = []
1351 session = str(uuid.uuid4())
1352 if PYTHON3:
1353 session = session.encode('ascii')
1354 def toggletrace(cmd):
1355 quoted = shellquote(cmd.strip()).replace(b'\\', b'\\\\')
1356 if active:
1357 script.append(
1358 b'echo END %s %s >> "$HGCATAPULTSERVERPIPE"\n' % (
1359 session, active[0]))
1360 script.append(
1361 b'echo START %s %s >> "$HGCATAPULTSERVERPIPE"\n' % (
1362 session, quoted))
1363 active[0:] = [quoted]
1347 1364
1348 1365 script = []
1349 1366
@@ -1371,6 +1388,29 b' class TTest(Test):'
1371 1388 script.append(b'alias hg="%s"\n' % self._hgcommand)
1372 1389 if os.getenv('MSYSTEM'):
1373 1390 script.append(b'alias pwd="pwd -W"\n')
1391
1392 if os.getenv('HGCATAPULTSERVERPIPE'):
1393 # Kludge: use a while loop to keep the pipe from getting
1394 # closed by our echo commands. The still-running file gets
1395 # reaped at the end of the script, which causes the while
1396 # loop to exit and closes the pipe. Sigh.
1397 script.append(
1398 b'rtendtracing() {\n'
1399 b' echo END %(session)s %(name)s >> $HGCATAPULTSERVERPIPE\n'
1400 b' rm -f "$TESTTMP/.still-running"\n'
1401 b'}\n'
1402 b'trap "rtendtracing" 0\n'
1403 b'touch "$TESTTMP/.still-running"\n'
1404 b'while [ -f "$TESTTMP/.still-running" ]; do sleep 1; done '
1405 b'> $HGCATAPULTSERVERPIPE &\n'
1406 b'HGCATAPULTSESSION=%(session)s ; export HGCATAPULTSESSION\n'
1407 b'echo START %(session)s %(name)s >> $HGCATAPULTSERVERPIPE\n'
1408 % {
1409 'name': self.name,
1410 'session': session,
1411 }
1412 )
1413
1374 1414 if self._case:
1375 1415 casestr = b'#'.join(self._case)
1376 1416 if isinstance(self._case, str):
@@ -1436,10 +1476,12 b' class TTest(Test):'
1436 1476 prepos = pos
1437 1477 pos = n
1438 1478 addsalt(n, False)
1439 cmd = l[4:].split()
1479 rawcmd = l[4:]
1480 cmd = rawcmd.split()
1481 toggletrace(rawcmd)
1440 1482 if len(cmd) == 2 and cmd[0] == b'cd':
1441 1483 l = b' $ cd %s || exit 1\n' % cmd[1]
1442 script.append(l[4:])
1484 script.append(rawcmd)
1443 1485 elif l.startswith(b' > '): # continuations
1444 1486 after.setdefault(prepos, []).append(l)
1445 1487 script.append(l[4:])
@@ -1458,7 +1500,6 b' class TTest(Test):'
1458 1500 if skipping is not None:
1459 1501 after.setdefault(pos, []).append(' !!! missing #endif\n')
1460 1502 addsalt(n + 1, False)
1461
1462 1503 return salt, script, after, expected
1463 1504
1464 1505 def _processoutput(self, exitcode, output, salt, after, expected):
General Comments 0
You need to be logged in to leave comments. Login now