/test/bugs/run.py
Python | 60 lines | 43 code | 5 blank | 12 comment | 5 complexity | 523a7f4b78ce7a0386061481c6600cf6 MD5 | raw file
1# 2# txt2tags fatal errors tester (http://txt2tags.org) 3# See also: ../run.py ../lib.py 4# 5# All these bugs are already fixed on the current version. 6# In older releases they dump an ugly Error Traceback. 7# 8# I think popen() don't work in some Windows, so these tests 9# may not work on it. 10# 11 12import os, sys, glob 13 14sys.path.insert(0, '..') 15import lib 16del sys.path[0] 17 18# sux 19lib.OK = lib.FAILED = 0 20lib.ERROR_FILES = [] 21 22def syscommand(cmd): 23 fd = os.popen(cmd) 24 output = [] 25 for line in fd.readlines(): 26 output.append(line.rstrip()) # stripping \s*\n 27 ret = fd.close() 28 if ret: ret = ret/256 # 16bit number 29 return ret, output 30 31def run(): 32 # test all .t2t files found 33 for infile in glob.glob("*.t2t"): 34 basename = infile.replace('.t2t', '') 35 outfile = basename + '.html' 36 print ' Testing %s ...' % basename, 37 cmdline = lib.TXT2TAGS + ' ' + infile 38 code, output = syscommand(cmdline) 39 if not output: 40 print "OK" 41 lib.OK = lib.OK + 1 42 os.remove(outfile) 43 else: 44 print "FAILED" 45 lib.FAILED = lib.FAILED + 1 46 continue 47 cmdline = lib.TXT2TAGSLITE + ' ' + infile 48 code, output = syscommand(cmdline) 49 if not output: 50 print "OK" 51 lib.OK = lib.OK + 1 52 os.remove(outfile) 53 else: 54 print "FAILED" 55 lib.FAILED = lib.FAILED + 1 56 continue 57 return lib.OK, lib.FAILED, lib.ERROR_FILES 58 59if __name__ == '__main__': 60 print lib.MSG_RUN_ALONE