From: Kornel Benko Date: Sun, 27 Dec 2015 13:33:11 +0000 (+0100) Subject: Cmake export tests: Add structue test for exported lyx files X-Git-Tag: 2.2.0beta1~307 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=d0d45d4043f1f67c73d034112d4e98a8a7cbf5c3;p=features.git Cmake export tests: Add structue test for exported lyx files We test here, if any \end_{somethig} matches \begin_{something}. Exeptions are \end_index and \end_branch ATM, they should match \index and \branch respectively. Also added new testfile. --- diff --git a/autotests/export/MissingEndLayoutBetweenTables.lyx b/autotests/export/MissingEndLayoutBetweenTables.lyx new file mode 100644 index 0000000000..bd81c3f9a7 --- /dev/null +++ b/autotests/export/MissingEndLayoutBetweenTables.lyx @@ -0,0 +1,302 @@ +#LyX 2.2 created this file. For more info see http://www.lyx.org/ +\lyxformat 503 +\begin_document +\begin_header +\origin unavailable +\textclass scrbook +\options bibliography=totoc,index=totoc,BCOR7.5mm,titlepage,captions=tableheading,usenames,dvipsnames,table +\use_default_options false +\begin_modules +initials +graphicboxes +\end_modules +\maintain_unincluded_children false +\language english +\language_package default +\inputencoding auto +\fontencoding global +\font_roman "lmodern" "default" +\font_sans "lmss" "default" +\font_typewriter "lmtt" "default" +\font_math "auto" "auto" +\font_default_family default +\use_non_tex_fonts false +\font_sc false +\font_osf false +\font_sf_scale 100 100 +\font_tt_scale 100 100 +\graphics default +\default_output_format default +\output_sync 0 +\bibtex_command default +\index_command default +\paperfontsize 12 +\spacing single +\use_hyperref true +\pdf_title "LyX's Figure, Table, Floats, Notes, and Boxes manual" +\pdf_author "LyX Team, Uwe Stöhr" +\pdf_subject "LyX-documentation about figures, tables, floats, notes, and boxes" +\pdf_keywords "LyX, Tables, Figures, Floats, Boxes, Notes" +\pdf_bookmarks true +\pdf_bookmarksnumbered true +\pdf_bookmarksopen true +\pdf_bookmarksopenlevel 1 +\pdf_breaklinks false +\pdf_pdfborder false +\pdf_colorlinks true +\pdf_backref false +\pdf_pdfusetitle false +\pdf_quoted_options "linkcolor=black, citecolor=black, urlcolor=blue, filecolor=blue, pdfpagelayout=OneColumn, pdfnewwindow=true, pdfstartview=XYZ, plainpages=false" +\papersize default +\use_geometry false +\use_package amsmath 2 +\use_package amssymb 2 +\use_package cancel 0 +\use_package esint 0 +\use_package mathdots 1 +\use_package mathtools 0 +\use_package mhchem 1 +\use_package stackrel 0 +\use_package stmaryrd 0 +\use_package undertilde 0 +\cite_engine basic +\cite_engine_type default +\biblio_style plain +\use_bibtopic false +\use_indices false +\paperorientation portrait +\suppress_date false +\justification true +\use_refstyle 0 +\notefontcolor #0000ff +\index Index +\shortcut idx +\color #008000 +\end_index +\secnumdepth 3 +\tocdepth 3 +\paragraph_separation skip +\defskip medskip +\quotes_language english +\papercolumns 1 +\papersides 2 +\paperpagestyle default +\tracking_changes false +\html_math_output 0 +\html_css_as_file 0 +\output_changes false +\html_be_strict false +\end_header + +\begin_body + +\begin_layout Title +Stripped down Embedded objects +\end_layout + +\begin_layout Standard +The table-wide vertical alignment is used for tables within text lines: +\begin_inset Newline newline +\end_inset + +A line with tables with different alignments: +\begin_inset Tabular + + + + + + +\begin_inset Text + +\begin_layout Plain Layout + +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout + +\family roman +\series medium +\shape up +\size normal +\emph off +\bar no +\noun off +\color none +xy1 +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Plain Layout + +\family roman +\series medium +\shape up +\size normal +\emph off +\bar no +\noun off +\color none +A +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout + +\end_layout + +\end_inset + + + + +\end_inset + + +\begin_inset Tabular + + + + + + +\begin_inset Text + +\begin_layout Plain Layout + +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +xy2 +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Plain Layout + +\family roman +\series medium +\shape up +\size normal +\emph off +\bar no +\noun off +\color none +A +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout + +\end_layout + +\end_inset + + + + +\end_inset + + +\begin_inset Tabular + + + + + + +\begin_inset Text + +\begin_layout Plain Layout + +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +xy3 +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Plain Layout + +\family roman +\series medium +\shape up +\size normal +\emph off +\bar no +\noun off +\color none +A +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout + +\end_layout + +\end_inset + + + + +\end_inset + + +\begin_inset Newline newline +\end_inset + + +\end_layout + +\begin_layout Standard +Problem occurs between the tables, missing +\backslash +end_layout +\end_layout + +\end_body +\end_document diff --git a/development/autotests/beginEndStructureCheck.pl b/development/autotests/beginEndStructureCheck.pl new file mode 100755 index 0000000000..437f52453e --- /dev/null +++ b/development/autotests/beginEndStructureCheck.pl @@ -0,0 +1,41 @@ +#! /usr/bin/env perl +# -*- mode: perl; -*- + +use strict; + +my @stack = (); +my $depth = 0; +my $input = $ARGV[0]; +my $line = 0; +if (open(FI, $input)) { + while (my $l = ) { + chomp($l); + $line++; + if ($l =~ /^\s*\\begin_([a-z]+)/) { + $stack[$depth] = $1; + $depth++; + } + elsif ($l =~ /^\s*\\(index|branch)\s/) { + # does not start with e.g. \begin_index, but ends with \end_index!! + $stack[$depth] = $1; + $depth++; + } + elsif ($l =~ /^\s*\\end_([a-z]+)/) { + my $expect = $1; + if ($depth > 0) { + if ($stack[$depth-1] eq $expect) { + $depth--; + } + else { + print "expected \\end_$stack[$depth-1], got \\end_$expect instead at $input:$line\n"; + exit(-1); + } + } + else { + print "got \\end_$expect, but depth is already 0 at $input:$line\n"; + exit(-2); + } + } + } +} +exit(0); diff --git a/development/autotests/export.cmake b/development/autotests/export.cmake index d894282ece..f90fa09f74 100755 --- a/development/autotests/export.cmake +++ b/development/autotests/export.cmake @@ -28,6 +28,7 @@ # set(Perl_Script "${TOP_SRC_DIR}/development/autotests/useSystemFonts.pl") +set(Structure_Script "${TOP_SRC_DIR}/development/autotests/beginEndStructureCheck.pl") set(LanguageFile "${TOP_SRC_DIR}/lib/languages") set(GetTempDir "${TOP_SRC_DIR}/development/autotests/getTempDir.pl") set(_ft ${fonttype}) @@ -78,9 +79,15 @@ if (NOT _err) set(ENV{${LYX_USERDIR_VER}} "${LYX_TESTS_USERDIR}") set(ENV{LANG} "en") # to get all error-messages in english execute_process( - COMMAND ${lyx} -batch -userdir "${LYX_TESTS_USERDIR}" ${result_file_name} + COMMAND ${PERL_EXECUTABLE} ${Structure_Script} "${WORKDIR}/${result_file_name}" RESULT_VARIABLE _err ERROR_VARIABLE lyxerr) + if (NOT _err) + execute_process( + COMMAND ${lyx} -batch -userdir "${LYX_TESTS_USERDIR}" ${result_file_name} + RESULT_VARIABLE _err + ERROR_VARIABLE lyxerr) + endif() if (NOT _err) CheckLoadErrors(lyxerr "${TOP_SRC_DIR}/development/autotests" _err) endif()