Skip to content

Commit 9863ce1

Browse files
committed
test: add a script to run test servers
Instead of trying to use bash directly, run the test servers using a script. This works around quoting and path resolution issues.
1 parent 0ceff4c commit 9863ce1

File tree

4 files changed

+21
-14
lines changed

4 files changed

+21
-14
lines changed

_appmap/test/bin/runner

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/usr/bin/env bash
2+
3+
set -ex
4+
5+
cd "$1"; shift
6+
7+
exec $@

_appmap/test/test_django.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -233,13 +233,12 @@ def startup_check(self):
233233
pass
234234
return False
235235

236+
terminate_on_interrupt = True
236237
pattern = f"server at http://{host}:{port}"
237238
args = [
238-
"bash",
239-
"-ec",
240-
f"cd {Path(__file__).parent / 'data'/ 'django'};"
241-
+ f" {sys.executable} manage.py runserver"
242-
+ f" {host}:{port}",
239+
Path(__file__).parent / "bin" / "runner",
240+
(Path(__file__).parent / "data" / "django").as_posix(),
241+
f"{Path(sys.executable).as_posix()} manage.py runserver {host}:{port}",
243242
]
244243
env = {
245244
"DJANGO_SETTINGS_MODULE": f"djangoapp.{settings}",

_appmap/test/test_fastapi.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,14 +88,15 @@ def startup_check(self):
8888
pass
8989
return False
9090

91+
timeout = 10
92+
terminate_on_interrupt = True
9193
pattern = f"Uvicorn running on http://{host}:{port}"
9294
# Can't set popen_kwargs["cwd"] until
9395
# https://github.com/pytest-dev/pytest-xprocess/issues/89 is fixed.
9496
args = [
95-
"bash",
96-
"-ec",
97-
f"cd {Path(__file__).parent / 'data'/ 'fastapi'};"
98-
+ f" {sys.executable} -m uvicorn fastapiapp.main:app"
97+
Path(__file__).parent / "bin" / "runner",
98+
(Path(__file__).parent / "data" / "fastapi").as_posix(),
99+
f"{Path(sys.executable).as_posix()} -m uvicorn fastapiapp.main:app"
99100
+ f" {reload} --host {host} --port {port}",
100101
]
101102
env = {

_appmap/test/test_flask.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -125,16 +125,16 @@ def startup_check(self):
125125
pass
126126
return False
127127

128+
terminate_on_interrupt = True
128129
pattern = f"Running on http://{host}:{port}"
129130
args = [
130-
"bash",
131-
"-ec",
132-
f"cd {Path(__file__).parent / 'data'/ 'flask'};"
133-
+ f" {sys.executable} -m flask run"
134-
+ f" -p {port}",
131+
Path(__file__).parent / "bin" / "runner",
132+
(Path(__file__).parent / "data" / "flask").as_posix(),
133+
f" {Path(sys.executable).as_posix()} -m flask run -p {port}",
135134
]
136135
print(args)
137136
env = {
137+
"APPMAP_DISABLE_LOG_FILE": "false",
138138
"FLASK_APP": "flaskapp.py",
139139
"FLASK_DEBUG": flask_debug,
140140
"PYTHONUNBUFFERED": "1",

0 commit comments

Comments
 (0)