The branch, master, has been updated.

- Log -----------------------------------------------------------------

commit 981b9c69d173b1e746efd0233792eeada8556ed4
Author: Kornel Benko <[email protected]>
Date:   Fri Dec 28 16:22:25 2012 +0100

    1.) Add format to CJK.lyx.lyx(missed in previous commit)
    2.) Add lyx2lyx test to runtests.py. This is done with extra parameter only,
      and does not change the behaviour without this parameter.

diff --git a/src/tex2lyx/test/CJK.lyx.lyx b/src/tex2lyx/test/CJK.lyx.lyx
index ef1b7fb..6ebad1a 100644
--- a/src/tex2lyx/test/CJK.lyx.lyx
+++ b/src/tex2lyx/test/CJK.lyx.lyx
@@ -1,5 +1,5 @@
 #LyX file created by tex2lyx 2.1.0dev
-\lyxformat 453
+\lyxformat 456
 \begin_document
 \begin_header
 \textclass article
diff --git a/src/tex2lyx/test/CMakeLists.txt b/src/tex2lyx/test/CMakeLists.txt
index 4994641..36be360 100644
--- a/src/tex2lyx/test/CMakeLists.txt
+++ b/src/tex2lyx/test/CMakeLists.txt
@@ -23,6 +23,13 @@ foreach(_fl ${_tex_tests})
     "${TOP_SRC_DIR}/lib/scripts"
     "${CMAKE_CURRENT_BINARY_DIR}"
     ${fl})
+  add_test(NAME tex2lyx2lyx/roundtrip/${_fl}
+    WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
+    COMMAND ${LYX_PYTHON_EXECUTABLE} 
"${TOP_SRC_DIR}/src/tex2lyx/test/runtests.py" "uselyx2lyx"
+    "$<TARGET_FILE:${_tex2lyx}>"
+    "${TOP_SRC_DIR}/lib/scripts"
+    "${CMAKE_CURRENT_BINARY_DIR}"
+    ${fl})
 endforeach()
 
 add_dependencies(lyx_run_tests ${_tex2lyx} ${_lyx})
diff --git a/src/tex2lyx/test/runtests.py b/src/tex2lyx/test/runtests.py
index 406a96e..bfa4c2a 100755
--- a/src/tex2lyx/test/runtests.py
+++ b/src/tex2lyx/test/runtests.py
@@ -18,35 +18,41 @@
 import os, string, sys, time, difflib, filecmp, subprocess, re
 
 def usage(prog_name):
-  return "Usage: %s [<tex2lyx binary> [[<script dir>] [[<output dir>] 
[testfile]]]]" % prog_name
+  return "Usage: %s [uselyx2lyx] [<tex2lyx binary> [[<script dir>] [[<output 
dir>] [testfile]]]]" % prog_name
 
 
 def main(argv):
     # Parse and manipulate the command line arguments.
-    if len(argv) >= 3:
-       sys.path.append(os.path.join(sys.argv[2]))
+    skipcount = 0
+    uselyx2lyx = False
+    if len(argv) > 1:
+        if argv[1] == "uselyx2lyx":
+            uselyx2lyx = True
+            skipcount = 1
+    if len(argv) >= 3+skipcount:
+       sys.path.append(os.path.join(sys.argv[2+skipcount]))
     else:
        sys.path.append(os.path.join(os.path.dirname(sys.argv[0]), 
'../../../lib/scripts'))
 
     from lyxpreview_tools import error
 
-    if len(argv) < 2:
+    if len(argv) < 2+skipcount:
         tex2lyx = './tex2lyx'
-    elif len(argv) <= 5:
-        tex2lyx = argv[1]
+    elif len(argv) <= 5+skipcount:
+        tex2lyx = argv[1+skipcount]
     else:
         error(usage(argv[0]))
 
     lyx = os.path.join(os.path.dirname(tex2lyx), "lyx")
     inputdir = os.path.dirname(argv[0])
-    if len(argv) >= 4:
-        outputdir = sys.argv[3]
+    if len(argv) >= 4+skipcount:
+        outputdir = sys.argv[3+skipcount]
     else:
 #        outputdir = inputdir
         outputdir = os.path.join(os.path.dirname(tex2lyx), "test")
 
