Make engine testing local#1160
Merged
AttackingOrDefending merged 8 commits intoDec 6, 2025
Merged
Conversation
No need to download any chess engines. Mypy does not see test_games.py
Collaborator
Author
|
Problems so far:
@AttackingOrDefending, any ideas for fixing (1)? For (2), can we detect connection errors and skip tests? |
Member
|
For (1): def create_engine(engine_config: Configuration, game: model.Game | None = None) -> EngineWrapper:
"""
Create the engine.
Use in a with-block to automatically close the engine when exiting the game.
:param engine_config: The options for the engine.
:return: An engine. Either UCI, XBoard, or Homemade.
"""
cfg = engine_config.engine
engine_path = cfg.name
engine_type = cfg.protocol
commands = []
if cfg.interpreter:
commands.append(cfg.interpreter)
commands.extend(cfg.interpreter_options)
else:
engine_path = os.path.abspath(os.path.join(cfg.dir, engine_path))
commands.append(engine_path)
if cfg.engine_options:
for k, v in cfg.engine_options.items():
commands.append(f"--{k}={v}" if v is not None else f"--{k}")
stderr = None if cfg.silence_stderr else subprocess.DEVNULL
Engine: type[UCIEngine | XBoardEngine | MinimalEngine]
if engine_type == "xboard":
Engine = XBoardEngine
elif engine_type == "uci":
Engine = UCIEngine
elif engine_type == "homemade":
Engine = get_homemade_engine(cfg.name)
else:
raise ValueError(
f" Invalid engine type: {engine_type}. Expected xboard, uci, or homemade.")
options = remove_managed_options(cfg.lookup(f"{engine_type}_options") or Configuration({}))
logger.debug(f"Starting engine: {commands}")
return Engine(commands, options, stderr, cfg.draw_or_resign, game, cwd=cfg.working_dir)
python = sys.executable # Otherwise you have to install chess on the global python
...
CONFIG["engine"]["dir"] = "test_bot" # can be removed
CONFIG["engine"]["name"] = "test_bot.uci_engine"
CONFIG["engine"]["interpreter"] = python
CONFIG["engine"]["interpreter_options"] = ["-m"]And change all imports to: For (2): Yes, just skip them. |
Collaborator
Author
|
I ended up using Anyway, this is ready for review and/or merging. |
Collaborator
Author
|
The external move tests can be fixed in another PR. |
Member
|
I think |
AttackingOrDefending
approved these changes
Dec 6, 2025
206e858
into
lichess-bot-devs:master
17 of 23 checks passed
r0950336
pushed a commit
to r0950336/lichess-bot
that referenced
this pull request
Dec 31, 2025
* Make UCI and XBoard tests local No need to download any chess engines. Mypy does not see test_games.py * Delete unused import * Delete unneeded external files and opponent arg * Add fix for imports to satisfy mypy * Use sys.executable for portability * Break up over-complicated line * Delete trivial testing engine
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Type of pull request:
Description:
Stops downloading chess engines every time a test is run. All engine types are simulated locally.
Related Issues:
N/A
Checklist:
Screenshots/logs (if applicable):