Skip to content

Commit 55f1048

Browse files
committed
Use bash script to start Python http server for testing PAC file
1 parent 2b2935f commit 55f1048

File tree

4 files changed

+24
-3
lines changed

4 files changed

+24
-3
lines changed

.github/workflows/macos.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ jobs:
4545
run: cmake --build build --config RelWithDebInfo
4646

4747
- name: Run test http server
48-
run: python3 -m http.server 8080 &
48+
run: ./pac_server.sh
4949
working-directory: test
5050

5151
- name: Run tests

.github/workflows/ubuntu.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ jobs:
8181
run: cmake --build build --config RelWithDebInfo
8282

8383
- name: Run test http server
84-
run: python3 -m http.server 8080 &
84+
run: ./pac_server.sh
8585
working-directory: test
8686

8787
- name: Run tests

.github/workflows/win32.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ jobs:
7171

7272
- name: Run test http server
7373
shell: bash
74-
run: python3 -m http.server 8080 &
74+
run: ./pac_server.sh
7575
working-directory: test
7676

7777
- name: Run tests

test/pac_server.sh

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/bin/sh
2+
# Start an HTTP server and wait until it is ready to accept connections.
3+
4+
PORT="${1:-8080}"
5+
MAX_ATTEMPTS=30
6+
7+
python3 -m http.server "$PORT" &
8+
SERVER_PID=$!
9+
10+
for i in $(seq 1 "$MAX_ATTEMPTS"); do
11+
if curl -sSf "http://127.0.0.1:$PORT/" >/dev/null 2>&1; then
12+
echo "HTTP server is ready on port $PORT (pid $SERVER_PID)"
13+
exit 0
14+
fi
15+
echo "Waiting for HTTP server (attempt $i/$MAX_ATTEMPTS)..."
16+
sleep 1
17+
done
18+
19+
echo "HTTP server failed to start on port $PORT" >&2
20+
kill "$SERVER_PID" 2>/dev/null
21+
exit 1

0 commit comments

Comments
 (0)