/test/target/run.py

http://txt2tags.googlecode.com/ · Python · 44 lines · 28 code · 9 blank · 7 comment · 6 complexity · cb295747aebab60fab8c88ce3e4dbda1 MD5 · raw file

  1. #
  2. # txt2tags target code 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. all_targets = 'aap aapw aas aasw aat aatw adoc bbcode creole dbk doku gwiki html html5 htmls lout man md mgp moin pm6 pmw csv csvs ods red rst rtf sgml spip tex texs txt txt2t wiki xhtml xhtmls'.split()
  13. tableable = 'aat aatw aas aasw aap aapw creole doku gwiki html html5 htmls man md moin pmw csv csvs ods red rst rtf sgml spip tex texs wiki xhtml xhtmls'.split()
  14. def run():
  15. # test all .t2t files found
  16. for infile in glob.glob("*.t2t"):
  17. basename = infile.replace('.t2t', '')
  18. # Choose targets
  19. targets = all_targets
  20. if basename == 'table':
  21. targets = tableable
  22. for target in targets:
  23. outfile = basename + '.' + target
  24. testname = '%s in %s' % (basename, target)
  25. if lib.initTest(testname, infile, outfile):
  26. cmdline = []
  27. cmdline.extend(['-i', infile])
  28. cmdline.extend(['-t', target])
  29. if target == 'aap':
  30. cmdline.extend(['--width', '80'])
  31. lib.convert(cmdline)
  32. lib.diff(outfile)
  33. return lib.OK, lib.FAILED, lib.ERROR_FILES
  34. if __name__ == '__main__':
  35. print lib.MSG_RUN_ALONE