Skip to content

Commit 84371da

Browse files
DinoVmeta-codesync[bot]
authored andcommitted
Run compiled code samples
Summary: Runs the compiled code samples - richards needs to not read the sys.argv. Reviewed By: grantlouisherman Differential Revision: D96362906 fbshipit-source-id: efb154cea5d19ee6d3eb9ec4ca4a3292fad6727f
1 parent fc49d10 commit 84371da

2 files changed

Lines changed: 18 additions & 3 deletions

File tree

cinderx/PythonLib/test_cinderx/test_compiler/test_static/pyrefly_binder.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import ast
44
import json
5+
import sys
56
import unittest
67
from glob import glob
78
from os import path
@@ -82,12 +83,13 @@ def test_cases(self):
8283
basename = path.basename(filename)
8384
if basename == "__init__":
8485
continue
86+
modname = f"cinderx.PythonLib.test_cinderx.test_compiler.test_static.pyreflytests.{basename}"
8587
with self.subTest(f), open(f) as f, open(jsonname) as jsonf:
8688
data = json.load(jsonf)
8789
code = self.compile_one(
8890
f.read(),
8991
PyreflyTypeInfo(data),
90-
modname=f"cinderx.PythonLib.test_cinderx.test_compiler.test_static.pyreflytests.{basename}",
92+
modname=modname,
9193
)
9294
if path.exists(testname):
9395
print(testname)
@@ -97,6 +99,19 @@ def test_cases(self):
9799
exec(compile(test_source, testname, "exec"), ns)
98100
ns["verify"](self, code)
99101

102+
mod = type(sys)(modname)
103+
mod.__dict__.update(
104+
**{
105+
"<fixed-modules>": {
106+
"__strict__": __import__("__strict__").__dict__,
107+
"typing": __import__("typing").__dict__,
108+
},
109+
"__name__": "__main__",
110+
}
111+
)
112+
sys.modules[modname] = mod
113+
exec(code, mod.__dict__)
114+
100115
def compile_one(
101116
self,
102117
code: str,

cinderx/PythonLib/test_cinderx/test_compiler/test_static/pyreflytests/richards_typed.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,6 @@ def run(self, iterations: int) -> bool:
419419

420420
if __name__ == "__main__":
421421
num_iterations = 1
422-
if len(sys.argv) > 1:
423-
num_iterations = int(sys.argv[1])
422+
# if len(sys.argv) > 1:
423+
# num_iterations = int(sys.argv[1])
424424
Richards().run(num_iterations)

0 commit comments

Comments
 (0)