tests: use `test -f` instead of `ls` to see if a file is present (issue6662) stable
authorAnton Shestakov <av6@dwimlabs.net>
Mon, 05 Dec 2022 19:37:12 +0400
branchstable
changeset 49773 13c0e3b4fd35
parent 49763 c52435820bbd
child 49778 48e38b179106
tests: use `test -f` instead of `ls` to see if a file is present (issue6662) ls's exit code when file doesn't exist is 2 on Linux and 1 on NetBSD, so let's use something that's supposedly more portable, since we only care whether the file is there or not.
tests/test-status-tracked-key.t
--- a/tests/test-status-tracked-key.t	Mon Dec 05 17:28:40 2022 +0100
+++ b/tests/test-status-tracked-key.t	Mon Dec 05 19:37:12 2022 +0400
@@ -165,8 +165,7 @@
 Test upgrade and downgrade
 ==========================
 
-  $ ls .hg/dirstate-tracked-hint
-  .hg/dirstate-tracked-hint
+  $ test -f .hg/dirstate-tracked-hint
   $ hg debugrequires | grep 'tracked'
   dirstate-tracked-key-v1
 
@@ -181,9 +180,8 @@
   
   no revlogs to process
   
-  $ ls -1 .hg/dirstate-tracked-hint
-  ls: *.hg/dirstate-tracked-hint*: $ENOENT$ (glob)
-  [2]
+  $ test -f .hg/dirstate-tracked-hint
+  [1]
   $ hg debugrequires | grep 'tracked'
   [1]
 
@@ -198,8 +196,7 @@
   
   no revlogs to process
   
-  $ ls -1 .hg/dirstate-tracked-hint
-  .hg/dirstate-tracked-hint
+  $ test -f .hg/dirstate-tracked-hint
   $ hg debugrequires | grep 'tracked'
   dirstate-tracked-key-v1
   $ cd ..