summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2019-08-01 16:10:49 (GMT)
committerJunio C Hamano <gitster@pobox.com>2019-08-01 16:10:50 (GMT)
commitcc2a7403fef8c3e19e8d5b3939e5a9ee4789fd86 (patch)
tree45d938f931943a2900ad0f391f0f37f525c8da97 /t
parenta7b27d9e6d1071ff61a0263a87fac441b8dff11b (diff)
parent90421400977b3c80fdb8b887c61272a8f3ec0d18 (diff)
downloadgit-cc2a7403fef8c3e19e8d5b3939e5a9ee4789fd86.zip
git-cc2a7403fef8c3e19e8d5b3939e5a9ee4789fd86.tar.gz
git-cc2a7403fef8c3e19e8d5b3939e5a9ee4789fd86.tar.bz2
Merge branch 'jc/dir-iterator-test-fix'
* jc/dir-iterator-test-fix: test-dir-iterator: do not assume errno values
Diffstat (limited to 't')
-rw-r--r--t/helper/test-dir-iterator.c11
-rwxr-xr-xt/t0066-dir-iterator.sh4
2 files changed, 12 insertions, 3 deletions
diff --git a/t/helper/test-dir-iterator.c b/t/helper/test-dir-iterator.c
index a5b96cb..c7c3066 100644
--- a/t/helper/test-dir-iterator.c
+++ b/t/helper/test-dir-iterator.c
@@ -4,6 +4,15 @@
#include "iterator.h"
#include "dir-iterator.h"
+static const char *error_name(int error_number)
+{
+ switch (error_number) {
+ case ENOENT: return "ENOENT";
+ case ENOTDIR: return "ENOTDIR";
+ default: return "ESOMETHINGELSE";
+ }
+}
+
/*
* usage:
* tool-test dir-iterator [--follow-symlinks] [--pedantic] directory_path
@@ -31,7 +40,7 @@ int cmd__dir_iterator(int argc, const char **argv)
diter = dir_iterator_begin(path.buf, flags);
if (!diter) {
- printf("dir_iterator_begin failure: %d\n", errno);
+ printf("dir_iterator_begin failure: %s\n", error_name(errno));
exit(EXIT_FAILURE);
}
diff --git a/t/t0066-dir-iterator.sh b/t/t0066-dir-iterator.sh
index 9354d3f..92910e4 100755
--- a/t/t0066-dir-iterator.sh
+++ b/t/t0066-dir-iterator.sh
@@ -55,13 +55,13 @@ test_expect_success 'dir-iterator should list files in the correct order' '
test_expect_success 'begin should fail upon inexistent paths' '
test_must_fail test-tool dir-iterator ./inexistent-path \
>actual-inexistent-path-output &&
- echo "dir_iterator_begin failure: 2" >expected-inexistent-path-output &&
+ echo "dir_iterator_begin failure: ENOENT" >expected-inexistent-path-output &&
test_cmp expected-inexistent-path-output actual-inexistent-path-output
'
test_expect_success 'begin should fail upon non directory paths' '
test_must_fail test-tool dir-iterator ./dir/b >actual-non-dir-output &&
- echo "dir_iterator_begin failure: 20" >expected-non-dir-output &&
+ echo "dir_iterator_begin failure: ENOTDIR" >expected-non-dir-output &&
test_cmp expected-non-dir-output actual-non-dir-output
'