From 9617fd0862322bc263bc8a73300cdee967d3def8 Mon Sep 17 00:00:00 2001 From: David Malcolm Date: Mon, 18 Jan 2016 17:26:58 +0000 Subject: [PATCH] PR testsuite/69181: ensure expected multiline outputs is cleared per-test 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 | 18 ++++++++++++++++ gcc/testsuite/gcc.dg/pr69181-1.c | 7 +++++++ gcc/testsuite/gcc.dg/pr69181-2.c | 4 ++++ gcc/testsuite/lib/gcc-dg.exp | 36 ++++++++++++++++---------------- gcc/testsuite/lib/multiline.exp | 22 ++++++++----------- 5 files changed, 56 insertions(+), 31 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/pr69181-1.c create mode 100644 gcc/testsuite/gcc.dg/pr69181-2.c diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index cfc6ce23dd71..da5bfa931f14 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,21 @@ +2016-01-18 David Malcolm + + 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 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 index 000000000000..e851f0c8a476 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr69181-1.c @@ -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 index 000000000000..dca90dcbf121 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr69181-2.c @@ -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; diff --git a/gcc/testsuite/lib/gcc-dg.exp b/gcc/testsuite/lib/gcc-dg.exp index f9ec2068bedb..c00332833136 100644 --- a/gcc/testsuite/lib/gcc-dg.exp +++ b/gcc/testsuite/lib/gcc-dg.exp @@ -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 } } diff --git a/gcc/testsuite/lib/multiline.exp b/gcc/testsuite/lib/multiline.exp index 6b2c1da9c878..fd7affcfafdf 100644 --- a/gcc/testsuite/lib/multiline.exp +++ b/gcc/testsuite/lib/multiline.exp @@ -47,17 +47,18 @@ # 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 } -- 2.47.2