Add very simple tex2lyx regression test suite.

It is invoked by 'make check' (automake only, it would be nice if someone
could add it to cmake as well), or by calling

python src/tex2lyx/test/runtests.py <path to tex2lyx binary>

by hand. Currently, it does not compare the output (this comes later).
The added .lyx files are from tex2lyx around mid of april, so that you
can see the regressions of the current version if you run the test
yourself (simply run git diff afterwards).

The home made test runner is quite stupid, but better than nothing.
Feel free to improve it or replace it with something better, as long
as running it stays as simple as now.
This commit is contained in:
Georg Baum 2012-07-08 19:28:19 +02:00
parent 57a8ea32c0
commit 1c0bd0132c
9 changed files with 11994 additions and 0 deletions

View File

@ -20,6 +20,7 @@ AM_CPPFLAGS += -DTEX2LYX $(PCH_FLAGS) -I$(top_srcdir)/src/tex2lyx \
-I$(top_srcdir)/src -I$(top_builddir) $(BOOST_INCLUDES)
TEST_FILES = \
test/runtests.py \
test/box-color-size-space-align.tex \
test/CJK.tex \
test/DummyDocument.tex \
@ -30,6 +31,8 @@ TEST_FILES = \
test/test-structure.tex \
test/XeTeX-polyglossia.tex
TESTS = test/runtests.py
LINKED_FILES = \
../Author.cpp \
../Color.cpp \

View File

