mirror of
https://git.savannah.gnu.org/git/coreutils.git
synced 2025-09-10 07:59:52 +02:00
tests: improve ls --dired with symlink testing
* tests/ls/dired.sh: Verify ls --dired with symlink.
This commit is contained in:
committed by
Pádraig Brady
parent
58a88f30f8
commit
f082cb8284
@@ -39,11 +39,13 @@ done
|
|||||||
# Also use multibyte characters to show --dired counts bytes not characters
|
# Also use multibyte characters to show --dired counts bytes not characters
|
||||||
touch dir/1a dir/2á || framework_failure_
|
touch dir/1a dir/2á || framework_failure_
|
||||||
mkdir -p dir/3dir || framework_failure_
|
mkdir -p dir/3dir || framework_failure_
|
||||||
|
touch dir/aaa || framework_failure_
|
||||||
|
ln -s target dir/0aaa_link || framework_failure_
|
||||||
|
|
||||||
ls -l --dired dir > out || fail=1
|
ls -l --dired dir > out || fail=1
|
||||||
|
|
||||||
dired_values=$(grep "//DIRED//" out| cut -d' ' -f2-)
|
dired_values=$(grep "//DIRED//" out| cut -d' ' -f2-)
|
||||||
expected_files="1a 2á 3dir"
|
expected_files="0aaa_link 1a 2á 3dir aaa"
|
||||||
|
|
||||||
dired_count=$(printf '%s\n' $dired_values | wc -l)
|
dired_count=$(printf '%s\n' $dired_values | wc -l)
|
||||||
expected_count=$(printf '%s\n' $expected_files | wc -l)
|
expected_count=$(printf '%s\n' $expected_files | wc -l)
|
||||||
@@ -60,6 +62,12 @@ set -- $dired_values
|
|||||||
while test "$#" -gt 0; do
|
while test "$#" -gt 0; do
|
||||||
extracted_filename=$(head -c "$2" out | tail -c+"$(($1 + 1))")
|
extracted_filename=$(head -c "$2" out | tail -c+"$(($1 + 1))")
|
||||||
expected_file=$(echo $expected_files | cut -d' ' -f$index)
|
expected_file=$(echo $expected_files | cut -d' ' -f$index)
|
||||||
|
|
||||||
|
# For symlinks, compare only the symlink name, ignoring the target part.
|
||||||
|
if echo "$extracted_filename" | grep ' -> ' > /dev/null; then
|
||||||
|
extracted_filename=$(echo "$extracted_filename" | cut -d' ' -f1)
|
||||||
|
fi
|
||||||
|
|
||||||
if test "$extracted_filename" != "$expected_file"; then
|
if test "$extracted_filename" != "$expected_file"; then
|
||||||
echo "Mismatch! Expected: $expected_file, Found: $extracted_filename"
|
echo "Mismatch! Expected: $expected_file, Found: $extracted_filename"
|
||||||
fail=1
|
fail=1
|
||||||
|
|||||||
Reference in New Issue
Block a user