Skip to content

Commit cc2a740

Browse files
committed
Merge branch 'jc/dir-iterator-test-fix'
* jc/dir-iterator-test-fix: test-dir-iterator: do not assume errno values
2 parents a7b27d9 + 9042140 commit cc2a740

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

t/helper/test-dir-iterator.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,15 @@
44
#include "iterator.h"
55
#include "dir-iterator.h"
66

7+
static const char *error_name(int error_number)
8+
{
9+
switch (error_number) {
10+
case ENOENT: return "ENOENT";
11+
case ENOTDIR: return "ENOTDIR";
12+
default: return "ESOMETHINGELSE";
13+
}
14+
}
15+
716
/*
817
* usage:
918
* tool-test dir-iterator [--follow-symlinks] [--pedantic] directory_path
@@ -31,7 +40,7 @@ int cmd__dir_iterator(int argc, const char **argv)
3140
diter = dir_iterator_begin(path.buf, flags);
3241

3342
if (!diter) {
34-
printf("dir_iterator_begin failure: %d\n", errno);
43+
printf("dir_iterator_begin failure: %s\n", error_name(errno));
3544
exit(EXIT_FAILURE);
3645
}
3746

t/t0066-dir-iterator.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,13 @@ test_expect_success 'dir-iterator should list files in the correct order' '
5555
test_expect_success 'begin should fail upon inexistent paths' '
5656
test_must_fail test-tool dir-iterator ./inexistent-path \
5757
>actual-inexistent-path-output &&
58-
echo "dir_iterator_begin failure: 2" >expected-inexistent-path-output &&
58+
echo "dir_iterator_begin failure: ENOENT" >expected-inexistent-path-output &&
5959
test_cmp expected-inexistent-path-output actual-inexistent-path-output
6060
'
6161

6262
test_expect_success 'begin should fail upon non directory paths' '
6363
test_must_fail test-tool dir-iterator ./dir/b >actual-non-dir-output &&
64-
echo "dir_iterator_begin failure: 20" >expected-non-dir-output &&
64+
echo "dir_iterator_begin failure: ENOTDIR" >expected-non-dir-output &&
6565
test_cmp expected-non-dir-output actual-non-dir-output
6666
'
6767

0 commit comments

Comments
 (0)