forked from naftaliharris/markovian
-
Notifications
You must be signed in to change notification settings - Fork 0
/
runtests.py
executable file
·45 lines (35 loc) · 1.42 KB
/
runtests.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
#!/usr/bin/python
# runtests.py
# runs all the tests on Markovian
import unittest
import sh
class TestMarkovian(unittest.TestCase):
def test_units(self):
"""Run the C unittests"""
sh.make("unittest")
run = sh.Command("./unittest")
run() # will throw an exception upon nonzero exit code
def test_search(self):
"""Make sure aspiration search is the same as ordinary search
Uses random fens as values, so not guaranteed to produce the same
output when run multiple times"""
lines = str(sh.rl("test/data/fenio.fens", "--count=10")).rstrip('\n')
sh.make("aspire_search")
run = sh.Command("./aspire_search")
aspire_output = str(run(sh.echo(lines)))
sh.make("no_aspire_search")
run = sh.Command("./no_aspire_search")
no_aspire_output = str(run(sh.echo(lines)))
for fen_orig, fen1, fen2 in zip(lines.split('\n'),
aspire_output.split('\n'),
no_aspire_output.split('\n')):
self.assertEquals(fen1, fen2, "Original fen: '%s'" % fen_orig)
def test_compilation(self):
"""Make sure all binaries compile"""
for target in ["xboard", "debug", "profile", "cache-hits"]:
sh.make(target)
sh.make("clean")
def tearDown(self):
sh.make("clean")
if __name__ == "__main__":
unittest.main()