1+ import asyncio
12import pathlib
23import shlex
3- import sys
44import sysconfig
55import tempfile
66import test .support
7+ import test .test_tools
78import test .support .script_helper
89import unittest
910
1314_TOOLS_JIT_TEST_TEST_EXECUTOR_CASES_C_H = _TOOLS_JIT_TEST / "test_executor_cases.c.h"
1415_TOOLS_JIT_BUILD_PY = _TOOLS_JIT / "build.py"
1516
17+ test .test_tools .skip_if_missing ("jit" )
18+ with test .test_tools .imports_under_tool ("jit" ):
19+ import _llvm
1620
1721@test .support .cpython_only
1822@unittest .skipIf (test .support .Py_DEBUG , "Debug stencils aren't tested." )
1923@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." )
2124class TestJITStencils (unittest .TestCase ):
2225
2326 def _build_jit_stencils (self , target : str ) -> str :
@@ -31,6 +34,9 @@ def _build_jit_stencils(self, target: str) -> str:
3134 "--pyconfig-dir" , pyconfig_h .parent ,
3235 target ,
3336 __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" ,
3440 )
3541 if result .rc :
3642 self .skipTest (f"Build failed: { shlex .join (map (str , args ))} " )
@@ -54,6 +60,8 @@ def _check_jit_stencils(
5460 raise
5561
5662 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." )
5765 self .maxDiff = None
5866 found = False
5967 for test_jit_stencils_h in _TOOLS_JIT_TEST .glob ("test_jit_stencils-*.h" ):
@@ -64,7 +72,7 @@ def test_jit_stencils(self):
6472 found = True
6573 self ._check_jit_stencils (expected , actual , test_jit_stencils_h )
6674 # 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!"
6876
6977
7078if __name__ == "__main__" :
0 commit comments