Skip to content

Commit

Permalink
Further fixes for Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
Disservin committed Sep 17, 2024
1 parent ebf4f19 commit 21a9e9a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
4 changes: 2 additions & 2 deletions tests/instrumented.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ def test_depth_5_with_callback(self):
self.stockfish.send_command("go depth 5")

def callback(output):
regex = "info depth \d+ seldepth \d+ multipv \d+ score cp \d+ nodes \d+ nps \d+ hashfull \d+ tbhits \d+ time \d+ pv"
regex = r"info depth \d+ seldepth \d+ multipv \d+ score cp \d+ nodes \d+ nps \d+ hashfull \d+ tbhits \d+ time \d+ pv"
if output.startswith("info depth") and not re.match(regex, output):
assert False
if output.startswith("bestmove"):
Expand All @@ -274,7 +274,7 @@ def test_ucinewgame_and_go_depth_9(self):
def callback(output):
nonlocal depth

regex = f"info depth {depth} seldepth \d+ multipv \d+ score cp \d+ wdl \d+ \d+ \d+ nodes \d+ nps \d+ hashfull \d+ tbhits \d+ time \d+ pv"
regex = rf"info depth {depth} seldepth \d+ multipv \d+ score cp \d+ wdl \d+ \d+ \d+ nodes \d+ nps \d+ hashfull \d+ tbhits \d+ time \d+ pv"

if output.startswith("info depth"):
if not re.match(regex, output):
Expand Down
20 changes: 13 additions & 7 deletions tests/testing.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import subprocess
from typing import List, Callable, Any
from typing import List
import os
import collections
import time
Expand All @@ -10,10 +10,11 @@
from contextlib import redirect_stdout
import io
import tarfile
import urllib.request
import pathlib
import concurrent.futures
import tempfile
import shutil
import requests

CYAN_COLOR = "\033[36m"
GRAY_COLOR = "\033[2m"
Expand Down Expand Up @@ -90,15 +91,20 @@ def get_syzygy_path():
def download_syzygy():
if not os.path.isdir(os.path.join(PATH, "syzygy")):
url = "https://api.github.com/repos/niklasf/python-chess/tarball/9b9aa13f9f36d08aadfabff872882f4ab1494e95"
tarball_path = "/tmp/python-chess.tar.gz"
file = "niklasf-python-chess-9b9aa13"

urllib.request.urlretrieve(url, tarball_path)
with tempfile.TemporaryDirectory() as tmpdirname:
tarball_path = os.path.join(tmpdirname, f"{file}.tar.gz")

with tarfile.open(tarball_path, "r:gz") as tar:
tar.extractall("/tmp")
response = requests.get(url, stream=True)
with open(tarball_path, 'wb') as f:
for chunk in response.iter_content(chunk_size=8192):
f.write(chunk)

os.rename("/tmp/niklasf-python-chess-9b9aa13", os.path.join(PATH, "syzygy"))
with tarfile.open(tarball_path, "r:gz") as tar:
tar.extractall(tmpdirname)

shutil.move(os.path.join(tmpdirname, file), os.path.join(PATH, "syzygy"))

class OrderedClassMembers(type):
@classmethod
Expand Down

0 comments on commit 21a9e9a

Please sign in to comment.