43 lines
1.6 KiB
Python
Executable File
43 lines
1.6 KiB
Python
Executable File
#!/usr/bin/python3
|
|
import unittest, subprocess, filecmp, argparse, os.path, os, shutil
|
|
|
|
REFERENCE_DIR = os.path.join(os.path.abspath(os.path.dirname(__file__)), "tests")
|
|
|
|
REGEXES_DATA = [ #TODO
|
|
[r"[a-zA-Z0-9]*"]
|
|
]
|
|
|
|
def make_test(regexes, idx):
|
|
def test(self):
|
|
p = subprocess.Popen([os.path.join(args.builddir, "src", "Lexesis-test"), "test_%s" % idx, data_dir], stdin=subprocess.PIPE)
|
|
p.communicate(bytes("\n".join(regexes), "utf-8"))
|
|
self.assertEqual(0, p.returncode)
|
|
|
|
self.assertTrue(filecmp.cmp(os.path.join(REFERENCE_DIR, "test_%s.re" % idx), os.path.join(data_dir, "test_%s.re" % idx)))
|
|
self.assertTrue(filecmp.cmp(os.path.join(REFERENCE_DIR, "test_%s.enfa" % idx), os.path.join(data_dir, "test_%s.enfa" % idx)))
|
|
self.assertTrue(filecmp.cmp(os.path.join(REFERENCE_DIR, "test_%s.mssc" % idx), os.path.join(data_dir, "test_%s.mssc" % idx)))
|
|
self.assertTrue(filecmp.cmp(os.path.join(REFERENCE_DIR, "test_%s.min" % idx), os.path.join(data_dir, "test_%s.min" % idx)))
|
|
|
|
return test
|
|
|
|
class Tests(unittest.TestCase):
|
|
pass
|
|
|
|
if __name__ == "__main__":
|
|
parser = argparse.ArgumentParser()
|
|
parser.add_argument("--builddir", metavar="builddir", default=os.path.join(os.path.abspath(os.path.dirname(__file__)), "build"), required=False)
|
|
args = parser.parse_args()
|
|
|
|
data_dir = os.path.join(args.builddir, "test_data")
|
|
try:
|
|
shutil.rmtree(data_dir)
|
|
except Exception as err:
|
|
pass
|
|
os.mkdir(data_dir)
|
|
|
|
for i, regexes in enumerate(REGEXES_DATA):
|
|
t = make_test(regexes, i)
|
|
setattr(Tests, "test_%s" % i, t)
|
|
|
|
unittest.main()
|