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

Method setUp

test/common.py:735–806  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

733 shared.check_sanity(force=True, quiet=True)
734
735 def setUp(self):
736 super().setUp()
737 self.js_engines = config.JS_ENGINES.copy()
738 self.settings_mods = {}
739 self.skip_exec = None
740 self.flaky = False
741 self.cflags = ['-Wclosure', '-Werror', '-Wno-limited-postlink-optimizations']
742 # TODO(https://github.com/emscripten-core/emscripten/issues/11121)
743 # For historical reasons emcc compiles and links as C++ by default.
744 # However we want to run our tests in a more strict manner. We can
745 # remove this if the issue above is ever fixed.
746 self.set_setting('NO_DEFAULT_TO_CXX')
747 self.ldflags = []
748 # Increase the stack trace limit to maximise usefulness of test failure reports.
749 # Also, include backtrace for all uncaught exceptions (not just Error).
750 self.node_args = ['--stack-trace-limit=50', '--trace-uncaught']
751 self.spidermonkey_args = []
752
753 nodejs = get_nodejs()
754 if nodejs:
755 node_version = shared.get_node_version(nodejs)
756
757 # If the version we are running tests in is lower than the version that
758 # emcc targets then we need to tell emcc to target that older version.
759 emcc_min_node_version_str = str(shared.settings.MIN_NODE_VERSION)
760 emcc_min_node_version = (
761 int(emcc_min_node_version_str[0:2]),
762 int(emcc_min_node_version_str[2:4]),
763 int(emcc_min_node_version_str[4:6]),
764 )
765 if node_version < emcc_min_node_version:
766 self.cflags.append('-sMIN_NODE_VERSION=%02d%02d%02d' % node_version)
767
768 self.v8_args = ['--wasm-staging']
769 self.env = {}
770 self.temp_files_before_run = []
771 self.required_engine = None
772 self.wasm_engines = config.WASM_ENGINES.copy()
773 self.use_all_engines = EMTEST_ALL_ENGINES
774 engine = self.get_current_js_engine()
775 if not engine_is_node(engine) and not engine_is_bun(engine) and not engine_is_deno(engine):
776 # If our current JS engine a "shell" environment we need to explicitly enable support for
777 # it in ENVIRONMENT.
778 default_envs = 'web,webview,worker,node'
779 self.set_setting('ENVIRONMENT', default_envs + ',shell')
780
781 if EMTEST_DETECT_TEMPFILE_LEAKS:
782 for root, dirnames, filenames in os.walk(self.temp_dir):
783 for dirname in dirnames:
784 self.temp_files_before_run.append(os.path.normpath(os.path.join(root, dirname)))
785 for filename in filenames:
786 self.temp_files_before_run.append(os.path.normpath(os.path.join(root, filename)))
787
788 if self.runningInParallel():
789 self.working_dir = tempfile.mkdtemp(prefix='emscripten_test_' + self.__class__.__name__ + '_', dir=self.temp_dir)
790 else:
791 self.working_dir = path_from_root('out/test')
792 if os.path.exists(self.working_dir):

Callers

nothing calls this directly

Calls 15

set_settingMethod · 0.95
get_current_js_engineMethod · 0.95
runningInParallelMethod · 0.95
path_from_rootFunction · 0.90
get_nodejsFunction · 0.85
engine_is_nodeFunction · 0.85
engine_is_bunFunction · 0.85
engine_is_denoFunction · 0.85
force_delete_contentsFunction · 0.85
ensure_dirFunction · 0.85
appendMethod · 0.80
existsMethod · 0.80

Tested by

no test coverage detected