]> git.lyx.org Git - lyx.git/blobdiff - src/tex2lyx/test/runtests.py
update tex2lyx tests after file format change
[lyx.git] / src / tex2lyx / test / runtests.py
index 8d053acd1f6f28a79ff344bf88e5e0372d0c2087..0cebef0dabdab583b7c8cfff0fa057c6f3183acb 100755 (executable)
@@ -1,4 +1,4 @@
-#! /usr/bin/env python
+#! /usr/bin/python3
 # -*- coding: utf-8 -*-
 
 # file src/tex2lyx/test/runtests.py
@@ -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,28 +62,33 @@ 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', \
+                'tabular-x-test.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)
@@ -95,13 +102,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:
@@ -122,6 +129,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()
@@ -139,6 +152,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
@@ -147,4 +161,3 @@ def getlyxinput(lyx, lyxfx, lyxf, uselyx2lyx):
 
 if __name__ == "__main__":
     main(sys.argv)
-