Skip to content

Commit 42187d8

Browse files
committed
test: make integration tests also run for aw-server-rust
1 parent 1270209 commit 42187d8

File tree

2 files changed

+29
-8
lines changed

2 files changed

+29
-8
lines changed

Makefile

+7-1
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,13 @@ test-integration:
118118
# TODO: Move "integration tests" to aw-client
119119
# FIXME: For whatever reason the script stalls on Appveyor
120120
# Example: https://ci.appveyor.com/project/ErikBjare/activitywatch/build/1.0.167/job/k1ulexsc5ar5uv4v
121-
pytest ./scripts/tests/integration_tests.py ./aw-server/tests/ -v
121+
# aw-server-python
122+
@echo "== Integration testing aw-server =="
123+
@pytest ./scripts/tests/integration_tests.py ./aw-server/tests/ -v
124+
# aw-server-rust
125+
@echo "== Integration testing aw-server-rust =="
126+
@export PATH=aw-server-rust/target/release:aw-server-rust/target/debug:${PATH}; \
127+
pytest ./scripts/tests/integration_tests.py ./aw-server/tests/ -v
122128

123129
ICON := "aw-qt/media/logo/logo.png"
124130

scripts/tests/integration_tests.py

+22-7
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,39 @@
1+
import os
2+
import platform
13
import subprocess
2-
from time import sleep
34
import tempfile
4-
import platform
5+
from time import sleep
56

67
import pytest
78

89

910
def _windows_kill_process(pid):
1011
import ctypes
12+
1113
PROCESS_TERMINATE = 1
1214
handle = ctypes.windll.kernel32.OpenProcess(PROCESS_TERMINATE, False, pid)
1315
ctypes.windll.kernel32.TerminateProcess(handle, -1)
1416
ctypes.windll.kernel32.CloseHandle(handle)
1517

1618

19+
# NOTE: to run tests with a specific server binary,
20+
# set the PATH such that it is the "aw-server" binary.
1721
@pytest.fixture(scope="session")
1822
def server_process():
1923
logfile_stdout = tempfile.NamedTemporaryFile(delete=False)
2024
logfile_stderr = tempfile.NamedTemporaryFile(delete=False)
2125

22-
server_proc = subprocess.Popen(["aw-server", "--testing"], stdout=logfile_stdout, stderr=logfile_stderr)
26+
# find the path of the "aw-server" binary and log it
27+
which_server = subprocess.check_output(["which", "aw-server"], text=True)
28+
print(f"aw-server path: {which_server}")
29+
30+
# if aw-server-rust in PATH, assert that we're picking up the aw-server-rust binary
31+
if "aw-server-rust" in os.environ["PATH"]:
32+
assert "aw-server-rust" in which_server
33+
34+
server_proc = subprocess.Popen(
35+
["aw-server", "--testing"], stdout=logfile_stdout, stderr=logfile_stderr
36+
)
2337

2438
# Wait for server to start up properly
2539
# TODO: Ping the server until it's alive to remove this sleep
@@ -40,19 +54,20 @@ def server_process():
4054
with open(logfile_stdout.name, "r+b") as f:
4155
stdout = str(f.read(), "utf8")
4256
if any(e in stdout for e in error_indicators):
43-
pytest.fail("Found ERROR indicator in stdout from server: {}".format(stdout))
57+
pytest.fail(f"Found ERROR indicator in stdout from server: {stdout}")
4458

4559
with open(logfile_stderr.name, "r+b") as f:
4660
stderr = str(f.read(), "utf8")
47-
if not stderr:
48-
pytest.fail("No output to stderr from server")
61+
# For some reason, this fails aw-server-rust, but not aw-server-python
62+
# if not stderr:
63+
# pytest.fail("No output to stderr from server")
4964

5065
# Will show in case pytest fails
5166
print(stderr)
5267

5368
for s in error_indicators:
5469
if s in stderr:
55-
pytest.fail("Found ERROR indicator in stderr from server: {}".format(s))
70+
pytest.fail(f"Found ERROR indicator in stderr from server: {s}")
5671

5772
# NOTE: returncode was -9 for whatever reason
5873
# if server_proc.returncode != 0:

0 commit comments

Comments
 (0)