mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-09-20 06:49:56 +00:00
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.
This commit is contained in:
parent
889563984f
commit
981b9c69d1
@ -1,5 +1,5 @@
|
||||
#LyX file created by tex2lyx 2.1.0dev
|
||||
\lyxformat 453
|
||||
\lyxformat 456
|
||||
\begin_document
|
||||
\begin_header
|
||||
\textclass article
|
||||
|
@ -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})
|
||||
|
@ -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)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user