-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_containers.py
executable file
·48 lines (34 loc) · 2.4 KB
/
test_containers.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
#!/usr/bin/env python3
import sys
import unittest
from subprocess import run
from run_container import image_name, run_bogglesolve_container, DEFAULT_DICT_PATH
EXPECTED_SOLUTIONS = b'aal\naalii\nail\naile\naisle\nalcine\nale\nalen\nalias\nalien\nalin\naln\nani\nanis\naquiline\ncilia\ncine\ncinel\nclag\nclan\nclang\ncline\nclinia\nelain\nels\nelsin\nens\ngain\ngaine\ngains\ngal\ngale\ngalenic\ngali\ngan\ngas\nilia\niliau\ning\ninial\ninquiline\nisle\nlag\nlai\nlain\nlaine\nlan\nlas\nlei\nlenis\nlens\nliang\nlie\nlien\nliin\nlin\nline\nlinie\nlis\nnaa\nnag\nnail\nnain\nnais\nnasi\nnei\nngai\nnil\nqua\nquag\nquail\nquale\nquan\nquasi\nquila\nquin\nquinia\nquinic\nquis\nquisle\nsaa\nsag\nsai\nsail\nsain\nsal\nsale\nsalic\nsaline\nsan\nsang\nsial\nsialic\nsil\nsile\nsilen\nsileni\nsilenic\nsiliqua\nsin\nsina\nsinal\nsine\nsing\nsla\nslag\nslain\nslang\nsline\nsnag\nsnail\nsnails\nsquail\nsquin\nsuine\nusnic\n'
TEST_BOARD = 'sgnscqaiiliaensu'
def build_bogglesolve_image(dir_name: str):
cmd = ["docker", "build", "--rm", "-t", image_name(dir_name), "."]
print(' '.join(cmd), file=sys.stderr)
run(cmd, check=True, cwd=f"./{dir_name}")
class TestViaDocker(unittest.TestCase):
dict_words_path = DEFAULT_DICT_PATH
def test_python2(self):
build_bogglesolve_image('python2')
proc = run_bogglesolve_container('python2', [TEST_BOARD], dict_path=self.dict_words_path)
self.assertEqual(proc.stdout, EXPECTED_SOLUTIONS)
def test_python3(self):
build_bogglesolve_image('python3')
proc = run_bogglesolve_container('python3', ["--board", TEST_BOARD], dict_path=self.dict_words_path)
self.assertEqual(proc.stdout, EXPECTED_SOLUTIONS)
def test_ruby(self):
build_bogglesolve_image('ruby')
proc = run_bogglesolve_container('ruby', [TEST_BOARD], dict_path=self.dict_words_path)
self.assertEqual(proc.stdout, EXPECTED_SOLUTIONS)
def test_hylang(self):
build_bogglesolve_image('hylang')
proc = run_bogglesolve_container('hylang', ["--board", TEST_BOARD], dict_path=self.dict_words_path)
self.assertEqual(proc.stdout, EXPECTED_SOLUTIONS)
if __name__ == '__main__':
# If the last cmd line arg does not start with `Test...` or `test...` assume it is a dictionary of words
if len(sys.argv) > 1 and sys.argv[-1][0:4].lower() != "test":
TestViaDocker.dict_words_path = sys.argv.pop()
unittest.main(verbosity=2)