]> git.lyx.org Git - lyx.git/blobdiff - src/tex2lyx/test/runtests.py
Amend 26ea1e1 for roundtrip tests
[lyx.git] / src / tex2lyx / test / runtests.py
index b6f5e7ca4d35c700648e4b5cf262d0ea53258934..7c82909dedbedb5ea4908d6c44b350236d156022 100755 (executable)
@@ -15,6 +15,8 @@
 # suffix, since I don't know how to transport command line arguments through
 # the autotools "make check" mechanism.
 
+from __future__ import print_function
+
 import os, string, sys, time, difflib, filecmp, subprocess, re
 
 def usage(prog_name):
@@ -60,29 +62,32 @@ def main(argv):
     else:
         suffix = ""
     lyx = os.path.join(os.path.dirname(tex2lyx), "lyx" + suffix)
-    inputdir = os.path.dirname(argv[0])
+    inputdir = os.path.realpath(os.path.dirname(argv[0]))
     if len(argv) >= 4+skipcount:
-        outputdir = sys.argv[3+skipcount]
+        outputdir = os.path.realpath(sys.argv[3+skipcount])
     else:
 #        outputdir = inputdir
-        outputdir = os.path.join(os.path.dirname(tex2lyx), "test")
+        outputdir = os.path.realpath(os.path.join(os.path.dirname(tex2lyx), "test"))
 
     if len(argv) >= 5+skipcount:
         files = [sys.argv[4+skipcount]]
     else:
         files = ['test.ltx', \
+                 'algo2e.tex', \
+                 'beamer.tex', \
                  'box-color-size-space-align.tex', \
                  'CJK.tex', \
                  'CJKutf8.tex', \
                  'test-insets.tex', \
+                 'test-insets-basic.tex', \
                  'test-memoir.tex', \
+                 'test-minted.tex', \
                  'test-modules.tex', \
                  'test-refstyle-theorems.tex', \
                  'test-scr.tex', \
                  'test-structure.tex', \
                  'verbatim.tex', \
-                 'XeTeX-polyglossia.tex', \
-                 'algo2e.tex']
+                 'XeTeX-polyglossia.tex']
 
     errors = []
     overwrite = (outputdir == inputdir)
@@ -96,13 +101,13 @@ 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"
+        print('Executing: ' + cmd + "\n")
         proc = subprocess.Popen(cmd, shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
         proc.wait()
         err = proc.returncode
         errorstring = proc.stderr.read()
         if not errorstring is None:
-            print errorstring
+            print(errorstring)
         if err != 0:
             errors.append(f)
         elif not overwrite:
@@ -123,6 +128,12 @@ 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()
@@ -140,6 +151,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