Bug 1523562 [wpt PR 14965] - Sync Mozilla CSS tests as of 2019-01-20, a=testonly
[gecko.git] / config / run-and-prefix.py
blob7869012fa1d7094322e14c5c2e5e17dc199f8993
1 #!/usr/bin/env python
2 # This Source Code Form is subject to the terms of the Mozilla Public
3 # License, v. 2.0. If a copy of the MPL was not distributed with this
4 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
6 # This script runs a process and prefixes its output with.
7 # Usage: run-and-prefix.py prefix command arg0 argv1...
9 from __future__ import absolute_import, print_function
11 import os
12 import subprocess
13 import sys
15 sys.stdout = os.fdopen(sys.stdout.fileno(), 'w', 0)
16 sys.stderr = os.fdopen(sys.stderr.fileno(), 'w', 0)
18 prefix = sys.argv[1]
19 args = sys.argv[2:]
21 p = subprocess.Popen(args, bufsize=0,
22 stdout=subprocess.PIPE,
23 stderr=subprocess.STDOUT,
24 stdin=sys.stdin.fileno(),
25 universal_newlines=True)
27 while True:
28 data = p.stdout.readline()
30 if data == b'':
31 break
33 print('%s> %s' % (prefix, data), end=b'')
35 sys.exit(p.wait())