]> git.donarmstrong.com Git - lilypond.git/commitdiff
MusicXML test suite: use custom py formatter for MusicXML files
authorReinhold Kainhofer <reinhold@kainhofer.com>
Thu, 24 Jun 2010 10:00:03 +0000 (12:00 +0200)
committerReinhold Kainhofer <reinhold@kainhofer.com>
Thu, 18 Aug 2011 20:29:19 +0000 (22:29 +0200)
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.

input/regression/musicxml/GNUmakefile
input/regression/musicxml/book-musicxml-testsuite.py [new file with mode: 0644]
scripts/build/lys-to-tely.py

index b343d88b6fb1372f7bdea8a056b5149ce8927751..101abd10c444149e7f05891ec006d54f459be951 100644 (file)
@@ -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 (file)
index 0000000..a292db5
--- /dev/null
@@ -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
+<p>
+ <a href="%(base)s%(ext)s">
+  <img align="middle" border="0" src="%(image)s" alt="%(alt)s">
+ </a>
+</p>
+@end html
+'''
+
+MusicXMLOutput = r'''
+@iftex
+@include %(base)s-systems.texi
+@end iftex
+'''
+
+MusicXMLPrintFilename = r'''
+@html
+<a href="%(base)s%(ext)s">
+@end html
+@file{%(filename)s}
+@html
+</a>
+@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 ());
index c4e387547b18563b5fe6ba81e4f05fbf90e61129..4b2e232053e8b6504f6f923df6d39ecabc10bbe9 100644 (file)
@@ -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
+<a name="%s"></a>
+@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"""