Skip to content

Commit e03dfe7

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 e03dfe7

File tree

4 files changed

+23
-12
lines changed

4 files changed

+23
-12
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 & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -233,13 +233,13 @@ 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 = [
238239
"bash",
239-
"-ec",
240-
f"cd {Path(__file__).parent / 'data'/ 'django'};"
241-
+ f" {sys.executable} manage.py runserver"
242-
+ f" {host}:{port}",
240+
Path(__file__).parent / "bin" / "runner",
241+
(Path(__file__).parent / "data" / "django").as_posix(),
242+
f"{Path(sys.executable).as_posix()} manage.py runserver {host}:{port}",
243243
]
244244
env = {
245245
"DJANGO_SETTINGS_MODULE": f"djangoapp.{settings}",

_appmap/test/test_fastapi.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,14 +88,16 @@ 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 = [
9597
"bash",
96-
"-ec",
97-
f"cd {Path(__file__).parent / 'data'/ 'fastapi'};"
98-
+ f" {sys.executable} -m uvicorn fastapiapp.main:app"
98+
Path(__file__).parent / "bin" / "runner",
99+
(Path(__file__).parent / "data" / "fastapi").as_posix(),
100+
f"{Path(sys.executable).as_posix()} -m uvicorn fastapiapp.main:app"
99101
+ f" {reload} --host {host} --port {port}",
100102
]
101103
env = {

_appmap/test/test_flask.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -125,24 +125,26 @@ 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 = [
130131
"bash",
131-
"-ec",
132-
f"cd {Path(__file__).parent / 'data'/ 'flask'};"
133-
+ f" {sys.executable} -m flask run"
134-
+ f" -p {port}",
132+
Path(__file__).parent / "bin" / "runner",
133+
(Path(__file__).parent / "data" / "flask").as_posix(),
134+
f" {Path(sys.executable).as_posix()} -m flask run -p {port}",
135135
]
136136
print(args)
137137
env = {
138+
"APPMAP_DISABLE_LOG_FILE": "false",
138139
"FLASK_APP": "flaskapp.py",
139140
"FLASK_DEBUG": flask_debug,
140141
"PYTHONUNBUFFERED": "1",
141142
"APPMAP_OUTPUT_DIR": "/tmp",
142143
**server_env,
143144
}
144145

145-
xprocess.ensure("myserver", Starter)
146+
pid, logpath = xprocess.ensure("myserver", Starter)
147+
print(f"pid: {pid} logpath: {logpath}")
146148
yield NS(debug=debug, url=f"http://{host}:{port}")
147149
xprocess.getinfo("myserver").terminate()
148150

0 commit comments

Comments
 (0)