зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1696531 - [xpcshell] Fix some py3 related issues in toolkit/modules/subprocess/test/xpcshell/test_subprocess.js, r=bhearsum
Depends on D110546 Differential Revision: https://phabricator.services.mozilla.com/D109730
This commit is contained in:
Родитель
1cfd38fd15
Коммит
5bd8e288d1
|
@ -1,5 +1,4 @@
|
|||
#!/usr/bin/env python2
|
||||
from __future__ import print_function
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import os
|
||||
import signal
|
||||
|
@ -7,15 +6,18 @@ import struct
|
|||
import sys
|
||||
|
||||
|
||||
def output(line):
|
||||
sys.stdout.write(struct.pack("@I", len(line)))
|
||||
sys.stdout.write(line)
|
||||
sys.stdout.flush()
|
||||
def output(line, stream=sys.stdout, print_only=False):
|
||||
if isinstance(line, str):
|
||||
line = line.encode("utf-8", "surrogateescape")
|
||||
if not print_only:
|
||||
stream.buffer.write(struct.pack("@I", len(line)))
|
||||
stream.buffer.write(line)
|
||||
stream.flush()
|
||||
|
||||
|
||||
def echo_loop():
|
||||
while True:
|
||||
line = sys.stdin.readline()
|
||||
line = sys.stdin.buffer.readline()
|
||||
if not line:
|
||||
break
|
||||
|
||||
|
@ -53,5 +55,5 @@ elif cmd == "ignore_sigterm":
|
|||
|
||||
time.sleep(3600)
|
||||
elif cmd == "print":
|
||||
sys.stdout.write(sys.argv[2])
|
||||
sys.stderr.write(sys.argv[3])
|
||||
output(sys.argv[2], stream=sys.stdout, print_only=True)
|
||||
output(sys.argv[3], stream=sys.stderr, print_only=True)
|
||||
|
|
|
@ -693,6 +693,7 @@ add_task(async function test_subprocess_environment() {
|
|||
Object.assign(environment, {
|
||||
PATH: env.get("PATH"),
|
||||
PATHEXT: env.get("PATHEXT"),
|
||||
SYSTEMROOT: env.get("SYSTEMROOT"),
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче