MCPcopy Create free account
hub / github.com/emscripten-core/emscripten / run_process

Method run_process

test/common.py:1253–1288  ·  view source on GitHub ↗
(self, cmd, check=True, **kwargs)

Source from the content-addressed store, hash-verified

1251 utils.delete_contents(shared.EMSCRIPTEN_TEMP_DIR)
1252
1253 def run_process(self, cmd, check=True, **kwargs):
1254 # Wrapper around utils.run_process. This is desirable so that the tests
1255 # can fail (in the unittest sense) rather than error'ing.
1256 # In the long run it would nice to completely remove the dependency on
1257 # core emscripten code (shared.py) here.
1258
1259 # Handle buffering for subprocesses. The python unittest buffering mechanism
1260 # will only buffer output from the current process (by overriding sys.stdout
1261 # and sys.stderr), not from sub-processes.
1262 stdout_buffering = 'stdout' not in kwargs and isinstance(sys.stdout, io.StringIO)
1263 stderr_buffering = 'stderr' not in kwargs and isinstance(sys.stderr, io.StringIO)
1264 if stdout_buffering:
1265 kwargs['stdout'] = PIPE
1266 if stderr_buffering:
1267 kwargs['stderr'] = PIPE
1268
1269 try:
1270 rtn = utils.run_process(cmd, check=check, **kwargs)
1271 except subprocess.CalledProcessError as e:
1272 if check and e.returncode != 0:
1273 print(e.stdout)
1274 print(e.stderr)
1275 self.fail(f'subprocess exited with non-zero return code({e.returncode}): `{shlex.join(cmd)}`')
1276
1277 if stdout_buffering:
1278 sys.stdout.write(rtn.stdout)
1279 # When we inject stdout/stderr buffering for our own internal purposes, we do not also want to
1280 # make it available on the returned object.
1281 # If we don't do this then callers would have access to rtn.stdout/rtn.stderr even when they
1282 # didn't request it (i.e. even when they did not pass stderr=PIPE), which can lead to tests
1283 # that pass in buffering mode, but fail without it.
1284 rtn.stdout = None
1285 if stderr_buffering:
1286 sys.stderr.write(rtn.stderr)
1287 rtn.stderr = None
1288 return rtn
1289
1290 def emcc(self, filename, args=[], **kwargs): # noqa
1291 filename = maybe_test_file(filename)

Callers 15

buildMethod · 0.95
get_wasm_textMethod · 0.95
emccMethod · 0.95
expect_failMethod · 0.95
ccsharedMethod · 0.95
build_libraryMethod · 0.95
get_clang_resource_dirFunction · 0.80
runFunction · 0.80
mainFunction · 0.80
check_callFunction · 0.80
get_clang_targetsFunction · 0.80

Calls 4

failMethod · 0.80
printFunction · 0.50
joinMethod · 0.45
writeMethod · 0.45