MCPcopy Create free account
hub / github.com/WebAssembly/wabt / main

Function main

test/run-c-api-examples.py:81–118  ·  view source on GitHub ↗
(args)

Source from the content-addressed store, hash-verified

79
80
81def main(args):
82 print('Running c-api examples..')
83 parser = argparse.ArgumentParser()
84 parser.add_argument('--bindir', metavar='PATH',
85 default=find_exe.GetDefaultPath(),
86 help='directory to search for all executables.')
87
88 options = parser.parse_args(args)
89 script_dir = os.path.dirname(os.path.abspath(__file__))
90 root = os.path.dirname(script_dir)
91 upstream_dir = os.path.join(root, 'third_party', 'wasm-c-api', 'example')
92 upstream_examples = [f for f in os.listdir(upstream_dir) if os.path.splitext(f)[1] == '.wasm']
93 upstream_examples = [os.path.splitext(f)[0] for f in upstream_examples]
94 check_for_missing(upstream_examples)
95
96 def should_skip(e):
97 return any(e.startswith(skip) for skip in SKIP_EXAMPLES)
98
99 to_run = [e for e in upstream_examples if not should_skip(e)]
100
101 os.chdir(options.bindir)
102 count = 0
103 fail_count = 0
104 for f in to_run:
105 if IS_WINDOWS:
106 f += '.exe'
107 exe = os.path.join(options.bindir, 'wasm-c-api-' + f)
108 if not os.path.exists(exe):
109 error('test executable not found: %s' % exe)
110
111 count += 1
112 if run_test(exe) != 0:
113 fail_count += 1
114
115 if fail_count:
116 print('[%d/%d] c-api examples failed' % (fail_count, count))
117 return 1
118 return 0
119
120
121if __name__ == '__main__':

Callers 1

Calls 6

printFunction · 0.85
check_for_missingFunction · 0.85
should_skipFunction · 0.85
run_testFunction · 0.85
joinMethod · 0.80
errorFunction · 0.70

Tested by

no test coverage detected