]> git.lyx.org Git - lyx.git/blobdiff - src/tex2lyx/test/runtests.py
tex2lyx: Add a newline at the end of comment if not at the end of a paragraph.
[lyx.git] / src / tex2lyx / test / runtests.py
index 57cd0e195c04879e2eb2748e0d5a44497cc043b6..c2c7c3050e9b98430e2ead0391783e26fda9a9d9 100755 (executable)
@@ -20,14 +20,15 @@ import os, string, sys, time, difflib, filecmp, subprocess, re
 def usage(prog_name):
   return "Usage: %s [uselyx2lyx] [<tex2lyx binary> [[<script dir>] [[<output dir>] [testfile]]]]" % prog_name
 
-pat_fl = re.compile(r'^#LyX file created by tex2lyx .*$')
+pat_fl1 = re.compile(r'^#LyX file created by tex2lyx .*$')
+pat_fl2 = re.compile(r'^#LyX \d+\.\d+ created this file.*$')
 
 def compareLyx(lines1, lines2):
     if lines1[1:] != lines2[1:]:
         return False
-    if not pat_fl.match(lines1[0]):
+    if not pat_fl1.match(lines1[0]) and not pat_fl2.match(lines1[0]):
         return False
-    if not pat_fl.match(lines2[0]):
+    if not pat_fl1.match(lines2[0]) and not pat_fl2.match(lines2[0]):
         return False
     return True
 
@@ -70,12 +71,16 @@ def main(argv):
         files = [sys.argv[4+skipcount]]
     else:
         files = ['test.ltx', \
+                 'algo2e.tex', \
                  'box-color-size-space-align.tex', \
                  'CJK.tex', \
                  'CJKutf8.tex', \
                  'test-insets.tex', \
+                 'test-insets-basic.tex', \
+                 'test-memoir.tex', \
                  'test-modules.tex', \
                  'test-refstyle-theorems.tex', \
+                 'test-scr.tex', \
                  'test-structure.tex', \
                  'verbatim.tex', \
                  'XeTeX-polyglossia.tex']
@@ -92,6 +97,7 @@ def main(argv):
         else:
             lyxfile = os.path.join(outputdir, base + ".lyx")
             cmd = '%s -roundtrip -copyfiles -f %s %s' % (tex2lyx, texfile, lyxfile)
+        print 'Executing: ' + cmd + "\n"
         proc = subprocess.Popen(cmd, shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
         proc.wait()
         err = proc.returncode
@@ -118,10 +124,16 @@ def main(argv):
                     f1 = open(lyxfile1, 'r')
                     f2 = open(lyxfile2, 'r')
                     lines1 = f1.readlines()
+                    i1 = 0
+                    for linex in lines1:
+                      if linex[:-1] == '\origin ' + inputdir + '/':
+                        lines1[i1] = '\origin ' + outputdir + '/' + "\n"
+                        break
+                      i1 = i1+1
                     lines2 = f2.readlines()
                     f1.close()
                     f2.close()
-                    # ignore the first line i.e., the version of lyx
+                    # ignore the first line e.g. the version of lyx
                     if not compareLyx(lines1, lines2):
                         diff = difflib.unified_diff(lines1, lines2, lyxfile1, lyxfile2, t1, t2)
                         sys.stdout.writelines(diff)
@@ -135,6 +147,7 @@ def getlyxinput(lyx, lyxfx, lyxf, uselyx2lyx):
     if uselyx2lyx:
         cmd = '%s -E lyx %s %s' % (lyx, lyxf, lyxfx)
         sys.stdout.writelines(cmd)
+        sys.stdout.writelines("\n")
         if os.system(cmd) != 0:
             return None
         return lyxf