forked from frozeneffigy/rDrama
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_tests.py
More file actions
executable file
·52 lines (45 loc) · 1.02 KB
/
Copy pathrun_tests.py
File metadata and controls
executable file
·52 lines (45 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/usr/bin/python3
import subprocess
import sys
# we want to leave the container in whatever state it currently is, so check to see if it's running
docker_inspect = subprocess.run([
"docker",
"container",
"inspect",
"-f", "{{.State.Status}}",
"rDrama",
],
capture_output = True,
).stdout.decode("utf-8").strip()
was_running = docker_inspect == "running"
# update containers, just in case they're out of date
if was_running:
print("Updating containers . . .", flush=True)
else:
print("Starting containers . . .", flush=True)
subprocess.run([
"docker-compose",
"up",
"--build",
"-d",
],
check = True,
)
# run the test
print("Running test . . .", flush=True)
result = subprocess.run([
"docker",
"exec",
"rDrama",
"bash", "-c", "cd service && python3 -m pytest -s"
])
if not was_running:
# shut down, if we weren't running in the first place
print("Shutting down containers . . .", flush=True)
subprocess.run([
"docker-compose",
"stop",
],
check = True,
)
sys.exit(result.returncode)