PageRenderTime 14ms CodeModel.GetById 10ms RepoModel.GetById 0ms app.codeStats 0ms

/test/bugs/run.py

http://txt2tags.googlecode.com/
Python | 60 lines | 43 code | 5 blank | 12 comment | 3 complexity | 523a7f4b78ce7a0386061481c6600cf6 MD5 | raw file
Possible License(s): GPL-2.0, GPL-3.0, WTFPL
  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. import os, sys, glob
  12. sys.path.insert(0, '..')
  13. import lib
  14. del sys.path[0]
  15. # sux
  16. lib.OK = lib.FAILED = 0
  17. lib.ERROR_FILES = []
  18. def syscommand(cmd):
  19. fd = os.popen(cmd)
  20. output = []
  21. for line in fd.readlines():
  22. output.append(line.rstrip()) # stripping \s*\n
  23. ret = fd.close()
  24. if ret: ret = ret/256 # 16bit number
  25. return ret, output
  26. def run():
  27. # test all .t2t files found
  28. for infile in glob.glob("*.t2t"):
  29. basename = infile.replace('.t2t', '')
  30. outfile = basename + '.html'
  31. print ' Testing %s ...' % basename,
  32. cmdline = lib.TXT2TAGS + ' ' + infile
  33. code, output = syscommand(cmdline)
  34. if not output:
  35. print "OK"
  36. lib.OK = lib.OK + 1
  37. os.remove(outfile)
  38. else:
  39. print "FAILED"
  40. lib.FAILED = lib.FAILED + 1
  41. continue
  42. cmdline = lib.TXT2TAGSLITE + ' ' + infile
  43. code, output = syscommand(cmdline)
  44. if not output:
  45. print "OK"
  46. lib.OK = lib.OK + 1
  47. os.remove(outfile)
  48. else:
  49. print "FAILED"
  50. lib.FAILED = lib.FAILED + 1
  51. continue
  52. return lib.OK, lib.FAILED, lib.ERROR_FILES
  53. if __name__ == '__main__':
  54. print lib.MSG_RUN_ALONE