]> git.donarmstrong.com Git - lilypond.git/commit
Fix 1477: Add (ly:expect-warning msg args) to suppress expected warnings
authorReinhold Kainhofer <reinhold@kainhofer.com>
Thu, 29 Sep 2011 09:25:04 +0000 (11:25 +0200)
committerReinhold Kainhofer <reinhold@kainhofer.com>
Thu, 29 Sep 2011 09:25:04 +0000 (11:25 +0200)
commit1ecdd56060e34a00b2be6b38029b286a601ea6f8
tree7fe6069579f98381c37f055f0f2aa989c03d09ca
parent3accbdd0e93e68f9c7bcaf90a5ababbd411bbb83
Fix 1477: Add (ly:expect-warning msg args) to suppress expected warnings

If a file contains (ly:expect-warning ....), the corresponding warning
string will be added to a list of expected warnings. If the corresponding
warning (or erro) is triggered, it will not be printed to stderr, but the
string will be removed from the list. So, each ly:expect-warning, suppresses
exactly one occurrence of the warning. To suppress a warning multiple times,
call ly:expect-warning multiple times.

After one file is processed, the list of expected warnings is checked.
If it is not empty, it means that an expected warning was not triggered,
which might be a bug. So we print out a warning message about this fact.

This allows the regtests to check proper warning messages, without
polluting the console output with those warning messages.
All warnings that are actually printed in the regtests are a bug.

For translated error message, there are two approaches: If the warning
is created from scheme, simply use
       (ly:expect-warning (_ "msg with ~a") "args")
If the message is triggered from C++, the translated string is in printf
syntax, so we need to translate that and then convert it into a format
string for Scheme. This can be done with the new function
ly:translate-cpp-warning-scheme instead of _:
       (ly:expect-warning (ly:translate-cpp-warning-scheme "msg with %s") "args")

This patch does not yet adapt all regtests that are supposed to print warnings
to this new approach. This will follow in a separate patch.
flower/include/warn.hh
flower/warn.cc
lily/warn-scheme.cc
scm/lily.scm