PR testsuite/69181: ensure expected multiline outputs is cleared per-test
authorDavid Malcolm <dmalcolm@redhat.com>
Mon, 18 Jan 2016 17:26:58 +0000 (17:26 +0000)
committerDavid Malcolm <dmalcolm@gcc.gnu.org>
Mon, 18 Jan 2016 17:26:58 +0000 (17:26 +0000)
gcc/testsuite/ChangeLog:
PR testsuite/69181
* gcc.dg/pr69181-1.c: New test file.
* gcc.dg/pr69181-2.c: New test file.
* lib/gcc-dg.exp (dg-test): Consolidate post-test cleanup of
globals by moving it to...
(cleanup-after-saved-dg-test): ...this new function.  Add
"global additional_sources_used".  Add reset of global
multiline_expected_outputs to the empty list.
* lib/multiline.exp (_multiline_expected_outputs): Rename this
global to...
(multiline_expected_outputs): ...this, and updated comments to
note that it is modified from gcc-dg.exp.
(dg-end-multiline-output): Update for the above renaming.
(handle-multiline-outputs): Likewise.  Remove the clearing
of the expected outputs to the empty list.

From-SVN: r232535

gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/pr69181-1.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/pr69181-2.c [new file with mode: 0644]
gcc/testsuite/lib/gcc-dg.exp
gcc/testsuite/lib/multiline.exp

index cfc6ce2..da5bfa9 100644 (file)
@@ -1,3 +1,21 @@
+2016-01-18  David Malcolm  <dmalcolm@redhat.com>
+
+       PR testsuite/69181
+       * gcc.dg/pr69181-1.c: New test file.
+       * gcc.dg/pr69181-2.c: New test file.
+       * lib/gcc-dg.exp (dg-test): Consolidate post-test cleanup of
+       globals by moving it to...
+       (cleanup-after-saved-dg-test): ...this new function.  Add
+       "global additional_sources_used".  Add reset of global
+       multiline_expected_outputs to the empty list.
+       * lib/multiline.exp (_multiline_expected_outputs): Rename this
+       global to...
+       (multiline_expected_outputs): ...this, and updated comments to
+       note that it is modified from gcc-dg.exp.
+       (dg-end-multiline-output): Update for the above renaming.
+       (handle-multiline-outputs): Likewise.  Remove the clearing
+       of the expected outputs to the empty list.
+
 2016-01-18  Richard Biener  <rguenther@suse.de>
 
        PR tree-optimization/69297
diff --git a/gcc/testsuite/gcc.dg/pr69181-1.c b/gcc/testsuite/gcc.dg/pr69181-1.c
new file mode 100644 (file)
index 0000000..e851f0c
--- /dev/null
@@ -0,0 +1,7 @@
+/* { dg-do compile { target this_will_not_be_matched-*-* } } */
+
+/* { dg-begin-multiline-output "" }
+   This message should never be checked for.
+   In particular, it shouldn't be checked for in the *next*
+   test case.
+   { dg-end-multiline-output "" } */
diff --git a/gcc/testsuite/gcc.dg/pr69181-2.c b/gcc/testsuite/gcc.dg/pr69181-2.c
new file mode 100644 (file)
index 0000000..dca90dc
--- /dev/null
@@ -0,0 +1,4 @@
+/* Dummy test case, to verify that the dg-begin-multiline-output directive
+   from pr69181-1.c isn't erroneously expected to be handled in *this*
+   test case.  */
+int make_non_empty;
index f9ec206..c003328 100644 (file)
@@ -826,33 +826,21 @@ proc output-exists-not { args } {
 if { [info procs saved-dg-test] == [list] } {
     rename dg-test saved-dg-test
 
-    proc dg-test { args } {
+    # Helper function for cleanups that should happen after the call
+    # to the real dg-test, whether or not it returns normally, or
+    # fails with an error.
+    proc cleanup-after-saved-dg-test { } {
        global additional_files
        global additional_sources
+       global additional_sources_used
        global additional_prunes
-       global errorInfo
        global compiler_conditional_xfail_data
        global shouldfail
        global testname_with_flags
        global set_target_env_var
        global keep_saved_temps_suffixes
+       global multiline_expected_outputs
 
-       if { [ catch { eval saved-dg-test $args } errmsg ] } {
-           set saved_info $errorInfo
-           set additional_files ""
-           set additional_sources ""
-           set additional_sources_used ""
-           set additional_prunes ""
-           set shouldfail 0
-           if [info exists compiler_conditional_xfail_data] {
-               unset compiler_conditional_xfail_data
-           }
-           if [info exists testname_with_flags] {
-               unset testname_with_flags
-           }
-           unset_timeout_vars
-           error $errmsg $saved_info
-       }
        set additional_files ""
        set additional_sources ""
        set additional_sources_used ""
@@ -871,6 +859,18 @@ if { [info procs saved-dg-test] == [list] } {
        if [info exists testname_with_flags] {
            unset testname_with_flags
        }
+       set multiline_expected_outputs []
+    }
+
+    proc dg-test { args } {
+       global errorInfo
+
+       if { [ catch { eval saved-dg-test $args } errmsg ] } {
+           set saved_info $errorInfo
+           cleanup-after-saved-dg-test
+           error $errmsg $saved_info
+       }
+       cleanup-after-saved-dg-test
     }
 }
 
index 6b2c1da..fd7affc 100644 (file)
 # to have the testsuite verify the expected output.
 
 ############################################################################
-# Global variables.  Although global, these are intended to only be used from
-# within multiline.exp.
+# Global variables.
 ############################################################################
 
+# This is intended to only be used from within multiline.exp.
 # The line number of the last dg-begin-multiline-output directive.
 set _multiline_last_beginning_line -1
 
 # A list of
 #   first-line-number, last-line-number, lines
 # where each "lines" is a list of strings.
-set _multiline_expected_outputs []
+# This is cleared at the end of each test by gcc-dg.exp's wrapper for dg-test.
+set multiline_expected_outputs []
 
 ############################################################################
 # Exported functions.
@@ -94,9 +95,9 @@ proc dg-end-multiline-output { args } {
     verbose "lines: $lines" 3
     # Create an entry of the form:  first-line, last-line, lines
     set entry [list $_multiline_last_beginning_line $line $lines]
-    global _multiline_expected_outputs
-    lappend _multiline_expected_outputs $entry
-    verbose "within dg-end-multiline-output: _multiline_expected_outputs: $_multiline_expected_outputs" 3
+    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
 }
@@ -107,14 +108,12 @@ proc dg-end-multiline-output { args } {
 # those that weren't found.
 #
 # It returns a pruned version of its output.
-#
-# It also clears the list of expected multiline outputs.
 
 proc handle-multiline-outputs { text } {
-    global _multiline_expected_outputs
+    global multiline_expected_outputs
     global testname_with_flags
     set index 0
-    foreach entry $_multiline_expected_outputs {
+    foreach entry $multiline_expected_outputs {
        verbose "  entry: $entry" 3
        set start_line [lindex $entry 0]
        set end_line   [lindex $entry 1]
@@ -140,9 +139,6 @@ proc handle-multiline-outputs { text } {
        set index [expr $index + 1]
     }
 
-    # Clear the list of expected multiline outputs
-    set _multiline_expected_outputs []
-
     return $text
 }