1
+ import asyncio
1
2
import pathlib
2
3
import shlex
3
- import sys
4
4
import sysconfig
5
5
import tempfile
6
6
import test .support
7
+ import test .test_tools
7
8
import test .support .script_helper
8
9
import unittest
9
10
13
14
_TOOLS_JIT_TEST_TEST_EXECUTOR_CASES_C_H = _TOOLS_JIT_TEST / "test_executor_cases.c.h"
14
15
_TOOLS_JIT_BUILD_PY = _TOOLS_JIT / "build.py"
15
16
17
+ test .test_tools .skip_if_missing ("jit" )
18
+ with test .test_tools .imports_under_tool ("jit" ):
19
+ import _llvm
16
20
17
21
@test .support .cpython_only
18
22
@unittest .skipIf (test .support .Py_DEBUG , "Debug stencils aren't tested." )
19
23
@unittest .skipIf (test .support .Py_GIL_DISABLED , "Free-threaded stencils aren't tested." )
20
- @unittest .skipUnless (sysconfig .is_python_build (), "Requires a local Python build." )
21
24
class TestJITStencils (unittest .TestCase ):
22
25
23
26
def _build_jit_stencils (self , target : str ) -> str :
@@ -31,6 +34,9 @@ def _build_jit_stencils(self, target: str) -> str:
31
34
"--pyconfig-dir" , pyconfig_h .parent ,
32
35
target ,
33
36
__isolated = False ,
37
+ # Windows leaks temporary files on failure because the JIT build
38
+ # process is async. This forces it to be "sync" for this test:
39
+ PYTHON_CPU_COUNT = "1" ,
34
40
)
35
41
if result .rc :
36
42
self .skipTest (f"Build failed: { shlex .join (map (str , args ))} " )
@@ -54,6 +60,8 @@ def _check_jit_stencils(
54
60
raise
55
61
56
62
def test_jit_stencils (self ):
63
+ if not asyncio .run (_llvm ._find_tool ("clang" )):
64
+ self .skipTest (f"LLVM { _llvm ._LLVM_VERSION } isn't installed." )
57
65
self .maxDiff = None
58
66
found = False
59
67
for test_jit_stencils_h in _TOOLS_JIT_TEST .glob ("test_jit_stencils-*.h" ):
@@ -64,7 +72,7 @@ def test_jit_stencils(self):
64
72
found = True
65
73
self ._check_jit_stencils (expected , actual , test_jit_stencils_h )
66
74
# This is a local build. If the JIT is available, at least one test should run:
67
- assert found or not sys . _jit . is_available () , "No JIT stencils built!"
75
+ assert found , "No JIT stencils built!"
68
76
69
77
70
78
if __name__ == "__main__" :
0 commit comments