@@ -356,6 +356,13 @@ def do_test(&block)
356356 break
357357 end
358358 end
359+ # MesPrint inevitably inserts newline characters when a line exceeds
360+ # its length limit. To verify error/warning messages, here we remove
361+ # newline characters that seem to be part of continuation lines
362+ # (this simple implementation also removes newline characters that are
363+ # not due to MesPrint).
364+ @cleaned_stdout = @stdout.gsub(/\R (? = ? \S )(? ! \S + Line \d +)/, " " )
365+
359366 yield
360367 # NOTE: Here we catch all exceptions, though it is a very bad style. This
361368 # is because, in Ruby 1.9, test/unit is implemented based on
@@ -622,7 +629,7 @@ def warning?(expected_message = nil)
622629 if expected_message.nil?
623630 @stdout =~ /(^|\R)\S+ Line \d+ --> Warning/
624631 else
625- @stdout =~ Regexp.new("(^|\\ R)\\ S+ Line \\ d+ --> Warning: .*#{Regexp.escape(expected_message)}")
632+ @cleaned_stdout =~ Regexp.new("(^|\\ R)\\ S+ Line \\ d+ --> Warning: .*#{Regexp.escape(expected_message)}")
626633 end
627634 end
628635
@@ -631,7 +638,7 @@ def preprocess_error?(expected_message = nil)
631638 if expected_message.nil?
632639 @stdout =~ /(^|\R)\S+ Line \d+ ==>/
633640 else
634- @stdout =~ Regexp.new("(^|\\ R)\\ S+ Line \\ d+ ==> .*#{Regexp.escape(expected_message)}")
641+ @cleaned_stdout =~ Regexp.new("(^|\\ R)\\ S+ Line \\ d+ ==> .*#{Regexp.escape(expected_message)}")
635642 end
636643 end
637644
@@ -640,7 +647,7 @@ def compile_error?(expected_message = nil)
640647 if expected_message.nil?
641648 @stdout =~ /(^|\R)\S+ Line \d+ -->/
642649 else
643- @stdout =~ Regexp.new("(^|\\ R)\\ S+ Line \\ d+ --> .*#{Regexp.escape(expected_message)}")
650+ @cleaned_stdout =~ Regexp.new("(^|\\ R)\\ S+ Line \\ d+ --> .*#{Regexp.escape(expected_message)}")
644651 end
645652 end
646653
@@ -660,7 +667,7 @@ def runtime_error?(expected_message = nil)
660667 else
661668 # NOTE: it just tests if the output contains the expected message,
662669 # which is probably put before "Terminate()" is called.
663- result && @stdout =~ Regexp.new(Regexp.escape(expected_message))
670+ result && @cleaned_stdout =~ Regexp.new(Regexp.escape(expected_message))
664671 end
665672 end
666673
0 commit comments