55import sys
66import platform
77import importlib .util
8- from typing import List , Sequence
8+ from typing import List , Sequence , Optional
99from contextlib import contextmanager
1010import argparse
1111from pathlib import Path
@@ -114,7 +114,12 @@ def symlink(src: Path, dst: Path) -> None:
114114 os .symlink (str (src .resolve ()), str (dst .resolve ()))
115115
116116
117- def create_test_workdir (test_dir : Path , distrib_workdir : Path , test_workdir : Path ) -> None :
117+ def create_test_workdir (
118+ test_dir : Path ,
119+ distrib_workdir : Path ,
120+ test_workdir : Path ,
121+ custom_gdextension_api : Optional [Path ],
122+ ) -> None :
118123 print (
119124 f"{ YELLOW } { test_dir .name } : Create&populate test workdir in { test_workdir } { NO_COLOR } " ,
120125 flush = True ,
@@ -123,7 +128,10 @@ def create_test_workdir(test_dir: Path, distrib_workdir: Path, test_workdir: Pat
123128 symlink (distrib_workdir / "addons" , test_workdir / "addons" )
124129 shutil .copy (distrib_workdir / "pythonscript.gdextension" , test_workdir )
125130 # GDExtension headers are needed to compile Cython modules
126- symlink (build_dir / "gdextension_api" , test_workdir / "gdextension_api" )
131+ if custom_gdextension_api :
132+ shutil .copytree (custom_gdextension_api , test_workdir / "gdextension_api" )
133+ else :
134+ symlink (build_dir / "gdextension_api" , test_workdir / "gdextension_api" )
127135
128136 build_script = test_workdir / "build.py"
129137 if build_script .exists ():
@@ -262,6 +270,11 @@ def run_test(
262270 action = "store_true" ,
263271 help = "Only update the addons build symlinked into all test projects" ,
264272 )
273+ parser .add_argument (
274+ "--custom-gdextension-api" ,
275+ type = Path ,
276+ help = "Copy GDExtension API folder from there instead of symlink the build one (useful if you have issues on Windows)" ,
277+ )
265278
266279 try :
267280 options_separator = sys .argv .index ("--" )
@@ -312,5 +325,6 @@ def test_workdir_factory():
312325 test_dir = test_dir ,
313326 distrib_workdir = distrib_workdir ,
314327 test_workdir = test_workdir ,
328+ custom_gdextension_api = args .custom_gdextension_api ,
315329 )
316330 run_test (test_dir .name , test_workdir , godot_binary_path , godot_extra_args )
0 commit comments