gecko-dev/toolkit/modules/subprocess/test/xpcshell/data_test_script.py
Sandor Molnar 6ceb5f92a7 Backed out 10 changesets (bug 1696531) for causing mochitest failures in TypeError: cannot use a string pattern on a bytes-like object. CLOSED TREE
Backed out changeset abc85e3c21b0 (bug 1696531)
Backed out changeset 82445e26060e (bug 1696531)
Backed out changeset 97771570e425 (bug 1696531)
Backed out changeset c3f229148f6c (bug 1696531)
Backed out changeset 9557ff3065bc (bug 1696531)
Backed out changeset 98d17a5f6886 (bug 1696531)
Backed out changeset b0eee4af2caf (bug 1696531)
Backed out changeset 544be24f74be (bug 1696531)
Backed out changeset ddcc795bf838 (bug 1696531)
Backed out changeset e5e76f56ceb9 (bug 1696531)
2021-05-06 23:57:56 +03:00

57 lines
1.1 KiB
Python

#!/usr/bin/env python2
from __future__ import print_function
import os
import signal
import struct
import sys
def output(line):
sys.stdout.write(struct.pack("@I", len(line)))
sys.stdout.write(line)
sys.stdout.flush()
def echo_loop():
while True:
line = sys.stdin.readline()
if not line:
break
output(line)
if sys.platform == "win32":
import msvcrt
msvcrt.setmode(sys.stderr.fileno(), os.O_BINARY)
cmd = sys.argv[1]
if cmd == "echo":
echo_loop()
elif cmd == "exit":
sys.exit(int(sys.argv[2]))
elif cmd == "env":
for var in sys.argv[2:]:
output(os.environ.get(var, "!"))
elif cmd == "pwd":
output(os.path.abspath(os.curdir))
elif cmd == "print_args":
for arg in sys.argv[2:]:
output(arg)
elif cmd == "ignore_sigterm":
signal.signal(signal.SIGTERM, signal.SIG_IGN)
output("Ready")
while True:
try:
signal.pause()
except AttributeError:
import time
time.sleep(3600)
elif cmd == "print":
sys.stdout.write(sys.argv[2])
sys.stderr.write(sys.argv[3])