From: Martyn Jago <martyn.jago@btinternet.com>
To: Eric Schulte <schulte.eric@gmail.com>
Cc: emacs-orgmode@gnu.org
Subject: Re: ob-lilypond
Date: Fri, 1 Jul 2011 14:43:28 +0100 [thread overview]
Message-ID: <D1F7C215-E4E5-4643-A6AE-4E3E70178C03@btinternet.com> (raw)
In-Reply-To: <87ei2b8a1z.fsf@gmail.com>
[-- Attachment #1: Type: text/plain, Size: 580 bytes --]
Hi
>
> That's good to hear. Are you up for trying to merge them into the rest
> of the Org-mode test suite? This should be as simple as placing any
> org-mode example files you have in
>
> org-mode/testing/examples/
>
> placing the .el file defining your tests into
>
> org-mode/testing/lisp/
>
> and renaming all of your tests so that they start with the prefix
> "ob-lilypond/"
>
> I fully understand if you don't have the time to do this, and I should
> be able to take a shot at it some time in the not-too-distant future.
Hopefully this patch will work for you...
[-- Attachment #2: port-test-ob-lilypond.patch --]
[-- Type: application/octet-stream, Size: 16197 bytes --]
diff --git a/lisp/ob-lilypond.el b/lisp/ob-lilypond.el
index 031eb8f..39aa78c 100644
--- a/lisp/ob-lilypond.el
+++ b/lisp/ob-lilypond.el
@@ -242,14 +242,15 @@ LINE is the erroneous line"
FILE-NAME is full path to lilypond file.
LINENO is the number of the erroneous line"
- (set-buffer (get-buffer-create "temp-buf"))
- (insert-file-contents (ly-switch-extension file-name ".ly")
- nil nil nil t)
- (if (> lineNo 0)
- (progn
- (goto-line lineNo)
- (buffer-substring (point) (point-at-eol)))
- nil))
+ (with-temp-buffer
+ (insert-file-contents (ly-switch-extension file-name ".ly")
+ nil nil nil t)
+ (if (> lineNo 0)
+ (progn
+ (goto-char (point-min))
+ (forward-line (- lineNo 1))
+ (buffer-substring (point) (point-at-eol)))
+ nil)))
(defun ly-attempt-to-open-pdf (file-name &optional test)
"Attempt to display the generated pdf file
diff --git a/testing/examples/ob-lilypond-broken.ly b/testing/examples/ob-lilypond-broken.ly
new file mode 100644
index 0000000..e836f6d
--- /dev/null
+++ b/testing/examples/ob-lilypond-broken.ly
@@ -0,0 +1,31 @@
+line 1
+line 2
+line 3
+line 4
+line 5
+line 6
+line 7
+line 8
+line 9
+line 10
+line 11
+line 12
+line 13
+line 14
+line 15
+line 16
+line 17
+line 18
+line 19
+line 20
+line 21
+line 22
+line 23
+line 24
+line 25
+line 26
+line 27
+line 28
+line 29
+line 30
+
diff --git a/testing/examples/ob-lilypond-broken.org b/testing/examples/ob-lilypond-broken.org
new file mode 100644
index 0000000..557418b
--- /dev/null
+++ b/testing/examples/ob-lilypond-broken.org
@@ -0,0 +1,39 @@
+* Faulty lilypond org file for test purposes (do not adjust)
+line 2
+line 3
+line 4
+line 5
+line 6
+line 7
+line 8
+line 9
+line 10
+line 11
+line 12
+line 13
+line 14
+line 15
+line 16
+line 17
+line 18
+line 19
+line 20
+line 21
+line 22
+line 23
+line 24
+line 25
+line 26
+line 27
+line 28
+line 29
+line 30
+line 31
+line 32
+line 33
+line 34
+line 35
+line 36
+line 37
+line 38
+line 39
diff --git a/testing/examples/ob-lilypond-test.error b/testing/examples/ob-lilypond-test.error
new file mode 100644
index 0000000..ceae291
--- /dev/null
+++ b/testing/examples/ob-lilypond-test.error
@@ -0,0 +1,15 @@
+Processing `xxx'
+Parsing...
+/path/to/tangled/file/test.ly:25:0: error: syntax error, unexpected \score, expecting '='
+
+\score {
+Interpreting music... [8][16][24][32]
+Preprocessing graphical objects...
+Interpreting music...
+MIDI output to `xxx'
+Finding the ideal number of pages...
+Fitting music on 2 or 3 pages...
+Drawing systems...
+Layout output to `xxx'
+Converting to `xxx'...
+error: failed files: "/Path/to/tangled/file/test.ly/example.ly"
diff --git a/testing/examples/ob-lilypond-test.ly b/testing/examples/ob-lilypond-test.ly
new file mode 100644
index 0000000..745600d
--- /dev/null
+++ b/testing/examples/ob-lilypond-test.ly
@@ -0,0 +1,30 @@
+
+% [[file:~/.emacs.d/martyn/martyn/ob-lilypond/test/test-build/test.org::*LilyPond%2520Version][LilyPond-Version:1]]
+
+\version "2.12.3"
+
+% LilyPond-Version:1 ends here
+
+% [[file:~/.emacs.d/martyn/martyn/ob-lilypond/test/test-build/test.org::*lilypond%2520block%2520for%2520test%2520purposes][lilypond-block-for-test-purposes:1]]
+
+\score {
+ \relative c' {
+ c8 d e f g a b c |
+ b a g f e d c4 |
+ }
+
+% lilypond-block-for-test-purposes:1 ends here
+
+% [[file:~/.emacs.d/martyn/martyn/ob-lilypond/test/test-build/test.org::*lilypond%2520block%2520for%2520test%2520purposes][lilypond-block-for-test-purposes:2]]
+
+\layout {
+ }
+ \midi {
+ \context {
+ \Score
+ tempoWholesPerMinute = #(ly:make-moment 150 4)
+ }
+ }
+}
+
+% lilypond-block-for-test-purposes:2 ends here
diff --git a/testing/examples/ob-lilypond-test.org b/testing/examples/ob-lilypond-test.org
new file mode 100644
index 0000000..cd8587a
--- /dev/null
+++ b/testing/examples/ob-lilypond-test.org
@@ -0,0 +1,37 @@
+* Test org lilypond file
+
+This is a simple file for test purposes
+
+** LilyPond Version
+
+#+begin_src lilypond
+
+\version "2.12.3"
+
+#+end_src
+
+** DONE lilypond block for test purposes
+
+#+begin_src lilypond
+
+ \score {
+ \relative c' {
+ c8 d e f g a b c |
+ b a g f e d c4 |
+ }
+
+#+end_src
+
+#+begin_src lilypond
+
+ \layout {
+ }
+ \midi {
+ \context {
+ \Score
+ tempoWholesPerMinute = #(ly:make-moment 150 4)
+ }
+ }
+ }
+
+#+end_src
diff --git a/testing/lisp/test-ob-lilypond.el b/testing/lisp/test-ob-lilypond.el
new file mode 100644
index 0000000..16d6f09
--- /dev/null
+++ b/testing/lisp/test-ob-lilypond.el
@@ -0,0 +1,323 @@
+(save-excursion
+ (set-buffer (get-buffer-create "test-ob-lilypond.el"))
+ (setq ly-here
+ (file-name-directory
+ (buffer-file-name
+ (current-buffer)))))
+
+(ert-deftest ob-lilypond/assert ()
+ (should t))
+
+(ert-deftest ob-lilypond/feature-provision ()
+ (should (featurep 'ob-lilypond)))
+
+(ert-deftest ob-lilypond/check-lilypond-alias ()
+ (should (fboundp 'lilypond-mode)))
+
+(ert-deftest ob-lilypond/org-babel-tangle-lang-exts ()
+ (let ((found nil)
+ (list org-babel-tangle-lang-exts))
+ (while list
+ (when (equal (car list) '("LilyPond" . "ly"))
+ (setq found t))
+ (setq list (cdr list)))
+ (should found)))
+
+(ert-deftest ob-lilypond/org-babel-prep-session:lilypond ()
+ (should-error (org-babel-prep-session:lilypond nil nil))
+ :type 'error)
+
+(ert-deftest ob-lilypond/ly-version-const ()
+ (should (boundp 'ly-version)))
+
+(ert-deftest ob-lilypond/ly-version-command ()
+ (should (equal "ob-lilypond version 0.2" (ly-version)))
+ (with-temp-buffer
+ (ly-version t)
+ (should (equal "ob-lilypond version 0.2"
+ (buffer-substring (point-min) (point-max))))))
+
+(ert-deftest ob-lilypond/ly-compile-lilyfile ()
+ (should (equal
+ `(,(ly-determine-ly-path) ;program
+ nil ;infile
+ "*lilypond*" ;buffer
+ t ;display
+ ,(if ly-gen-png "--png" "") ;&rest...
+ ,(if ly-gen-html "--html" "")
+ ,(if ly-use-eps "-dbackend=eps" "")
+ ,(if ly-gen-svg "-dbackend=svg" "")
+ "--output=test-file"
+ "test-file.ly")
+ (ly-compile-lilyfile "test-file.ly" t))))
+
+(ert-deftest ob-lilypond/ly-compile-post-tangle ()
+ (should (boundp 'ly-compile-post-tangle)))
+
+(ert-deftest ob-lilypond/ly-display-pdf-post-tangle ()
+ (should (boundp 'ly-display-pdf-post-tangle)))
+
+(ert-deftest ob-lilypond/ly-play-midi-post-tangle ()
+ (should (boundp 'ly-play-midi-post-tangle)))
+
+(ert-deftest ob-lilypond/ly-OSX-ly-path ()
+ (should (boundp 'ly-OSX-ly-path))
+ (should (stringp ly-OSX-ly-path)))
+
+(ert-deftest ob-lilypond/ly-OSX-pdf-path ()
+ (should (boundp 'ly-OSX-pdf-path))
+ (should (stringp ly-OSX-pdf-path)))
+
+(ert-deftest ob-lilypond/ly-OSX-midi-path ()
+ (should (boundp 'ly-OSX-midi-path))
+ (should (stringp ly-OSX-midi-path)))
+
+(ert-deftest ob-lilypond/ly-nix-ly-path ()
+ (should (boundp 'ly-nix-ly-path))
+ (should (stringp ly-nix-ly-path)))
+
+(ert-deftest ob-lilypond/ly-nix-pdf-path ()
+ (should (boundp 'ly-nix-pdf-path))
+ (should (stringp ly-nix-pdf-path)))
+
+(ert-deftest ob-lilypond/ly-nix-midi-path ()
+ (should (boundp 'ly-nix-midi-path))
+ (should (stringp ly-nix-midi-path)))
+
+(ert-deftest ob-lilypond/ly-win32-ly-path ()
+ (should (boundp 'ly-win32-ly-path))
+ (should (stringp ly-win32-ly-path)))
+
+(ert-deftest ob-lilypond/ly-win32-pdf-path ()
+ (should (boundp 'ly-win32-pdf-path))
+ (should (stringp ly-win32-pdf-path)))
+
+(ert-deftest ob-lilypond/ly-win32-midi-path ()
+ (should (boundp 'ly-win32-midi-path))
+ (should (stringp ly-win32-midi-path)))
+
+(ert-deftest ob-lilypond/ly-gen-png ()
+ (should (boundp 'ly-gen-png)))
+
+(ert-deftest ob-lilypond/ly-gen-svg ()
+ (should (boundp 'ly-gen-svg)))
+
+(ert-deftest ob-lilypond/ly-gen-html ()
+ (should (boundp 'ly-gen-html)))
+
+(ert-deftest ob-lilypond/use-eps ()
+ (should (boundp 'ly-use-eps)))
+
+(ert-deftest ob-lilypond/org-babel-default-header-args:lilypond ()
+ (should (equal '((:tangle . "yes")
+ (:noweb . "yes")
+ (:results . "silent")
+ (:comments . "yes"))
+ org-babel-default-header-args:lilypond)))
+
+;;TODO finish...
+(ert-deftest ob-lilypond/org-babel-expand-body:lilypond ()
+ (should (equal "This is a test"
+ (org-babel-expand-body:lilypond "This is a test" ()))))
+
+;;TODO (ert-deftest ly-test-org-babel-execute:lilypond ())
+(ert-deftest ob-lilypond/ly-check-for-compile-error ()
+ (set-buffer (get-buffer-create "*lilypond*"))
+ (erase-buffer)
+ (should (not (ly-check-for-compile-error nil t)))
+ (insert-file-contents (concat ly-here
+ "../examples/ob-lilypond-test.error")
+ nil nil nil t)
+ (goto-char (point-min))
+ (should (ly-check-for-compile-error nil t))
+ (kill-buffer "*lilypond*"))
+
+(ert-deftest ob-lilypond/ly-process-compile-error ()
+ (find-file-other-window (concat
+ ly-here
+ "../examples/ob-lilypond-broken.org"))
+ (set-buffer (get-buffer-create "*lilypond*"))
+ (insert-file-contents (concat
+ ly-here
+ "../examples/ob-lilypond-test.error")
+ nil nil nil t)
+ (goto-char (point-min))
+ (search-forward "error:" nil t)
+ (should-error
+ (ly-process-compile-error (concat
+ ly-here
+ "../examples/ob-lilypond-broken.ly"))
+ :type 'error)
+ (set-buffer "ob-lilypond-broken.org")
+ (should (equal 238 (point)))
+ (exchange-point-and-mark)
+ (should (equal (+ 238 (length "line 25")) (point)))
+ (kill-buffer "*lilypond*")
+ (kill-buffer "ob-lilypond-broken.org"))
+
+(ert-deftest ob-lilypond/ly-mark-error-line ()
+ (let ((file-name (concat
+ ly-here
+ "../examples/ob-lilypond-broken.org"))
+ (expected-point-min 198)
+ (expected-point-max 205)
+ (line "line 20"))
+ (find-file-other-window file-name)
+ (ly-mark-error-line file-name line)
+ (should (equal expected-point-min (point)))
+
+ (exchange-point-and-mark)
+ (should (= expected-point-max (point)))
+ (kill-buffer (file-name-nondirectory file-name))))
+
+(ert-deftest ob-lilypond/ly-parse-line-num ()
+ (with-temp-buffer
+ (insert-file-contents (concat
+ ly-here
+ "../examples/ob-lilypond-test.error")
+ nil nil nil t)
+ (goto-char (point-min))
+ (search-forward "error:")
+ (should (equal 25 (ly-parse-line-num (current-buffer))))))
+
+(ert-deftest ob-lilypond/ly-parse-error-line ()
+ (let ((ly-file (concat
+ ly-here
+ "../examples/ob-lilypond-broken.ly")))
+ (should (equal "line 20"
+ (ly-parse-error-line ly-file 20)))
+ (should (not (ly-parse-error-line ly-file 0)))))
+
+(ert-deftest ob-lilypond/ly-attempt-to-open-pdf ()
+ (let ((post-tangle ly-display-pdf-post-tangle)
+ (ly-file (concat
+ ly-here
+ "../examples/ob-lilypond-test.ly"))
+ (pdf-file (concat
+ ly-here
+ "../examples/ob-lilypond-test.pdf")))
+ (setq ly-open-pdf-post-tangle t)
+ (when (not (file-exists-p pdf-file))
+ (set-buffer (get-buffer-create (file-name-nondirectory pdf-file)))
+ (write-file pdf-file))
+ (should (equal
+ (concat
+ (ly-determine-pdf-path) " " pdf-file)
+ (ly-attempt-to-open-pdf ly-file t)))
+ (delete-file pdf-file)
+ (kill-buffer (file-name-nondirectory pdf-file))
+ (should (equal
+ "No pdf file generated so can't display!"
+ (ly-attempt-to-open-pdf pdf-file)))
+ (setq ly-display-pdf-post-tangle post-tangle)))
+
+(ert-deftest ob-lilypond/ly-attempt-to-play-midi ()
+ (let ((post-tangle ly-play-midi-post-tangle)
+ (ly-file (concat
+ ly-here
+ "../examples/ob-lilypond-test.ly"))
+ (midi-file (concat
+ ly-here
+ "../examples/ob-lilypond-test.midi")))
+ (setq ly-play-midi-post-tangle t)
+ (when (not (file-exists-p midi-file))
+ (set-buffer (get-buffer-create (file-name-nondirectory midi-file)))
+ (write-file midi-file))
+ (should (equal
+ (concat
+ (ly-determine-midi-path) " " midi-file)
+ (ly-attempt-to-play-midi ly-file t)))
+ (delete-file midi-file)
+ (kill-buffer (file-name-nondirectory midi-file))
+ (should (equal
+ "No midi file generated so can't play!"
+ (ly-attempt-to-play-midi midi-file)))
+ (setq ly-play-midi-post-tangle post-tangle)))
+
+(ert-deftest ob-lilypond/ly-determine-ly-path ()
+ (should (equal ly-OSX-ly-path
+ (ly-determine-ly-path "darwin")))
+ (should (equal ly-win32-ly-path
+ (ly-determine-ly-path "win32")))
+ (should (equal ly-nix-ly-path
+ (ly-determine-ly-path "nix"))))
+
+(ert-deftest ob-lilypond/ly-determine-pdf-path ()
+ (should (equal ly-OSX-pdf-path
+ (ly-determine-pdf-path "darwin")))
+ (should (equal ly-win32-pdf-path
+ (ly-determine-pdf-path "win32")))
+ (should (equal ly-nix-pdf-path
+ (ly-determine-pdf-path "nix"))))
+
+(ert-deftest ob-lilypond/ly-determine-midi-path ()
+ (should (equal ly-OSX-midi-path
+ (ly-determine-midi-path "darwin")))
+ (should (equal ly-win32-midi-path
+ (ly-determine-midi-path "win32")))
+ (should (equal ly-nix-midi-path
+ (ly-determine-midi-path "nix"))))
+
+(ert-deftest ob-lilypond/ly-toggle-midi-play-toggles-flag ()
+ (if ly-play-midi-post-tangle
+ (progn
+ (ly-toggle-midi-play)
+ (should (not ly-play-midi-post-tangle))
+ (ly-toggle-midi-play)
+ (should ly-play-midi-post-tangle))
+ (ly-toggle-midi-play)
+ (should ly-play-midi-post-tangle)
+ (ly-toggle-midi-play)
+ (should (not ly-play-midi-post-tangle))))
+
+(ert-deftest ob-lilypond/ly-toggle-pdf-display-toggles-flag ()
+ (if ly-display-pdf-post-tangle
+ (progn
+ (ly-toggle-pdf-display)
+ (should (not ly-display-pdf-post-tangle))
+ (ly-toggle-pdf-display)
+ (should ly-display-pdf-post-tangle))
+ (ly-toggle-pdf-display)
+ (should ly-display-pdf-post-tangle)
+ (ly-toggle-pdf-display)
+ (should (not ly-display-pdf-post-tangle))))
+
+(ert-deftest ob-lilypond/ly-toggle-png-generation-toggles-flag ()
+ (if ly-gen-png
+ (progn
+ (ly-toggle-png-generation)
+ (should (not ly-gen-png))
+ (ly-toggle-png-generation)
+ (should ly-gen-png))
+ (ly-toggle-png-generation)
+ (should ly-gen-png)
+ (ly-toggle-png-generation)
+ (should (not ly-gen-png))))
+
+(ert-deftest ob-lilypond/ly-toggle-html-generation-toggles-flag ()
+ (if ly-gen-html
+ (progn
+ (ly-toggle-html-generation)
+ (should (not ly-gen-html))
+ (ly-toggle-html-generation)
+ (should ly-gen-html))
+ (ly-toggle-html-generation)
+ (should ly-gen-html)
+ (ly-toggle-html-generation)
+ (should (not ly-gen-html))))
+
+(ert-deftest ob-lilypond/ly-switch-extension-with-extensions ()
+ (should (equal "test-name.xyz"
+ (ly-switch-extension "test-name" ".xyz")))
+ (should (equal "test-name.xyz"
+ (ly-switch-extension "test-name.abc" ".xyz")))
+ (should (equal "test-name"
+ (ly-switch-extension "test-name.abc" ""))))
+
+(ert-deftest ob-lilypond/ly-switch-extension-with-paths ()
+ (should (equal "/some/path/to/test-name.xyz"
+ (ly-switch-extension "/some/path/to/test-name" ".xyz"))))
+
+(provide 'test-ob-lilypond)
+
+;;; test-ob-lilypond.el ends here
[-- Attachment #3: Type: text/plain, Size: 560 bytes --]
It looks like noweb parsing has very recently become very brittle,
since it broke the noweb in my lilypond example.
This does not appear to be restricted to lilypond blocks.
The error is (wrong-type-argument consp nil)
I fixed for my songs by changing...
#+srcname: gen_arpeggio(key,root)
to...
#+srcname: gen_arpeggio (key,root)
and...
<<gen_arpeggio(key="c",root="c")>>
to...
<<gen_arpeggio (key="c",root="c")>>
I believe #+call: is affected too.
Unfortunately I won't be able to investigate further until next week.
Regards
Martyn
next prev parent reply other threads:[~2011-07-01 13:43 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-06-27 13:00 ob-lilypond Martyn Jago
2011-06-27 18:53 ` ob-lilypond Eric Schulte
2011-06-28 9:38 ` ob-lilypond Martyn Jago
2011-06-28 10:07 ` ob-lilypond Bastien
2011-06-28 10:21 ` ob-lilypond Bastien
2011-06-28 20:45 ` ob-lilypond Eric Schulte
2011-06-28 23:07 ` ob-lilypond Bastien
2011-06-29 0:41 ` ob-lilypond Eric Schulte
2011-06-29 17:07 ` ob-lilypond Martyn Jago
2011-06-29 21:15 ` ob-lilypond Eric Schulte
2011-06-30 6:38 ` ob-lilypond Martyn Jago
2011-06-30 18:10 ` ob-lilypond Eric Schulte
2011-07-01 12:01 ` ob-lilypond Christian Moe
2011-07-06 8:13 ` [BABEL][PATCH] ob-lilypond basic mode - was ob-lilypond Martyn Jago
2011-07-06 13:20 ` Eric Schulte
2011-07-01 13:43 ` Martyn Jago [this message]
2011-07-01 19:27 ` ob-lilypond Eric Schulte
2011-07-02 13:04 ` ob-lilypond Martyn Jago
2011-06-28 13:38 ` ob-lilypond Cameron Horsburgh
2011-06-28 16:46 ` ob-lilypond Martyn Jago
2011-06-28 12:11 ` ob-lilypond Christian Moe
2011-06-28 13:18 ` ob-lilypond David O'Toole
2011-06-28 17:06 ` ob-lilypond Martyn Jago
2011-06-28 18:51 ` ob-lilypond Christian Moe
2011-06-28 19:00 ` ob-lilypond Michael Brand
2011-06-28 20:00 ` ob-lilypond Christian Moe
2011-06-28 21:19 ` ob-lilypond Martyn Jago
-- strict thread matches above, loose matches on Subject: below --
2015-03-25 12:49 ob-lilypond pls
2015-03-26 9:20 ` ob-lilypond pls
2015-03-29 21:27 ` ob-lilypond Nick Dokos
2015-03-30 9:20 ` ob-lilypond Patrick L. Schmidt
2015-03-26 9:26 ob-lilypond Patrick L. Schmidt
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=D1F7C215-E4E5-4643-A6AE-4E3E70178C03@btinternet.com \
--to=martyn.jago@btinternet.com \
--cc=emacs-orgmode@gnu.org \
--cc=schulte.eric@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).