Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,12 +1,29 @@
import subprocess
import logging
import time
import socket


def wait_for_port(port, process, timeout=100):
start = time.time()
while time.time() - start < timeout:
# Check if process died
if process.poll() is not None:
raise RuntimeError(f"Server process exited with code {process.returncode}")
try:
with socket.create_connection(("localhost", port), timeout=1):
return True
except (socket.timeout, ConnectionRefusedError, OSError):
time.sleep(0.2)
raise RuntimeError(f"Port {port} not ready within {timeout}s")


def test(codeql, java):
# Each of these serves the "repo" and "repo2" directories on http://localhost:924[89]
repo_server_process = subprocess.Popen(["python3", "-m", "http.server", "9428", "-b", "localhost"], cwd="repo")
repo_server_process2 = subprocess.Popen(["python3", "-m", "http.server", "9429", "-b", "localhost"], cwd="repo2")
repo_server_process = subprocess.Popen(["python3", "-m", "http.server", "9428", "-b", "localhost"], cwd="repo", stderr=subprocess.PIPE, stdout=subprocess.PIPE)
repo_server_process2 = subprocess.Popen(["python3", "-m", "http.server", "9429", "-b", "localhost"], cwd="repo2", stderr=subprocess.PIPE, stdout=subprocess.PIPE)
try:
wait_for_port(9428, repo_server_process)
wait_for_port(9429, repo_server_process2)
codeql.database.create(
extractor_option="buildless=true",
_env={"CODEQL_EXTRACTOR_JAVA_OPTION_BUILDLESS_CLASSPATH_FROM_BUILD_FILES": "true"},
Expand Down