PageRenderTime 22ms CodeModel.GetById 16ms app.highlight 4ms RepoModel.GetById 1ms app.codeStats 0ms

/test/gotchas/run.py

http://txt2tags.googlecode.com/
Python | 38 lines | 28 code | 4 blank | 6 comment | 2 complexity | 18e775deff858059f8f6966526928cd8 MD5 | raw file
 1#
 2# txt2tags marks gotchas tester (http://txt2tags.org)
 3# See also: ../run.py ../lib.py
 4#
 5
 6import os, sys, re, glob
 7
 8sys.path.insert(0, '..')
 9import lib
10del sys.path[0]
11
12# sux
13lib.OK = lib.FAILED = 0
14lib.ERROR_FILES = []
15
16def run():
17    # test all OK files found
18    for outfile in glob.glob("ok/*"):
19        basename = re.sub('\..*?$', '', outfile.replace('ok/', ''))
20        target = re.sub('.*\.', '', outfile)
21        infile = basename + ".t2t"
22        outfile = outfile.replace('ok/', '')
23        if lib.initTest(basename, infile, outfile):
24            cmdline = ['-H']
25            cmdline.extend(['-t', target])
26            cmdline.append(infile)
27            lib.convert(cmdline)
28            lib.diff(outfile)
29            lib.convert(cmdline, True)
30            lib.diff(outfile)
31    # clean up
32    if os.path.isfile(lib.CONFIG_FILE):
33        os.remove(lib.CONFIG_FILE)
34    
35    return lib.OK, lib.FAILED, lib.ERROR_FILES
36
37if __name__ == '__main__':
38    print lib.MSG_RUN_ALONE