From: Jarkko Hietaniemi Date: Mon, 1 Oct 2001 01:19:21 +0000 (+0000) Subject: Use stty -g to restore the terminal state, do not even X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=fc81c880d856f71fc84201fd183d90bfd812c5c2;p=p5sagit%2Fp5-mst-13.2.git 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 --- diff --git a/lib/Term/Complete.t b/lib/Term/Complete.t index 3f8cb20..63b2825 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 -