mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-01-31 11:37:35 +00:00
b5f743cdc3
We now build a separate APE binary for each test so they can run in parallel. We've got 148 tests running fast and stable so far.
15 lines
506 B
Python
15 lines
506 B
Python
import sys
|
|
from importlib import _bootstrap_external
|
|
|
|
def run_module_as_main(mod_name):
|
|
path = "/zip/.python/%s.pyc" % (mod_name.replace(".", "/"))
|
|
loader = _bootstrap_external.SourcelessFileLoader(mod_name, path)
|
|
code = loader.get_code(mod_name)
|
|
globs = sys.modules["__main__"].__dict__
|
|
globs["__name__"] = "__main__"
|
|
globs["__file__"] = path[:-1]
|
|
globs["__package__"] = None
|
|
globs["__loader__"] = loader
|
|
globs["__spec__"] = None
|
|
exec(code, globs)
|
|
return globs
|