Use head instead of dd in the read test

The read test is now failing on GitHub actions even though it passes on
my Mac. It may be due to differences in dd between these two
environments. Stop using dd and just use head.
This commit is contained in:
ridiculousfish 2022-04-02 13:23:51 -07:00
parent 108fe574a0
commit 448dd18685

View file

@ -192,7 +192,7 @@ set line abcdefghijklmnopqrstuvwxyz
# Ensure the `read` command terminates if asked to read too much data. The var # Ensure the `read` command terminates if asked to read too much data. The var
# should be empty. We throw away any data we read if it exceeds the limit on # should be empty. We throw away any data we read if it exceeds the limit on
# what we consider reasonable. # what we consider reasonable.
yes $line | dd iflag=fullblock bs=1024 count=(math "1 + $fish_read_limit / 1024") 2>/dev/null | read --null x yes $line | head -c (math "1 + $fish_read_limit") | read --null x
if test $status -ne 122 if test $status -ne 122
echo reading too much data did not terminate with failure status echo reading too much data did not terminate with failure status
end end
@ -239,14 +239,12 @@ end
# Same as previous test but limit the amount of data fed to `read` rather than # Same as previous test but limit the amount of data fed to `read` rather than
# using the `--nchars` flag. # using the `--nchars` flag.
yes $line | dd iflag=fullblock bs=1024 count=(math "$fish_read_limit / 1024") 2>/dev/null | read --null x yes $line | head -c $fish_read_limit | read --null x
if test $status -ne 0 if test $status -ne 0
echo the read of the max amount of data failed unexpectedly echo the read of the max amount of data failed unexpectedly
end end
if test (string length "$x") -ne $fish_read_limit if test (string length "$x") -ne $fish_read_limit
# See how much data 'yes' produced. echo reading with a limited amount of input data failed the length test
set yeslen (yes $line | dd iflag=fullblock bs=1024 count=(math "$fish_read_limit / 1024") 2>/dev/null | wc -c | tr -d " \t\n\r")
echo reading the max amount of data with --nchars failed the length test. read: (string length "$x"), limit: $fish_read_limit, yes produced: $yeslen
end end
# Confirm reading non-interactively works -- \#4206 regression # Confirm reading non-interactively works -- \#4206 regression