public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] multiline.exp: complain about mismatched dg-{begin|end}-multiline-output
@ 2018-10-11 13:35 David Malcolm
  2018-10-11 16:50 ` Jeff Law
  0 siblings, 1 reply; 2+ messages in thread
From: David Malcolm @ 2018-10-11 13:35 UTC (permalink / raw)
  To: gcc-patches; +Cc: David Malcolm

Mismatched dg-{begin|end}-multiline-output directives are currently
silently ignored, leading to difficult-to-diagnose test failures
involving excess output.

This patch makes multiline.exp complain about them.

Successfully regrtested on x86_64-pc-linux-gnu

OK for trunk?

gcc/testsuite/ChangeLog:
	* lib/multiline.exp (dg-begin-multiline-output): Issue an error if
	there hasn't been a dg-end-multiline-output since the last
	dg-begin-multiline-output.
	(dg-end-multiline-output): Issue an error if there hasn't been a
	dg-begin-multiline-output.  Reset _multiline_last_beginning_line
	as soon possible.  Rename "line" to "last_line".
---
 gcc/testsuite/lib/multiline.exp | 27 +++++++++++++++++++++------
 1 file changed, 21 insertions(+), 6 deletions(-)

diff --git a/gcc/testsuite/lib/multiline.exp b/gcc/testsuite/lib/multiline.exp
index 6c7ecdf..6e431d9 100644
--- a/gcc/testsuite/lib/multiline.exp
+++ b/gcc/testsuite/lib/multiline.exp
@@ -72,6 +72,14 @@ proc dg-begin-multiline-output { args } {
     global _multiline_last_beginning_line
     verbose "dg-begin-multiline-output: args: $args" 3
     set line [expr [lindex $args 0] + 1]
+
+    # Complain if there hasn't been a dg-end-multiline-output
+    # since the last dg-begin-multiline-output
+    if { $_multiline_last_beginning_line != -1 } {
+	set last_directive_line [expr $_multiline_last_beginning_line - 1]
+	error "$last_directive_line: unterminated dg-begin-multiline-output"
+    }
+    
     set _multiline_last_beginning_line $line
 }
 
@@ -84,8 +92,17 @@ proc dg-begin-multiline-output { args } {
 proc dg-end-multiline-output { args } {
     global _multiline_last_beginning_line
     verbose "dg-end-multiline-output: args: $args" 3
-    set line [expr [lindex $args 0] - 1]
-    verbose "multiline output lines: $_multiline_last_beginning_line-$line" 3
+    set first_line $_multiline_last_beginning_line
+
+    # Complain if there hasn't been a dg-begin-multiline-output
+    if { $first_line == -1 } {
+	error "[lindex $args 0]: dg-end-multiline-output without dg-begin-multiline-output"
+	return
+    }
+    set _multiline_last_beginning_line -1
+
+    set last_line [expr [lindex $args 0] - 1]
+    verbose "multiline output lines: $first_line-$last_line" 3
 
     if { [llength $args] > 3 } {
 	error "[lindex $args 0]: too many arguments"
@@ -109,16 +126,14 @@ proc dg-end-multiline-output { args } {
     # "prog" now contains the filename
     # Load it and split it into lines
 
-    set lines [_get_lines $prog $_multiline_last_beginning_line $line]
+    set lines [_get_lines $prog $first_line $last_line]
 
     verbose "lines: $lines" 3
     # Create an entry of the form:  first-line, last-line, lines, maybe_x
-    set entry [list $_multiline_last_beginning_line $line $lines $maybe_x]
+    set entry [list $first_line $last_line $lines $maybe_x]
     global multiline_expected_outputs
     lappend multiline_expected_outputs $entry
     verbose "within dg-end-multiline-output: multiline_expected_outputs: $multiline_expected_outputs" 3
-
-    set _multiline_last_beginning_line -1
 }
 
 # Hook to be called by prune.exp's prune_gcc_output to
-- 
1.8.5.3

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] multiline.exp: complain about mismatched dg-{begin|end}-multiline-output
  2018-10-11 13:35 [PATCH] multiline.exp: complain about mismatched dg-{begin|end}-multiline-output David Malcolm
@ 2018-10-11 16:50 ` Jeff Law
  0 siblings, 0 replies; 2+ messages in thread
From: Jeff Law @ 2018-10-11 16:50 UTC (permalink / raw)
  To: David Malcolm, gcc-patches

On 10/11/18 8:20 AM, David Malcolm wrote:
> Mismatched dg-{begin|end}-multiline-output directives are currently
> silently ignored, leading to difficult-to-diagnose test failures
> involving excess output.
> 
> This patch makes multiline.exp complain about them.
> 
> Successfully regrtested on x86_64-pc-linux-gnu
> 
> OK for trunk?
> 
> gcc/testsuite/ChangeLog:
> 	* lib/multiline.exp (dg-begin-multiline-output): Issue an error if
> 	there hasn't been a dg-end-multiline-output since the last
> 	dg-begin-multiline-output.
> 	(dg-end-multiline-output): Issue an error if there hasn't been a
> 	dg-begin-multiline-output.  Reset _multiline_last_beginning_line
> 	as soon possible.  Rename "line" to "last_line".
OK.  Assuming since there's no patches to existing tests that at least
for the x86-64 target we don't have any mismatched dg-blah things in the
tree right now.

jeff

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-10-11 15:44 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-11 13:35 [PATCH] multiline.exp: complain about mismatched dg-{begin|end}-multiline-output David Malcolm
2018-10-11 16:50 ` Jeff Law

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).