From cbba4dbb8d52c5b0f32e803cf8587f276ee1ec86 Mon Sep 17 00:00:00 2001 From: Jacob Bachmeyer Date: Thu, 18 Jun 2020 17:32:48 -0500 Subject: Add tests for handling arithmetic errors in auto-loaded procedures --- testsuite/runtest.main/abort.exp | 11 +++++++ .../abort/testsuite/abort.test/abort-al-dbz.exp | 38 ++++++++++++++++++++++ 2 files changed, 49 insertions(+) create mode 100644 testsuite/runtest.main/abort/testsuite/abort.test/abort-al-dbz.exp (limited to 'testsuite') diff --git a/testsuite/runtest.main/abort.exp b/testsuite/runtest.main/abort.exp index c5f7014..864f1e0 100644 --- a/testsuite/runtest.main/abort.exp +++ b/testsuite/runtest.main/abort.exp @@ -50,6 +50,16 @@ set tests { "PASS: running abort-undef.exp.*\ *UNRESOLVED: .* aborted at call to unknown command.*\ *expected passes\[ \t\]+1\n.*unresolved testcases\[ \t\]+1\n" } + { "stop at auto-loaded divide-by-zero without --keep_going" + "abort-al-dbz.exp simple.exp" + "PASS: running abort-al-dbz.exp.*\ + *UNRESOLVED: .* aborted at .*\ + *expected passes\[ \t\]+1\n.*unresolved testcases\[ \t\]+1\n" } + { "continue after auto-loaded divide-by-zero with --keep_going" + "--keep_going abort-al-dbz.exp simple.exp" + "PASS: running abort-al-dbz.exp.*\ + *PASS: simple test.*\ + *expected passes\[ \t\]+2\n" } { "stop at abort without --keep_going" "abort-undef.exp simple.exp" "PASS: running abort-undef.exp.*\ @@ -76,3 +86,4 @@ foreach t $tests { } file delete -force $tmpdir +file delete -force [testsuite file -object -test abort testsuite abort.test lib] diff --git a/testsuite/runtest.main/abort/testsuite/abort.test/abort-al-dbz.exp b/testsuite/runtest.main/abort/testsuite/abort.test/abort-al-dbz.exp new file mode 100644 index 0000000..df55a9a --- /dev/null +++ b/testsuite/runtest.main/abort/testsuite/abort.test/abort-al-dbz.exp @@ -0,0 +1,38 @@ +# Copyright (C) 2020 Free Software Foundation, Inc. +# +# This file is part of DejaGnu. +# +# DejaGnu is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# DejaGnu is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with DejaGnu; if not, write to the Free Software Foundation, +# Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. + +# Cause a divide-by-zero error in an auto-loaded procedure. + +pass "running abort-al-dbz.exp" + +set fd [open [testsuite file -object -test lib foo.tcl] w] +puts $fd {proc throw_arith_error_div_by_zero { } { + expr { 1 / 0 } +} +} +close $fd + +auto_mkindex \ + [testsuite file -object -test lib] \ + [testsuite file -object -test lib/*.tcl] + +lappend auto_path [testsuite file -object -test lib] + +throw_arith_error_div_by_zero + +fail "script did not abort" -- cgit v1.1