tests/run-tests.py
changeset 40489 a9e00c48c5ef
parent 40488 d95358143ce6
child 40490 889424be7ad2
equal deleted inserted replaced
40488:d95358143ce6 40489:a9e00c48c5ef
  1376         def addsalt(line, inpython):
  1376         def addsalt(line, inpython):
  1377             if inpython:
  1377             if inpython:
  1378                 script.append(b'%s %d 0\n' % (salt, line))
  1378                 script.append(b'%s %d 0\n' % (salt, line))
  1379             else:
  1379             else:
  1380                 script.append(b'echo %s %d $?\n' % (salt, line))
  1380                 script.append(b'echo %s %d $?\n' % (salt, line))
  1381         active = []
  1381         activetrace = []
  1382         session = str(uuid.uuid4())
  1382         session = str(uuid.uuid4())
  1383         if PYTHON3:
  1383         if PYTHON3:
  1384             session = session.encode('ascii')
  1384             session = session.encode('ascii')
  1385         hgcatapult = os.getenv('HGCATAPULTSERVERPIPE')
  1385         hgcatapult = os.getenv('HGCATAPULTSERVERPIPE')
  1386         def toggletrace(cmd=None):
  1386         def toggletrace(cmd=None):
  1387             if not hgcatapult or hgcatapult == os.devnull:
  1387             if not hgcatapult or hgcatapult == os.devnull:
  1388                 return
  1388                 return
  1389 
  1389 
  1390             if active:
  1390             if activetrace:
  1391                 script.append(
  1391                 script.append(
  1392                     b'echo END %s %s >> "$HGCATAPULTSERVERPIPE"\n' % (
  1392                     b'echo END %s %s >> "$HGCATAPULTSERVERPIPE"\n' % (
  1393                         session, active[0]))
  1393                         session, activetrace[0]))
  1394             if cmd is None:
  1394             if cmd is None:
  1395                 return
  1395                 return
  1396 
  1396 
  1397             if isinstance(cmd, str):
  1397             if isinstance(cmd, str):
  1398                 quoted = shellquote(cmd.strip())
  1398                 quoted = shellquote(cmd.strip())
  1400                 quoted = shellquote(cmd.strip().decode('utf8')).encode('utf8')
  1400                 quoted = shellquote(cmd.strip().decode('utf8')).encode('utf8')
  1401             quoted = quoted.replace(b'\\', b'\\\\')
  1401             quoted = quoted.replace(b'\\', b'\\\\')
  1402             script.append(
  1402             script.append(
  1403                 b'echo START %s %s >> "$HGCATAPULTSERVERPIPE"\n' % (
  1403                 b'echo START %s %s >> "$HGCATAPULTSERVERPIPE"\n' % (
  1404                     session, quoted))
  1404                     session, quoted))
  1405             active[0:] = [quoted]
  1405             activetrace[0:] = [quoted]
  1406 
  1406 
  1407         script = []
  1407         script = []
  1408 
  1408 
  1409         # After we run the shell script, we re-unify the script output
  1409         # After we run the shell script, we re-unify the script output
  1410         # with non-active parts of the source, with synchronization by our
  1410         # with non-active parts of the source, with synchronization by our
  1541             script.append(b'EOF\n')
  1541             script.append(b'EOF\n')
  1542         if skipping is not None:
  1542         if skipping is not None:
  1543             after.setdefault(pos, []).append('  !!! missing #endif\n')
  1543             after.setdefault(pos, []).append('  !!! missing #endif\n')
  1544         addsalt(n + 1, False)
  1544         addsalt(n + 1, False)
  1545         # Need to end any current per-command trace
  1545         # Need to end any current per-command trace
  1546         if active:
  1546         if activetrace:
  1547             toggletrace()
  1547             toggletrace()
  1548         return salt, script, after, expected
  1548         return salt, script, after, expected
  1549 
  1549 
  1550     def _processoutput(self, exitcode, output, salt, after, expected):
  1550     def _processoutput(self, exitcode, output, salt, after, expected):
  1551         # Merge the script output back into a unified test.
  1551         # Merge the script output back into a unified test.