@ -0,0 +1,712 @@
#LyX file created by tex2lyx 2.1.0svn
\lyxformat 430
\begin_document
\begin_header
\textclass article
\begin_preamble
\usepackage{CJK}\usepackage{babel}
% It is impossible to get the document language because the document could start with a command,
% whitespace, and English word or whatever and the rest is in Japanese. Checking for the first CJK
% environment is no solution because the document could be English and contain only some Japanese.
\end_preamble
\use_default_options false
\language english
\language_package default
\inputencoding utf8
\fontencoding T1
\font_roman default
\font_sans default
\font_typewriter default
\font_default_family default
\use_non_tex_fonts false
\font_sc false
\font_osf false
\font_sf_scale 100
\font_tt_scale 100
\graphics default
\paperfontsize default
\spacing single
\use_hyperref 0
\papersize default
\use_geometry false
\use_package amsmath 1
\use_package esint 1
\use_package mathdots 0
\use_package mathtools 0
\use_package mhchem 0
\use_package undertilde 0
\cite_engine basic
\cite_engine_type numerical
\biblio_style plain
\use_bibtopic false
\use_indices false
\paperorientation portrait
\suppress_date false
\justification true
\use_refstyle 0
\secnumdepth 3
\tocdepth 3
\paragraph_separation indent
\paragraph_indentation default
\quotes_language english
\papercolumns 1
\papersides 1
\paperpagestyle default
\tracking_changes false
\output_changes false
\html_math_output 0
\html_css_as_file 0
\html_be_strict false
\end_header
\begin_body
\begin_layout Standard
\begin_inset ERT
status collapsed
\begin_layout Standard
\backslash
begin{CJK}
\end_layout
\end_inset
\begin_inset ERT
status collapsed
\begin_layout Standard
{
\end_layout
\end_inset
EUC-JP
\begin_inset ERT
status collapsed
\begin_layout Standard
}
\end_layout
\end_inset
\begin_inset ERT
status collapsed
\begin_layout Standard
{}
\end_layout
\end_inset
Japanese
\begin_inset ERT
status collapsed
\begin_layout Standard
\backslash
end{CJK}
\end_layout
\end_inset
\begin_inset ERT
status collapsed
\begin_layout Standard
\backslash
begin{CJK}
\end_layout
\end_inset
\begin_inset ERT
status collapsed
\begin_layout Standard
{
\end_layout
\end_inset
UTF8
\begin_inset ERT
status collapsed
\begin_layout Standard
}
\end_layout
\end_inset
\begin_inset ERT
status collapsed
\begin_layout Standard
{}
\end_layout
\end_inset
Chinese traditional
\begin_inset ERT
status collapsed
\begin_layout Standard
\backslash
end{CJK}
\end_layout
\end_inset
\begin_inset ERT
status collapsed
\begin_layout Standard
\backslash
begin{CJK}
\end_layout
\end_inset
\begin_inset ERT
status collapsed
\begin_layout Standard
{
\end_layout
\end_inset
EUC-JP
\begin_inset ERT
status collapsed
\begin_layout Standard
}
\end_layout
\end_inset
\begin_inset ERT
status collapsed
\begin_layout Standard
{}
\end_layout
\end_inset
Japanese
\begin_inset ERT
status collapsed
\begin_layout Standard
\backslash
end{CJK}
\end_layout
\end_inset
hello
\begin_inset ERT
status collapsed
\begin_layout Standard
\backslash
begin{CJK}
\end_layout
\end_inset
\begin_inset ERT
status collapsed
\begin_layout Standard
{
\end_layout
\end_inset
GB
\begin_inset ERT
status collapsed
\begin_layout Standard
}
\end_layout
\end_inset
\begin_inset ERT
status collapsed
\begin_layout Standard
{}
\end_layout
\end_inset
Chinese simplified
\begin_inset ERT
status collapsed
\begin_layout Standard
\backslash
end{CJK}
\end_layout
\end_inset
\begin_inset ERT
status collapsed
\begin_layout Standard
\backslash
begin{CJK}
\end_layout
\end_inset
\begin_inset ERT
status collapsed
\begin_layout Standard
{
\end_layout
\end_inset
EUC-JP
\begin_inset ERT
status collapsed
\begin_layout Standard
}
\end_layout
\end_inset
\begin_inset ERT
status collapsed
\begin_layout Standard
{
\end_layout
\end_inset
hei
\begin_inset ERT
status collapsed
\begin_layout Standard
}
\end_layout
\end_inset
Japanese
\begin_inset ERT
status collapsed
\begin_layout Standard
\backslash
end{CJK}
\end_layout
\end_inset
\begin_inset ERT
status collapsed
\begin_layout Standard
\backslash
begin{CJK}
\end_layout
\end_inset
\begin_inset ERT
status collapsed
\begin_layout Standard
{
\end_layout
\end_inset
GB
\begin_inset ERT
status collapsed
\begin_layout Standard
}
\end_layout
\end_inset
\begin_inset ERT
status collapsed
\begin_layout Standard
{}
\end_layout
\end_inset
Chinese simplified
\begin_inset ERT
status collapsed
\begin_layout Standard
\backslash
end{CJK}
\end_layout
\end_inset
\end_layout
\begin_layout Standard
\begin_inset ERT
status collapsed
\begin_layout Standard
\backslash
begin{CJK}
\end_layout
\end_inset
\begin_inset ERT
status collapsed
\begin_layout Standard
{
\end_layout
\end_inset
Bg5
\begin_inset ERT
status collapsed
\begin_layout Standard
}
\end_layout
\end_inset
\begin_inset ERT
status collapsed
\begin_layout Standard
{}
\end_layout
\end_inset
Big5 文鼎楷書
\begin_inset ERT
status collapsed
\begin_layout Standard
\backslash
end{CJK}
\end_layout
\end_inset
\end_layout
\begin_layout Standard
\lang english
English
\end_layout
\begin_layout Standard
\begin_inset ERT
status collapsed
\begin_layout Standard
\backslash
begin{CJK}
\end_layout
\end_inset
\begin_inset ERT
status collapsed
\begin_layout Standard
{
\end_layout
\end_inset
SJIS
\begin_inset ERT
status collapsed
\begin_layout Standard
}
\end_layout
\end_inset
\begin_inset ERT
status collapsed
\begin_layout Standard
{}
\end_layout
\end_inset
ShiftJIS 日本語の文章
\begin_inset ERT
status collapsed
\begin_layout Standard
\backslash
end{CJK}
\end_layout
\end_inset
\end_layout
\begin_layout Standard
hello
\end_layout
\begin_layout Standard
\begin_inset ERT
status collapsed
\begin_layout Standard
\backslash
begin{CJK}
\end_layout
\end_inset
\begin_inset ERT
status collapsed
\begin_layout Standard
{
\end_layout
\end_inset
JIS
\begin_inset ERT
status collapsed
\begin_layout Standard
}
\end_layout
\end_inset
\begin_inset ERT
status collapsed
\begin_layout Standard
{}
\end_layout
\end_inset
JIS-code 
\begin_inset Formula $BF|K\8l$
\end_inset
NJ8>O(B
\begin_inset ERT
status collapsed
\begin_layout Standard
\backslash
end{CJK}
\end_layout
\end_inset
\end_layout
\begin_layout Standard
\begin_inset ERT
status collapsed
\begin_layout Standard
\backslash
begin{CJK}
\end_layout
\end_inset
\begin_inset ERT
status collapsed
\begin_layout Standard
{
\end_layout
\end_inset
KS
\begin_inset ERT
status collapsed
\begin_layout Standard
}
\end_layout
\end_inset
\begin_inset ERT
status collapsed
\begin_layout Standard
{}
\end_layout
\end_inset
Korean
\begin_inset ERT
status collapsed
\begin_layout Standard
\backslash
end{CJK}
\end_layout
\end_inset
\end_layout
\end_body
\end_document

View File

@ -0,0 +1,76 @@
#LyX file created by tex2lyx 2.1.0svn
\lyxformat 430
\begin_document
\begin_header
\textclass article
\use_default_options false
\language english
\language_package none
\inputencoding latin9
\fontencoding T1
\font_roman default
\font_sans default
\font_typewriter default
\font_default_family default
\use_non_tex_fonts false
\font_sc false
\font_osf false
\font_sf_scale 100
\font_tt_scale 100
\graphics default
\paperfontsize 12
\spacing onehalf
\use_hyperref 0
\papersize a4paper
\use_geometry false
\use_package amsmath 2
\use_package esint 1
\use_package mathdots 0
\use_package mathtools 0
\use_package mhchem 0
\use_package undertilde 0
\cite_engine natbib
\cite_engine_type numerical
\biblio_style plainnat
\use_bibtopic false
\use_indices true
\paperorientation portrait
\suppress_date false
\justification true
\use_refstyle 0
\secnumdepth 3
\tocdepth 3
\paragraph_separation indent
\paragraph_indentation 3mm
\quotes_language english
\papercolumns 1
\papersides 1
\paperpagestyle default
\tracking_changes false
\output_changes false
\html_math_output 0
\html_css_as_file 0
\html_be_strict false
\end_header
\begin_body
\begin_layout Subsection
\begin_inset CommandInset label
LatexCommand label
name "sub:External-Subsection"
\end_inset
External Subsection
\end_layout
\begin_layout Standard
This is a small dummy child document to show how files can be inserted to another document. Here are some accented characters to make sure the encoding is passed to included files: éè
\end_layout
\end_body
\end_document

View File

@ -0,0 +1,322 @@
#LyX file created by tex2lyx 2.1.0svn
\lyxformat 430
\begin_document
\begin_header
\textclass article
\begin_preamble
\usepackage{fontspec}\setmainfont[Mapping=tex-text]{Linux Libertine O}
\setsansfont[Mapping=tex-text,Scale=0.75]{Linux Biolinum O}
\setmonofont{Linux Biolinum O}
\usepackage{xunicode}\usepackage{polyglossia}\setdefaultlanguage[variant=british, ordinalmonthday = false]{english}
\setotherlanguage{albanian}
\setotherlanguage[variant=polytonic]{greek}
\setotherlanguage{hebrew}
\end_preamble
\use_default_options false
\language english
\language_package none
\inputencoding auto
\fontencoding default
\font_roman default
\font_sans default
\font_typewriter default
\font_default_family default
\use_non_tex_fonts true
\font_sc false
\font_osf false
\font_sf_scale 100
\font_tt_scale 100
\graphics default
\paperfontsize default
\spacing single
\use_hyperref 0
\papersize default
\use_geometry false
\use_package amsmath 1
\use_package esint 1
\use_package mathdots 0
\use_package mathtools 0
\use_package mhchem 0
\use_package undertilde 0
\cite_engine basic
\cite_engine_type numerical
\biblio_style plain
\use_bibtopic false
\use_indices false
\paperorientation portrait
\suppress_date false
\justification true
\use_refstyle 0
\secnumdepth 3
\tocdepth 3
\paragraph_separation indent
\paragraph_indentation default
\quotes_language english
\papercolumns 1
\papersides 1
\paperpagestyle default
\tracking_changes false
\output_changes false
\html_math_output 0
\html_css_as_file 0
\html_be_strict false
\end_header
\begin_body
\begin_layout Part
df
\end_layout
\begin_layout Standard
1 English
\begin_inset ERT
status collapsed
\begin_layout Standard
\backslash
textgreek
\end_layout
\end_inset
[variant=ancient]
\begin_inset ERT
status collapsed
\begin_layout Standard
{
\end_layout
\end_inset
ancient Greek
\begin_inset ERT
status collapsed
\begin_layout Standard
}
\end_layout
\end_inset
English
\begin_inset ERT
status collapsed
\begin_layout Standard
\backslash
textgreek
\end_layout
\end_inset
[numerals=arabic, variant=ancient]
\begin_inset ERT
status collapsed
\begin_layout Standard
{
\end_layout
\end_inset
ancient G
\family sans
reek
\family default
with Arabic numerals
\begin_inset ERT
status collapsed
\begin_layout Standard
}
\end_layout
\end_inset
English
\end_layout
\begin_layout Standard
\begin_inset ERT
status collapsed
\begin_layout Standard
\backslash
begin{albanian}
\end_layout
\end_inset
\end_layout
\begin_layout Part
df
\end_layout
\begin_layout Standard
2 Albanian
\begin_inset ERT
status collapsed
\begin_layout Standard
\backslash
textgreek
\end_layout
\end_inset
\begin_inset ERT
status collapsed
\begin_layout Standard
{
\end_layout
\end_inset
Greek
\begin_inset ERT
status collapsed
\begin_layout Standard
}
\end_layout
\end_inset
Albanian
\shape smallcaps
smallcaps
\shape default
\end_layout
\begin_layout Standard
\begin_inset ERT
status collapsed
\begin_layout Standard
\backslash
end{albanian}
\end_layout
\end_inset
\begin_inset ERT
status collapsed
\begin_layout Standard
\backslash
begin{hebrew}
\end_layout
\end_inset
\end_layout
\begin_layout Part
df
\end_layout
\begin_layout Standard
3 Hebrew
\end_layout
\begin_layout Standard
\begin_inset ERT
status collapsed
\begin_layout Standard
\backslash
end{hebrew}
\end_layout
\end_inset
\begin_inset ERT
status collapsed
\begin_layout Standard
%empty language paragraph
\end_layout
\begin_layout Standard
\end_layout
\end_inset
\begin_inset ERT
status collapsed
\begin_layout Standard
\backslash
begin{albanian}
\end_layout
\end_inset
\begin_inset ERT
status collapsed
\begin_layout Standard
\backslash
end{albanian}
\end_layout
\end_inset
\end_layout
\end_body
\end_document

File diff suppressed because it is too large Load Diff

48
src/tex2lyx/test/runtests.py Executable file
View File

@ -0,0 +1,48 @@
#! /usr/bin/env python
# -*- coding: utf-8 -*-
# file src/tex2lyx/test/runtests.py
# This file is part of LyX, the document processor.
# Licence details can be found in the file COPYING.
# author Georg Baum
# Full author contact details are available in file CREDITS
# This script reads a unicode symbol file and completes it in the given range
import os, string, sys
def usage(prog_name):
return "Usage: %s [<tex2lyx binary>]" % prog_name
def main(argv):
# Parse and manipulate the command line arguments.
sys.path.append(os.path.join(os.path.dirname(sys.argv[0]), '../../../lib/scripts'))
from lyxpreview_tools import error
if len(argv) == 1:
tex2lyx = './tex2lyx'
elif len(argv) == 2:
tex2lyx = argv[1]
else:
error(usage(argv[0]))
basedir = os.path.dirname(argv[0])
files = ['test.ltx', 'test-structure.tex', 'test-insets.tex', \
'box-color-size-space-align.tex', 'CJK.tex', \
'XeTeX-polyglossia.tex']
for f in files:
texfile = os.path.join(os.path.dirname(argv[0]), f)
cmd = '%s -roundtrip -f %s' % (tex2lyx, texfile)
if os.system(cmd) != 0:
error('Running `%s´ failed.' % cmd)
if __name__ == "__main__":
main(sys.argv)

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,536 @@
#LyX file created by tex2lyx 2.1.0svn
\lyxformat 430
\begin_document
\begin_header
\textclass article
\begin_preamble
% This is a test document for tex2lyx
%some comments
%comments
\def\blah{\blahblah}
% And more comments
%more comments
\end_preamble
\use_default_options false
\language english
\language_package none
\inputencoding auto
\fontencoding default
\font_roman default
\font_sans default
\font_typewriter default
\font_default_family default
\use_non_tex_fonts false
\font_sc false
\font_osf false
\font_sf_scale 100
\font_tt_scale 100
\graphics default
\paperfontsize 11
\spacing single
\use_hyperref 0
\papersize default
\use_geometry false
\use_package amsmath 1
\use_package esint 1
\use_package mathdots 0
\use_package mathtools 0
\use_package mhchem 0
\use_package undertilde 0
\cite_engine basic
\cite_engine_type numerical
\biblio_style plain
\use_bibtopic false
\use_indices false
\paperorientation portrait
\suppress_date false
\justification true
\use_refstyle 0
\secnumdepth 3
\tocdepth 3
\paragraph_separation indent
\paragraph_indentation default
\quotes_language english
\papercolumns 1
\papersides 1
\paperpagestyle default
\tracking_changes false
\output_changes false
\html_math_output 0
\html_css_as_file 0
\html_be_strict false
\end_header
\begin_body
\begin_layout Title
Test Document
\end_layout
\begin_layout Standard
\begin_inset CommandInset toc
LatexCommand tableofcontents
\end_inset
\end_layout
\begin_layout Section
First Section
\end_layout
\begin_layout Standard
This
\size large
a
\size small
b
\size tiny
c
\size large
\size huge
d
\size default
is some text.
\begin_inset ERT
status collapsed
\begin_layout Standard
%Midline comment
\end_layout
\begin_layout Standard
\end_layout
\end_inset
\begin_inset Box Boxed
position "c"
hor_pos "c"
has_inner_box 0
inner_pos "c"
use_parbox 0
use_makebox 0
width "3in"
special "none"
height "1in"
height_special "totalheight"
status open
\begin_layout Standard
What are you doing \SpecialChar \ldots{}
Dave
\end_layout
\end_inset
. This is more text.
\end_layout
\begin_layout Section*
MySection
\end_layout
\begin_layout Standard
\begin_inset CommandInset label
LatexCommand label
name "sec:mysection"
\end_inset
This is some
\begin_inset Quotes eld
\end_inset
quoted
\begin_inset Quotes erd
\end_inset
text in a new section. I
\begin_inset ERT
status collapsed
\begin_layout Standard
{
\end_layout
\end_inset
\begin_inset ERT
status collapsed
\begin_layout Standard
\backslash
em
\end_layout
\end_inset
am
\begin_inset Foot
status collapsed
\begin_layout Standard
This is a great footnote because:
\end_layout
\begin_layout Itemize
The footnote is not
\emph on
emphasized
\emph default
.
\end_layout
\begin_layout Itemize
The text is
\end_layout
\begin_layout Standard
How cool is that!?
\end_layout
\end_inset
emphasizing
\begin_inset Quotes eld
\end_inset
text.
\end_layout
\begin_layout Standard
I keep
\begin_inset Quotes erd
\end_inset
emphasizing
\begin_inset ERT
status collapsed
\begin_layout Standard
}
\end_layout
\end_inset
. This
\begin_inset space ~
\end_inset
is text in a new par\SpecialChar \-
agraph.
\begin_inset Newline newline
\end_inset
It has \SpecialChar \ldots{}
an
\begin_inset Formula $ \alpha $
\end_inset
in it, which is OK\SpecialChar \@.
I can type special characters
\begin_inset Foot
status collapsed
\begin_layout Standard
i.e., characters which must be escaped
\end_layout
\end_inset
like & and #.
\end_layout
\begin_layout Standard
_ is a neat token.
\begin_inset ERT
status collapsed
\begin_layout Standard
% This line won't print!
\end_layout
\begin_layout Standard
\end_layout
\end_inset
\end_layout
\begin_layout Standard
Now I
\family sans
want
\family typewriter
to
\family sans
write
\family default
some math in a displayed equation.
\begin_inset Formula \begin{eqnarray*}
q^{(i)}_O & = & q^{water}_{O}+dq_{O}\times (P_{deg}^{(i-1)}-P_{deg}^{(i)})\\
q_{H}^{(i)} & = & q^{water}_{H}+dq_{H}\times (P_{deg}^{(i-1)}-P_{deg}^{(i)})\\
q_{p}^{(i)} & = & q^{water}_{H}+dq_{H}\times (P_{deg}^{(i-1)}-P^{(i+1)}_{deg})
\end{eqnarray*}
\end_inset
\end_layout
\begin_layout Standard
Here's an itemized list
\end_layout
\begin_layout Itemize
this is an item
\end_layout
\begin_deeper
\begin_layout Enumerate
this is a numbered item
\end_layout
\begin_deeper
\begin_layout Standard
But now I want to write some text.
\end_layout
\end_deeper
\begin_layout Enumerate
this is another numbered item
\end_layout
\begin_deeper
\begin_layout Standard
More text
\end_layout
\end_deeper
\end_deeper
\begin_deeper
\begin_layout Standard
Yet more text
\end_layout
\end_deeper
\begin_layout Itemize
this is another unnumbered item
\end_layout
\begin_deeper
\begin_layout Standard
Final text
\end_layout
\end_deeper
\begin_layout Section
\begin_inset Argument
status collapsed
\begin_layout Standard
hi
\end_layout
\end_inset
New Section
\end_layout
\begin_layout Standard
Here's a
\begin_inset ERT
status collapsed
\begin_layout Standard
{
\end_layout
\end_inset
\begin_inset ERT
status collapsed
\begin_layout Standard
\backslash
em
\end_layout
\end_inset
quotation:
\end_layout
\begin_layout Quotation
Hello there how are you?
\end_layout
\begin_layout Quotation
I am fine. Thanks
\end_layout
\begin_layout Standard
This
\begin_inset ERT
status collapsed
\begin_layout Standard
}
\end_layout
\end_inset
is a reference to section
\begin_inset CommandInset ref
LatexCommand ref
reference "sec:mysection"
\end_inset
on page
\begin_inset CommandInset ref
LatexCommand pageref
reference "sec:mysection"
\end_inset
.
\end_layout
\begin_layout Standard
\begin_inset Tabular
<lyxtabular version="3" rows="2" columns="2">
<features rotate="0" tabularvalignment="middle" tabularwidth="0pt">
<column alignment="left" valignment="top">
<column alignment="left" valignment="top">
<row>
<cell alignment="left" valignment="top" usebox="none">
\begin_inset Text
\begin_layout Standard
foo
\end_layout
\end_inset
</cell>
<cell alignment="left" valignment="top" usebox="none">
\begin_inset Text
\begin_layout Standard
bar
\end_layout
\end_inset
</cell>
</row>
<row>
<cell alignment="left" valignment="top" usebox="none">
\begin_inset Text
\begin_layout Standard
bar
\end_layout
\end_inset
</cell>
<cell alignment="left" valignment="top" usebox="none">
\begin_inset Text
\begin_layout Standard
foo
\end_layout
\end_inset
</cell>
</row>
</lyxtabular>
\end_inset
\end_layout
\begin_layout Standard
Let's try a few unicode characters: the (R) symbol ®(and the same one with braces ® and a space after) or maybe an accented a á or this one á or this î.
\end_layout
\begin_layout Standard
Watch out: ®should be glued to its successor here.
\end_layout
\begin_layout Standard
Final Text.
\end_layout
\end_body
\end_document