Skip to content

Commit

Permalink
test: get Windows test working again (#571)
Browse files Browse the repository at this point in the history
Apparently `py` is no longer a valid name for the python interpreter on
GitHub Actions.
  • Loading branch information
coryan authored Nov 2, 2023
1 parent 45bfb86 commit 442a30b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
12 changes: 9 additions & 3 deletions tests/test_testbench_continue_after_fault_injection.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,23 +36,29 @@ def setUp(self):
if platform.system().lower() == "windows":
server_start_message = "INFO:waitress:Serving on http://"
server_regex_pattern = "INFO:waitress:Serving on.*:([0-9]+)"
python_command = "py"
python_command = "python"

self.testbench_server = subprocess.Popen(
[python_command, "testbench_run.py", "localhost", "0", "10"],
stderr=subprocess.PIPE,
universal_newlines=True,
)
captured = []
self.port = None
start = time.time()
# Wait for the message declaring this process is running
while self.port is None and time.time() - start < 120:
while self.port is None and time.time() - start < 20:
line = self.testbench_server.stderr.readline()
if server_start_message in line:
m = re.compile(server_regex_pattern).search(line)
if m is not None:
self.port = m[1]
self.assertIsNotNone(self.port)
self.assertIsNotNone(
self.port,
msg="Did not find startup message {} in log:\n{}".format(
server_start_message, "\n".join(captured)
),
)

def tearDown(self):
self.testbench_server.stderr.close()
Expand Down
15 changes: 10 additions & 5 deletions tests/test_testbench_startup.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
class TestTestbenchStartup(unittest.TestCase):
def python_command(self):
if platform.system().lower() == "windows":
return "py"
return "python"
return "python3"

def setUp(self):
Expand Down Expand Up @@ -64,7 +64,6 @@ def tearDown(self):
p.wait(30)

def wait_testbench_server(self):
started = False
port = None
start = time.time()

Expand All @@ -77,14 +76,20 @@ def wait_testbench_server(self):
server_regex_pattern = "INFO:waitress:Serving on.*:([0-9]+)"

# Wait for the message declaring this process is running
while not started and time.time() - start < 120:
captured = []
while port is None and time.time() - start < 120:
line = self.testbench_server.stderr.readline()
captured.append(line)
if server_start_message in line:
m = re.compile(server_regex_pattern).search(line)
if m is not None:
started = True
port = m[1]
self.assertTrue(started)
self.assertIsNotNone(
port,
msg="Did not find startup message {} in log:\n{}".format(
server_start_message, "\n".join(captured)
),
)
return port

def test_startup_server(self):
Expand Down

0 comments on commit 442a30b

Please sign in to comment.