Le 19/10/2024 à 14:02, Pádraig Brady a écrit :
On 18/10/2024 22:17, Sylvestre Ledru wrote:
Hello

These two patches improve the test coverage of ls & cksum.

The first patch tests that symlink with --dired are correctly positioned.

The second that comments on a checksum files aren't causing any
validation issues (but impacts the line number).
The first patch induces a failure on btrfs at least,
due to the non determination of directory order with the -f option.
For me the result is:

    drwxr-xr-x. 1 padraig padraig 40 Oct 19 12:58 .  drwx------. 1 padraig 
padraig 18 Oct 19 12:58 ..
    -rw-r--r--. 1 padraig padraig  0 Oct 19 12:58 1a
    -rw-r--r--. 1 padraig padraig  0 Oct 19 12:58 2á
    drwxr-xr-x. 1 padraig padraig  0 Oct 19 12:58 3dir
    -rw-r--r--. 1 padraig padraig  0 Oct 19 12:58 aaa
    lrwxrwxrwx  1 padraig padraig  6 Oct 19 12:58 aaa_link -> target

Why did you add the -f option?

just an oversight, sorry. I removed it as the goal is to test dired positions with symlinks (0aaa_link -> target)

Here is a better version :)

Cheers
S

From 9e716415136a03c4dc373d9f19c097e182b10941 Mon Sep 17 00:00:00 2001
From: Sylvestre Ledru <sylves...@debian.org>
Date: Thu, 17 Oct 2024 22:26:43 +0200
Subject: [PATCH 1/2] tests: improve ls --dired with symlink testing

* tests/ls/dired.sh: Verify ls --dired with symlink
---
 tests/ls/dired.sh | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/tests/ls/dired.sh b/tests/ls/dired.sh
index 7c6c03bd4..77845ab4d 100755
--- a/tests/ls/dired.sh
+++ b/tests/ls/dired.sh
@@ -39,11 +39,13 @@ done
 # Also use multibyte characters to show --dired counts bytes not characters
 touch dir/1a dir/2á || 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
 
 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)
 expected_count=$(printf '%s\n' $expected_files | wc -l)
@@ -60,6 +62,12 @@ set -- $dired_values
 while test "$#" -gt 0; do
   extracted_filename=$(head -c "$2" out | tail -c+"$(($1 + 1))")
   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 -q " -> "; then
+    extracted_filename=$(echo "$extracted_filename" | cut -d' ' -f1)
+  fi
+
   if test "$extracted_filename" != "$expected_file"; then
     echo "Mismatch! Expected: $expected_file, Found: $extracted_filename"
     fail=1
-- 
2.45.2

Reply via email to