Skip to content

Commit cbb82c0

Browse files
authored
Fixing tests to make them run and pass on Windows (#116)
* fix: allows tests to be run on windows (SIGUSR1 not supported) * fix: escape url pattern for regex, since windows uses backslash which makes it crash * fix: using forward slashes in file path since cdp always returns back forward slashes * run format + update changelogs * feat: run ci on windows * portable way to get chrome version (windows fix)
1 parent 8488491 commit cbb82c0

File tree

5 files changed

+17
-8
lines changed

5 files changed

+17
-8
lines changed

.github/workflows/test.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@ on:
1313
workflow_dispatch:
1414
jobs:
1515
test:
16-
runs-on: ubuntu-latest
16+
runs-on: ${{ matrix.os }}
17+
strategy:
18+
matrix:
19+
os: [ ubuntu-latest, windows-latest ]
1720
steps:
1821
- uses: actions/checkout@v4
1922
- name: Install uv
@@ -26,4 +29,5 @@ jobs:
2629
env:
2730
ZENDRIVER_TEST_BROWSERS: "headless"
2831
ZENDRIVER_TEST_NO_SANDBOX: "true"
29-
run: /bin/bash ./scripts/test.sh
32+
shell: bash
33+
run: ./scripts/test.sh

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99

1010
### Fixed
1111

12+
- Fixing tests so that they can run on Windows (and still run on Linux like before) @nathanfallet
13+
1214
### Added
1315

1416
### Changed

scripts/test.sh

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,7 @@ fi
1010
chrome_executable=$(uv run python -c "from zendriver.core.config import find_chrome_executable;print(find_chrome_executable())")
1111
echo "Chrome executable: $chrome_executable"
1212

13-
chrome_cmd=( "$chrome_executable" )
14-
chrome_cmd+=("--version")
15-
chrome_version=$("${chrome_cmd[@]}")
13+
chrome_version=$(uv run python -c "import os, subprocess, sys; path = r'$chrome_executable'; print(subprocess.run([path, '--version'], capture_output=True, text=True).stdout.strip()) if os.name != 'nt' else print('SKIP: Windows chrome.exe may not return version')")
1614
echo "Chrome version: $chrome_version"
1715

1816
set -x

tests/conftest.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,4 +123,9 @@ def handle_next_test(signum, frame):
123123
NEXT_TEST_EVENT.set()
124124

125125

126-
signal.signal(signal.SIGUSR1, handle_next_test)
126+
if hasattr(signal, "SIGUSR1"):
127+
signal.signal(signal.SIGUSR1, handle_next_test)
128+
else:
129+
logger.warning(
130+
"SIGUSR1 not available on this platform, handle_next_test will not be called."
131+
)

tests/sample_data/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22

33

44
def sample_file(name: str) -> str:
5-
path = (Path(__file__).parent / name).absolute()
6-
return f"file://{path}"
5+
path = (Path(__file__).parent / name).resolve()
6+
return path.as_uri()

0 commit comments

Comments
 (0)