From: Reinhold Kainhofer Date: Thu, 24 Jun 2010 10:00:03 +0000 (+0200) Subject: MusicXML test suite: use custom py formatter for MusicXML files X-Git-Tag: release/2.15.9-1~9^2~42 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=cfcb9efdbd7c6600fc89fc912ba80529010b31e7;p=lilypond.git MusicXML test suite: use custom py formatter for MusicXML files Use the .xml (and .mxl) files in collated-files rather than the converted .ly ones. In the future, I want to change the layout of each test case to also include renderings from other applications and maybe some other information. --- diff --git a/input/regression/musicxml/GNUmakefile b/input/regression/musicxml/GNUmakefile index b343d88b6f..101abd10c4 100644 --- a/input/regression/musicxml/GNUmakefile +++ b/input/regression/musicxml/GNUmakefile @@ -7,17 +7,18 @@ EXTRA_DIST_FILES = LICENSE TEXI2HTML_FLAGS += --nomenu -# Urgh, how can I do two replacements at once without messing up the order of the list? -TMP = $(sort $(MUSICXML_FILES) $(MUSICMXL_FILES) $(TEXINFO_SOURCES) ) -TMP1 = ${TMP:%.xml=$(outdir)/%.ly} -COLLATED_FILES = ${TMP1:%.mxl=$(outdir)/%.ly} +COLLATED_FILES = $(sort $(MUSICXML_FILES) $(MUSICMXL_FILES) $(TEXINFO_SOURCES) ) include $(depth)/make/stepmake.make TITLE=Unofficial MusicXML test suite +AUTHOR=Reinhold Kainhofer TEST_SUITE_VERSION=0.1 +LILYPOND_BOOK_FLAGS += --load-custom-package=book-musicxml-testsuite.py +# This breaks since *.tex and *.texi still contains ac/lily-xxxxxx references! +#LILYPOND_BOOK_FLAGS += --use-source-file-names ifeq ($(out),www) local-WWW-2: zip diff --git a/input/regression/musicxml/book-musicxml-testsuite.py b/input/regression/musicxml/book-musicxml-testsuite.py new file mode 100644 index 0000000000..a292db5489 --- /dev/null +++ b/input/regression/musicxml/book-musicxml-testsuite.py @@ -0,0 +1,64 @@ +# -*- coding: utf-8 -*- + +import book_base as BookBase +import book_texinfo as BookTexinfo +import book_snippets as BookSnippet +import lilylib as ly + +MusicXMLOutputImage = r'''@noindent +@ifinfo +@image{%(info_image_path)s,,,%(alt)s,%(ext)s} +@end ifinfo +@html +

+ + %(alt)s + +

+@end html +''' + +MusicXMLOutput = r''' +@iftex +@include %(base)s-systems.texi +@end iftex +''' + +MusicXMLPrintFilename = r''' +@html + +@end html +@file{%(filename)s} +@html + +@end html +''' + + + + +class BookMusicXML (BookTexinfo.BookTexinfoOutputFormat): + def __init__ (self): + BookTexinfo.BookTexinfoOutputFormat.__init__ (self) + self.format = "MusicXMLTest" + self.output[BookBase.OUTPUTIMAGE] = MusicXMLOutputImage + self.output[BookBase.OUTPUT] = MusicXMLOutput + self.output[BookBase.PRINTFILENAME] = MusicXMLPrintFilename + def snippet_class (self, type): + if type == "musicxml_file": + return MusicXMLTestSuiteSnippet + else: + return BookSnippet.snippet_type_to_class.get (type, BookSnippet.Snippet) + def snippet_output (self, basename, snippet): + return BookTexinfo.BookTexinfoOutputFormat.snippet_output (self, basename, snippet) + + +class MusicXMLTestSuiteSnippet (BookSnippet.MusicXMLFileSnippet): + def __init__ (self, type, match, formatter, line_number, global_options): + BookSnippet.MusicXMLFileSnippet.__init__ (self, type, match, formatter, line_number, global_options) + +## TODO: Customize output with renderings from other MusicXML-supporting +# applications. Also add some link to the intermediate .ly file + + +BookBase.register_format (BookMusicXML ()); diff --git a/scripts/build/lys-to-tely.py b/scripts/build/lys-to-tely.py index c4e387547b..4b2e232053 100644 --- a/scripts/build/lys-to-tely.py +++ b/scripts/build/lys-to-tely.py @@ -92,7 +92,7 @@ for opt in options: texi_file_re = re.compile ('.*\.i?te(ly|xi)$') html_file_re = re.compile ('.*\.i?htm(l)?$') -xml_file_re = re.compile ('.*\.i?xml$') +xml_file_re = re.compile ('.*\.i?(xm|mx)l$') tex_file_re = re.compile ('.*\.i?(la)?tex$') pdf_file_re = re.compile ('.*\.i?pdf$') @@ -101,7 +101,7 @@ def name2line (n): # We have a texi include file, simply include it: s = r"@include %s" % os.path.basename (n) elif (html_file_re.match (n) or pdf_file_re.match (n) or - xml_file_re.match (n) or tex_file_re.match (n)): + tex_file_re.match (n)): s = r""" @ifhtml @html @@ -110,7 +110,19 @@ def name2line (n): @end html @end ifhtml """ % (os.path.basename (n), os.path.basename (n)) - return s + + elif (xml_file_re.match (n)): + # Assume it's a MusicXML file -> convert, create image etc. + s = r""" +@ifhtml +@html + +@end html +@end ifhtml + +@musicxmlfile[%s]{%s} +""" % (os.path.basename (n), fragment_options, n) + else: # Assume it's a lilypond file -> create image etc. s = r"""