/test/gotchas/run.py

http://txt2tags.googlecode.com/ · Python · 38 lines · 25 code · 6 blank · 7 comment · 4 complexity · 18e775deff858059f8f6966526928cd8 MD5 · raw file

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