+\begin_layout Subsection
+\begin_inset CommandInset label
+LatexCommand label
+name "subsec:New-layouts"
+
+\end_inset
+
+New layouts
+\end_layout
+
+\begin_layout Standard
+Adding a new layout file to the \SpecialChar LyX
+ library makes it an
+\begin_inset Quotes eld
+\end_inset
+
+officially supported
+\begin_inset Quotes erd
+\end_inset
+
+ layout.
+ You should therefore think carefully about whether you really want to do
+ this and discuss it on lyx-devel, since you will need to be prepared to
+ update and fix the layout if necessary.
+ If the layout is experimental or for a rarely used document class, then
+ it may be better to add it to the relevant portion of the \SpecialChar LyX
+ wiki, as a user
+ contribution.
+ See
+\begin_inset CommandInset href
+LatexCommand href
+target "https://wiki.lyx.org/Layouts/Layouts"
+
+\end_inset
+
+.
+\end_layout
+
+\begin_layout Standard
+In older versions of this document, it was stated that new layout files
+ require a file format change.
+ After some discussion it was decided that this is not needed.
+\begin_inset Foot
+status open
+
+\begin_layout Plain Layout
+See
+\begin_inset CommandInset href
+LatexCommand href
+name "the thread “Proposal for a guide on updating layouts”"
+target "http://permalink.gmane.org/gmane.editors.lyx.devel/161202"
+
+\end_inset
+
+.
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Quote
+For reference, here are the arguments on each side
+\end_layout
+
+\begin_deeper
+\begin_layout Description
+Pro
+\begin_inset Quotes eld
+\end_inset
+
+New layout files are a file format change
+\begin_inset Quotes erd
+\end_inset
+
+
+\end_layout
+
+\begin_layout Itemize
+All documents produced by 2.2.
+\begin_inset Formula $x$
+\end_inset
+
+ can always be edited and exported even if
+\begin_inset Formula $x$
+\end_inset
+
+ is different.
+ This is important for people using different machines, or exchanging work
+ with colleagues.
+\end_layout
+
+\begin_layout Description
+Con
+\begin_inset Quotes eld
+\end_inset
+
+New layout files are not a file format change
+\begin_inset Quotes erd
+\end_inset
+
+
+\end_layout
+
+\begin_layout Itemize
+No new LaTeX classes can be supported in a stable version, and stable versions
+ have a typical lifetime of 2–3 years.
+\end_layout
+
+\begin_layout Itemize
+We have the same situation already with custom layout files: If a document
+ using a custom layout file is moved between machines or people, then the
+ layout file needs to be exchanged as well.
+ If that is not done, then we have a fallback implemented so that such documents
+ can still be edited, but not exported, and the user gets a warning.
+
+\end_layout
+
+\begin_layout Itemize
+The lyx2lyx script cannot do anything useful in such a case.
+\end_layout
+
+\end_deeper
+\begin_layout Standard
+If you have decided that you are going to add a new layout file to \SpecialChar LyX
+ itself,
+ then, you should do the following:
+\end_layout
+
+\begin_layout Enumerate
+Put your new layout file in
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+lib/layouts/
+\end_layout
+
+\end_inset
+
+ and add it to Git (
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+git add lib/layouts/newlayout.layout
+\end_layout
+
+\end_inset
+
+) so that it will be committed.
+\end_layout
+
+\begin_layout Enumerate
+Add an entry in
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+lib/Makefile.am
+\end_layout
+
+\end_inset
+
+, so that the new layout actually gets installed.
+\end_layout
+
+\begin_layout Enumerate
+Add an entry in
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+lib/doc/LaTeXConfig.lyx
+\end_layout
+
+\end_inset
+
+ containing in particular a line like
+\end_layout
+
+\begin_deeper
+\begin_layout Quote
+Found: [InsetInfo]
+\end_layout
+
+\begin_layout Standard
+where [InsetInfo] is obtained by entering in the minibuffer (Alt+X)
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+info-insert textclass <name>
+\end_layout
+
+\end_inset
+
+.
+ This inset will automatically display a boxed
+\begin_inset Quotes eld
+\end_inset
+
+yes
+\begin_inset Quotes erd
+\end_inset
+
+ or
+\begin_inset Quotes eld
+\end_inset
+
+no
+\begin_inset Quotes erd
+\end_inset
+
+ depending on the availability of the package.
+\end_layout
+
+\end_deeper
+\begin_layout Enumerate
+A template or example is strongly encouraged (but not necessarily required).
+ It is also possible to provide both.
+ Add them to
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+lib/templates/
+\end_layout
+
+\end_inset
+
+ or
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+lib/examples/
+\end_layout
+
+\end_inset
+
+, respectively.
+\end_layout
+
+\begin_layout Enumerate
+Reconfigure \SpecialChar LyX
+.
+\end_layout
+
+\begin_layout Enumerate
+Ensure the autotests for the new layout pass (see
+\begin_inset CommandInset ref
+LatexCommand ref
+reference "par:when-to-run-an-export-test"
+
+\end_inset
+
+).
+\end_layout
+
+\begin_layout Subsection
+New modules
+\end_layout
+
+\begin_layout Standard
+Adding a new module is very similar to adding a new layout.
+ Therefore, the previous section applies to new modules as well, with two
+ exceptions:
+\end_layout
+
+\begin_layout Enumerate
+You only need to add an entry to
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+lib/doc/LaTeXConfig.lyx
+\end_layout
+
+\end_inset
+
+ if the module requires a LaTeX package.
+ In that case, the command for entering the InsetInfo is:
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+\paragraph_spacing single
+info-insert package <name>
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Enumerate
+Modules do not need a template, only an example, which is strongly encouraged
+ but not necessarily required.
+\end_layout
+
+\begin_layout Subsection
+Layouts for document classes with incompatible versions
+\end_layout
+
+\begin_layout Standard
+Every now and then, there are changes to LaTeX document classes that break
+ backwards compatibility.
+\begin_inset Foot
+status collapsed
+
+\begin_layout Plain Layout
+Uwe has suggested we implement automatic detection of changes in class files.
+ This could be done by running a script every month that checks if a document
+ class was changed at CTAN and at the homepages of the scientific journals.
+ If it reports a change, we can check if our template and layout file are
+ still usable with the changed document class.
+ (This is different from the autotests insofar, as this would also catch
+ changes that do not result in compilation errors.)
+\end_layout
+
+\end_inset
+
+ Reasons can be a new name for the
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+*.cls
+\end_layout
+
+\end_inset
+
+ file, removed \SpecialChar LaTeX
+ commands, or both.
+ How should this best be handled in \SpecialChar LyX
+?
+\end_layout
+
+\begin_layout Standard
+The idea is to support the new version with a new \SpecialChar LyX
+ layout so that:
+\end_layout
+
+\begin_layout Itemize
+Existing documents can still be opened in \SpecialChar LyX
+ and will continue to work on
+ systems where the old version is still installed.
+
+\end_layout
+
+\begin_layout Itemize
+With differently named
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+*.cls
+\end_layout
+
+\end_inset
+
+ files, \SpecialChar LyX
+ can check for the availability of the particular version and reflect
+ this in the GUI.
+ Different document class versions with the same file name are currently
+ (2.2.x) not detected by the configuration script.
+ This is planned for 2.3.
+\begin_inset Foot
+status collapsed
+
+\begin_layout Plain Layout
+https://www.mail-archive.com/lyx-devel@lists.lyx.org/msg192467.html
+\end_layout
+
+\begin_layout Plain Layout
+However, what we really need is version detection for the configuration,
+ so that the user can be warned if the required class file has the wrong
+ version.
+ (If the class file keeps the name over the version change, only one of
+ the two layout files generates compilable documents.)
+\end_layout
+
+\begin_layout Plain Layout
+This point was also made here: http://permalink.gmane.org/gmane.editors.lyx.devel/143
+798
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Itemize
+The new layout can be added both to the master and the stable branches,
+ in accord with the policy discussed in
+\begin_inset CommandInset ref
+LatexCommand formatted
+reference "subsec:New-layouts"
+
+\end_inset
+
+.
+ No lyx2lyx conversion is then required when a new major version is released.
+\end_layout
+
+\begin_layout Standard
+The user can move an existing document to the new version simply by selecting
+ a new document class.
+ This step is well supported by \SpecialChar LyX
+, with established methods for handling
+ unsupported styles and other changes.
+ This way, no lyx2lyx code is required.
+\end_layout
+
+\begin_layout Standard
+The steps to support a new version of an existing document class are thus:
+\end_layout
+
+\begin_layout Itemize
+Create a new layout file including the upstream version in the name (avoid
+ special characters like spaces and dots), e.g.
+
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+acmsiggraph-v0-92.layout
+\end_layout
+
+\end_inset
+
+.
+\end_layout
+
+\begin_layout Itemize
+Include the name of the
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+*.cls
+\end_layout
+
+\end_inset
+
+ file as an optional argument in the
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+
+\backslash
+DeclareLaTeXClass
+\end_layout
+
+\end_inset
+
+ line and include the version number in the GUI name:
+\begin_inset Newline newline
+\end_inset
+
+
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+
+\backslash
+DeclareLaTeXClass[acmsiggraph]{ACM SIGGGRAPH (v.
+\begin_inset space ~
+\end_inset
+
+0.92)}
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Itemize
+Update the GUI name in the old layout file (whose name should not be changed),
+ e.g.:
+\begin_inset Newline newline
+\end_inset
+
+
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+
+\backslash
+DeclareLaTeXClass{ACM SIGGRAPH (<= v.
+\begin_inset space ~
+\end_inset
+
+0.91, obsolete)}
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Itemize
+To avoid duplicate definitions, the new layout can
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+Input
+\end_layout
+
+\end_inset
+
+ the old layout file and add\SpecialChar breakableslash
+remove\SpecialChar breakableslash
+obsolete\SpecialChar breakableslash
+modify settings and styles (similar
+ to the inclusion of
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+*.inc
+\end_layout
+
+\end_inset
+
+ files).
+\end_layout
+
+\begin_deeper
+\begin_layout Standard
+It may be tempting to let the new layout be the
+\begin_inset Quotes eld
+\end_inset
+
+master version
+\begin_inset Quotes erd
+\end_inset
+
+ and have the old layout import it.
+ However, this should not be done because any changes to the new layout
+ would need undo steps in the importing old layout.
+\end_layout
+
+\end_deeper
+\begin_layout Itemize
+If the new LaTeX document class obsoletes the old one, update the example
+ and template files to use the new layout.
+ Add a note about the changes (preferably with a pointer to the documentation
+ of the changes).
+\end_layout
+
+\begin_deeper
+\begin_layout Standard
+This way, new documents based on the template or example will use the up-to-date
+ document class version.
+\end_layout
+
+\end_deeper
+\begin_layout Standard
+\begin_inset Newpage newpage
+\end_inset
+
+
+\end_layout
+
+\begin_layout Section
+Tests
+\end_layout
+
+\begin_layout Standard
+Automated tests are an important tool to detect bugs and regressions in
+ software development.
+ Some projects like gcc even require each bug fix to be accompanied by a
+ test case for the automatic test suite, that would detect this bug.
+ Testing interactive features automatically is of course very hard, but
+ core functionality like document import and export can be tested quite
+ easily, and some tests of this kind exist.
+\end_layout
+
+\begin_layout Subsection
+unit tests
+\end_layout
+
+\begin_layout Standard
+There are attempts to set up a suite of unit tests for LyX.
+\end_layout
+
+\begin_layout Standard
+TODO: describe what is done and what is still to do.
+\end_layout
+
+\begin_layout Subsection
+tex2lyx tests
+\end_layout
+
+\begin_layout Standard
+The tex2lyx tests are located in the
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+src/tex2lyx/test
+\end_layout
+
+\end_inset
+
+ subfolder of the \SpecialChar LyX
+ source code distribution.
+ The actual testing is performed by the simple python script
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+src/tex2lyx/test/runtests.py
+\end_layout
+
+\end_inset
+
+.
+ Each test consists of two files:
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+<test name>.tex
+\end_layout
+
+\end_inset
+
+ contains the \SpecialChar LaTeX
+ code that should be tested.
+
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+<test name>.lyx.lyx
+\end_layout
+
+\end_inset
+
+ contains the expected output of tex2lyx.
+ When a test is run, the actual produced output is compared with the stored
+ reference output.
+ The test passes if both are identical.
+ The test machinery is also able to generate a file
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+<test name>.lyx.tex
+\end_layout
+
+\end_inset
+
+ by exporting the produced .lyx file with \SpecialChar LyX
+ again.
+ This may be useful for roundtrip comparisons.
+\end_layout
+
+\begin_layout Subsubsection
+Running the tests
+\end_layout
+
+\begin_layout Standard
+The tex2lyx tests can be run in several ways.
+ When in the
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+src/tex2lyx
+\end_layout
+
+\end_inset
+
+ subfolder of the build directory, the commands
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+ctest
+\end_layout
+
+\end_inset
+
+ (cmake, all platforms),
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+make test
+\end_layout
+
+\end_inset
+
+ (cmake, when using a make based build system and not MSVC) or
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+make alltests
+\end_layout
+
+\end_inset
+
+ (autotools) will run the tex2lyx tests.
+ Alternatively, in the root of the build directory, the command
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+ctest -R tex2lyx
+\end_layout
+
+\end_inset
+
+ runs all tests whose names match the regex
+\begin_inset Quotes eld
+\end_inset
+
+tex2lyx
+\begin_inset Quotes erd
+\end_inset
+
+.
+ Another way to run the tex2lyx tests in the root build directory is to
+ instead use the command
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+ctest -L '(cmplyx|roundtrip)'
+\end_layout
+
+\end_inset
+
+, which runs all tests categorized with the label
+\begin_inset Quotes eld
+\end_inset
+
+roundtrip
+\begin_inset Quotes erd
+\end_inset
+
+ or
+\begin_inset Quotes eld
+\end_inset
+
+cmplyx
+\begin_inset Quotes erd
+\end_inset
+
+.
+ If a test fails, the differences between the expected and actual results
+ are output in unified diff format.
+\end_layout
+
+\begin_layout Subsubsection
+Updating test references
+\begin_inset CommandInset label
+LatexCommand label
+name "sec:Updating-test-references"
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Standard
+In some cases a changed tex2lyx output is not a test failure, but wanted,
+ e.
+\begin_inset space \thinspace{}
+\end_inset
+
+g.
+\begin_inset space \space{}
+\end_inset
+
+if a tex2lyx bug was fixed, or a new feature was added.
+ In these cases the stored references need to be updated.
+ To do so if using autotools, call
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+make updatetests
+\end_layout
+
+\end_inset
+
+ in the
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+src/tex2lyx
+\end_layout
+
+\end_inset
+
+ subdirectory of the build directory.
+ If instead using CMake, call
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+make updatetex2lyxtests
+\end_layout
+
+\end_inset
+
+ in the build directory or in the
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+src/tex2lyx/test
+\end_layout
+
+\end_inset
+
+ subdirectory of the build directory.
+\begin_inset Foot
+status collapsed
+
+\begin_layout Plain Layout
+Note that this is a case where a make target in the build directory can
+ affect the source directory, which might not be advisable.
+\end_layout
+
+\end_inset
+
+ On Windows do the following:
+\end_layout
+
+\begin_layout Itemize
+Assure that the path to the python.exe is in your system PATH variable.
+\end_layout
+
+\begin_layout Itemize
+Double-click on the file
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+updatetex2lyxtests.vcxproj
+\end_layout
+
+\end_inset
+
+ in the build directory or in the
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+src/tex2lyx/test
+\end_layout
+
+\end_inset
+
+ subdirectory of your build directory.
+\end_layout
+
+\begin_layout Itemize
+In the appearing MSVC program right-click on the project
+\family sans
+updatetex2lyxtests
+\family default
+ in the project explorer and chose
+\family sans
+Create
+\family default
+.
+\end_layout
+
+\begin_layout Standard