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

Method expect_fail

test/common.py:1298–1314  ·  view source on GitHub ↗

Run a subprocess and assert that it returns non-zero. Return the stderr of the subprocess.

(self, cmd, expect_traceback=False, **kwargs)

Source from the content-addressed store, hash-verified

1296 # Shared test code between main suite and others
1297
1298 def expect_fail(self, cmd, expect_traceback=False, **kwargs):
1299 """Run a subprocess and assert that it returns non-zero.
1300
1301 Return the stderr of the subprocess.
1302 """
1303 proc = self.run_process(cmd, check=False, stderr=PIPE, **kwargs)
1304 self.assertNotEqual(proc.returncode, 0, 'subprocess unexpectedly succeeded. stderr:\n' + proc.stderr)
1305 # When we check for failure we expect a user-visible error, not a traceback.
1306 # However, on windows a python traceback can happen randomly sometimes,
1307 # due to "Access is denied" https://github.com/emscripten-core/emscripten/issues/718
1308 if expect_traceback:
1309 self.assertContained('Traceback', proc.stderr)
1310 elif not WINDOWS or 'Access is denied' not in proc.stderr:
1311 self.assertNotContained('Traceback', proc.stderr)
1312 if EMTEST_VERBOSE:
1313 sys.stderr.write(proc.stderr)
1314 return proc.stderr
1315
1316 def assert_fail(self, cmd, expected, **kwargs):
1317 """Just like expect_fail, but also check for expected message in stderr."""

Calls 4

run_processMethod · 0.95
assertContainedMethod · 0.95
assertNotContainedMethod · 0.95
writeMethod · 0.45