-    if len(argv) >= 5:
-        files = [sys.argv[4]]
+    if len(argv) >= 5+skipcount:
+        files = [sys.argv[4+skipcount]]
     else:
         files = ['test.ltx', 'test-structure.tex', 'test-insets.tex', \
              'test-modules.tex', 'box-color-size-space-align.tex', \
@@ -63,7 +69,7 @@ def main(argv):
             cmd = '%s -roundtrip -f %s' % (tex2lyx, texfile)
         else:
             lyxfile = os.path.join(outputdir, base + ".lyx")
-            cmd = '%s -copyfiles -f %s %s' % (tex2lyx, texfile, lyxfile)
+            cmd = '%s -roundtrip -copyfiles -f %s %s' % (tex2lyx, texfile, 
lyxfile)
         proc = subprocess.Popen(cmd, shell=True, stdin=subprocess.PIPE, 
stdout=subprocess.PIPE, stderr=subprocess.PIPE, close_fds=True)
         proc.wait()
         err = proc.returncode
@@ -73,24 +79,43 @@ def main(argv):
         if err != 0:
             errors.append(f)
         elif not overwrite:
-            lyxfile1 = os.path.join(inputdir, base + ".lyx.lyx")
-            lyxfile2 = os.path.join(outputdir, base + ".lyx")
-            if not filecmp.cmp(lyxfile1, lyxfile2, False):
-                t1 = time.ctime(os.path.getmtime(lyxfile1))
-                t2 = time.ctime(os.path.getmtime(lyxfile2))
-                f1 = open(lyxfile1, 'r')
-                f2 = open(lyxfile2, 'r')
-                lines1 = f1.readlines()
-                lines2 = f2.readlines()
-                diff = difflib.unified_diff(lines1, lines2, lyxfile1, 
lyxfile2, t1, t2)
-                f1.close()
-                f2.close()
-                sys.stdout.writelines(diff)
+            lyxfile1 = getlyxinput(lyx,
+                        os.path.join(inputdir, base + ".lyx.lyx"),
+                        os.path.join(outputdir, base + ".lyx1.lyx") , 
uselyx2lyx)
+            if lyxfile1 is None:
                 errors.append(f)
+            else:
+                lyxfile2 = getlyxinput(lyx,
+                          os.path.join(outputdir, base + ".lyx"),
+                          os.path.join(outputdir, base + ".lyx2.lyx"), 
uselyx2lyx)
+                if lyxfile2 is None:
+                    errors.append(f)
+                elif not filecmp.cmp(lyxfile1, lyxfile2, False):
+                    t1 = time.ctime(os.path.getmtime(lyxfile1))
+                    t2 = time.ctime(os.path.getmtime(lyxfile2))
+                    f1 = open(lyxfile1, 'r')
+                    f2 = open(lyxfile2, 'r')
+                    lines1 = f1.readlines()
+                    lines2 = f2.readlines()
+                    diff = difflib.unified_diff(lines1, lines2, lyxfile1, 
lyxfile2, t1, t2)
+                    f1.close()
+                    f2.close()
+                    sys.stdout.writelines(diff)
+                    errors.append(f)
 
     if len(errors) > 0:
         error('Converting the following files failed: %s' % ', '.join(errors))
 
+def getlyxinput(lyx, lyxfx, lyxf, uselyx2lyx):
+    if uselyx2lyx:
+        cmd = '%s -E lyx %s %s' % (lyx, lyxf, lyxfx)
+        sys.stdout.writelines(cmd)
+        if os.system(cmd) != 0:
+            return None
+        return lyxf
+    else:
+        return lyxfx
+
 if __name__ == "__main__":
     main(sys.argv)
 

commit 889563984f6615ef02c84b0cbaa6dda6f58ba19c
Author: Kornel Benko <[email protected]>
Date:   Fri Dec 28 16:19:34 2012 +0100

    Adapt format to test files

diff --git a/src/tex2lyx/test/XeTeX-polyglossia.lyx.lyx 
b/src/tex2lyx/test/XeTeX-polyglossia.lyx.lyx
index c39ac11..23bf90d 100644
--- a/src/tex2lyx/test/XeTeX-polyglossia.lyx.lyx
+++ b/src/tex2lyx/test/XeTeX-polyglossia.lyx.lyx
@@ -1,5 +1,5 @@
 #LyX file created by tex2lyx 2.1.0dev
-\lyxformat 453
+\lyxformat 456
 \begin_document
 \begin_header
 \textclass article
diff --git a/src/tex2lyx/test/box-color-size-space-align.lyx.lyx 
b/src/tex2lyx/test/box-color-size-space-align.lyx.lyx
index a855321..0ddc59d 100644
--- a/src/tex2lyx/test/box-color-size-space-align.lyx.lyx
+++ b/src/tex2lyx/test/box-color-size-space-align.lyx.lyx
@@ -1,5 +1,5 @@
 #LyX file created by tex2lyx 2.1.0dev
-\lyxformat 453
+\lyxformat 456
 \begin_document
 \begin_header
 \textclass article
diff --git a/src/tex2lyx/test/test-insets.lyx.lyx 
b/src/tex2lyx/test/test-insets.lyx.lyx
index df09a02..7b1b4c9 100644
--- a/src/tex2lyx/test/test-insets.lyx.lyx
+++ b/src/tex2lyx/test/test-insets.lyx.lyx
@@ -1,5 +1,5 @@
 #LyX file created by tex2lyx 2.1.0dev
-\lyxformat 453
+\lyxformat 456
 \begin_document
 \begin_header
 \textclass article
diff --git a/src/tex2lyx/test/test-modules.lyx.lyx 
b/src/tex2lyx/test/test-modules.lyx.lyx
index fcdaa1f..226102c 100644
--- a/src/tex2lyx/test/test-modules.lyx.lyx
+++ b/src/tex2lyx/test/test-modules.lyx.lyx
@@ -1,5 +1,5 @@
 #LyX file created by tex2lyx 2.1.0dev
-\lyxformat 453
+\lyxformat 456
 \begin_document
 \begin_header
 \textclass amsart
diff --git a/src/tex2lyx/test/test-structure.lyx.lyx 
b/src/tex2lyx/test/test-structure.lyx.lyx
index 1c83fc3..ea9ddab 100644
--- a/src/tex2lyx/test/test-structure.lyx.lyx
+++ b/src/tex2lyx/test/test-structure.lyx.lyx
@@ -1,5 +1,5 @@
 #LyX file created by tex2lyx 2.1.0dev
-\lyxformat 453
+\lyxformat 456
 \begin_document
 \begin_header
 \textclass article
diff --git a/src/tex2lyx/test/test.lyx.lyx b/src/tex2lyx/test/test.lyx.lyx
index 9bf19cb..ba14fab 100644
--- a/src/tex2lyx/test/test.lyx.lyx
+++ b/src/tex2lyx/test/test.lyx.lyx
@@ -1,5 +1,5 @@
 #LyX file created by tex2lyx 2.1.0dev
-\lyxformat 453
+\lyxformat 456
 \begin_document
 \begin_header
 \textclass article

-----------------------------------------------------------------------

Summary of changes:
 src/tex2lyx/test/CJK.lyx.lyx                       |    2 +-
 src/tex2lyx/test/CMakeLists.txt                    |    7 ++
 src/tex2lyx/test/XeTeX-polyglossia.lyx.lyx         |    2 +-
 .../test/box-color-size-space-align.lyx.lyx        |    2 +-
 src/tex2lyx/test/runtests.py                       |   73 +++++++++++++-------
 src/tex2lyx/test/test-insets.lyx.lyx               |    2 +-
 src/tex2lyx/test/test-modules.lyx.lyx              |    2 +-
 src/tex2lyx/test/test-structure.lyx.lyx            |    2 +-
 src/tex2lyx/test/test.lyx.lyx                      |    2 +-
 9 files changed, 63 insertions(+), 31 deletions(-)


hooks/post-receive
-- 
The LyX Source Repository

Reply via email to