forked from JonathonReinhart/scuba
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run_full_tests.py
executable file
·52 lines (36 loc) · 1.14 KB
/
run_full_tests.py
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/env python3
import os
import sys
import subprocess
import tempfile
import shutil
from tests.const import DOCKER_IMAGE
class InTempDir:
def __init__(self, suffix="", prefix="tmp", delete=True):
self.delete = delete
self.temp_path = tempfile.mkdtemp(suffix=suffix, prefix=prefix)
def __enter__(self):
self.orig_path = os.getcwd()
os.chdir(self.temp_path)
return self
def __exit__(self, *exc_info):
# Restore the working dir and cleanup the temp one
os.chdir(self.orig_path)
if self.delete:
shutil.rmtree(self.temp_path)
def test1():
with InTempDir(prefix="scuba-systest"):
with open(".scuba.yml", "w+t") as f:
f.write(f"image: {DOCKER_IMAGE}\n")
in_data = "success"
with open("file.in", "w+t") as f:
f.write(in_data)
subprocess.check_call(["scuba", "/bin/sh", "-c", "cat file.in >> file.out"])
with open("file.out", "rt") as f:
out_data = f.read()
assert in_data == out_data
def main():
test1()
print("All is good.")
if __name__ == "__main__":
main()