From fc81c880d856f71fc84201fd183d90bfd812c5c2 Mon Sep 17 00:00:00 2001 From: Jarkko Hietaniemi Date: Mon, 1 Oct 2001 01:19:21 +0000 Subject: [PATCH] Use stty -g to restore the terminal state, do not even try to run the tests if stty -g is not available. p4raw-id: //depot/perl@12282 --- lib/Term/Complete.t | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/Term/Complete.t b/lib/Term/Complete.t index 3f8cb2021a..63b2825b7a 100644 --- a/lib/Term/Complete.t +++ b/lib/Term/Complete.t @@ -8,6 +8,8 @@ BEGIN { use warnings; use Test::More tests => 8; use vars qw( $Term::Complete::complete $complete ); +my $restore; + SKIP: { skip('PERL_SKIP_TTY_TEST', 8) if $ENV{PERL_SKIP_TTY_TEST}; @@ -18,7 +20,9 @@ SKIP: { if (defined $TTY) { open(TTY, $TTY) or die "open $TTY failed: $!"; skip("$TTY not a tty", 8) if defined $TTY && ! -t TTY; - } + $restore = `stty -g`; + skip("Can't reliably restore $TTY", 8) if $?; + } use_ok( 'Term::Complete' ); @@ -65,6 +69,9 @@ like( $$out, qr/prompt:frobn/, 'prompt is okay' ); # now remove the prompt and we should be okay $$out =~ s/prompt://g; is( $$out, get_expected('frobn', 'frobnitz' ), 'works with new $complete' ); +`stty $restore`; + +} # end of SKIP, end of tests # easier than matching space characters sub get_expected { @@ -110,6 +117,3 @@ sub PRINT { my $self = shift; ($$self .= join('', @_)) =~ s/\s+/./gm; } - -} # end of SKIP, end of tests - -- 2.34.1