From 08b6751e4cb4fbcb813d54a73c37142231ab4ee9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A1draig=20Brady?= Date: Tue, 11 Apr 2023 13:02:21 +0100 Subject: [PATCH] tests: tty-eof: fix false failures and other issues * tests/misc/tty-eof.pl: Ensure we don't erroneously skip commands with parameters. Comment as to why cut(1) is treated differently. Adjust expect calls to not wait needlessly for cut output. Increase timeout from 10 to 30 seconds to avoid spurious failures. --- tests/misc/tty-eof.pl | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/tests/misc/tty-eof.pl b/tests/misc/tty-eof.pl index d429cbb8f..926517a4a 100755 --- a/tests/misc/tty-eof.pl +++ b/tests/misc/tty-eof.pl @@ -69,17 +69,21 @@ $@ { my $exp = new Expect; $exp->log_user(0); - $ENV{built_programs} =~ /\b$cmd\b/ || next; + my $cmd_name = (split(' ', $cmd))[0]; + $ENV{built_programs} =~ /\b$cmd_name\b/ || next; $exp->spawn("$cmd 2> $stderr") or (warn "$ME: cannot run '$cmd': $!\n"), $fail=1, next; - # No input for cut -f2. + # Test cut in a different mode, even though it supports the standard flow + # Ensure that it exits with no input as it used to not do so $cmd =~ /^cut/ or $exp->send("a b\n"); $exp->send("\cD"); # This is Control-D. FIXME: what if that's not EOF? - $exp->expect (0, '-re', "^a b\\r?\$"); - my $found = $exp->expect (1, '-re', "^.+\$"); + $cmd =~ /^cut/ + or $exp->expect (0, '-re', "^a b\\r?\$"); + $cmd =~ /^cut/ + or my $found = $exp->expect (1, '-re', "^.+\$"); $found and warn "F: $found: " . $exp->exp_match () . "\n"; - $exp->expect(10, 'eof'); + $exp->expect(30, 'eof'); # Expect no output from cut, since we gave it no input. defined $found || $cmd =~ /^cut/ or (warn "$ME: $cmd didn't produce expected output\n"), -- 2.26.2