MCPcopy Index your code
hub / github.com/nodejs/node / call_wrapper

Function call_wrapper

deps/v8/tools/unittests/predictable_wrapper_test.py:20–42  ·  view source on GitHub ↗

Call the predictable wrapper under test with a mocked file to test. Instead of d8, we use python and a python mock script. This mock script is expecting two arguments, mode (one of 'equal', 'differ' or 'missing') and a path to a temporary file for simulating non-determinism.

(mode)

Source from the content-addressed store, hash-verified

18 TOOLS_DIR, 'unittests', 'testdata', 'predictable_mocked.py')
19
20def call_wrapper(mode):
21 """Call the predictable wrapper under test with a mocked file to test.
22
23 Instead of d8, we use python and a python mock script. This mock script is
24 expecting two arguments, mode (one of 'equal', 'differ' or 'missing') and
25 a path to a temporary file for simulating non-determinism.
26 """
27 fd, state_file = tempfile.mkstemp()
28 os.close(fd)
29 try:
30 args = [
31 sys.executable,
32 PREDICTABLE_WRAPPER,
33 sys.executable,
34 PREDICTABLE_MOCKED,
35 mode,
36 state_file,
37 ]
38 proc = subprocess.Popen(args, stdout=subprocess.PIPE)
39 proc.communicate()
40 return proc.returncode
41 finally:
42 os.unlink(state_file)
43
44
45class PredictableTest(unittest.TestCase):

Callers 3

Calls 2

closeMethod · 0.65
unlinkMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…