Skip to content

Commit fea3738

Browse files
committed
Merge branch 'ab/getcwd-test'
Portability test update. * ab/getcwd-test: t0001: fix broken not-quite getcwd(3) test in bed6787
2 parents 4dc9646 + 482e148 commit fea3738

File tree

5 files changed

+33
-1
lines changed

5 files changed

+33
-1
lines changed

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -715,6 +715,7 @@ TEST_BUILTINS_OBJS += test-example-decorate.o
715715
TEST_BUILTINS_OBJS += test-fast-rebase.o
716716
TEST_BUILTINS_OBJS += test-genrandom.o
717717
TEST_BUILTINS_OBJS += test-genzeros.o
718+
TEST_BUILTINS_OBJS += test-getcwd.o
718719
TEST_BUILTINS_OBJS += test-hash-speed.o
719720
TEST_BUILTINS_OBJS += test-hash.o
720721
TEST_BUILTINS_OBJS += test-hashmap.o

t/helper/test-getcwd.c

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#include "test-tool.h"
2+
#include "git-compat-util.h"
3+
#include "parse-options.h"
4+
5+
static const char *getcwd_usage[] = {
6+
"test-tool getcwd",
7+
NULL
8+
};
9+
10+
int cmd__getcwd(int argc, const char **argv)
11+
{
12+
struct option options[] = {
13+
OPT_END()
14+
};
15+
char *cwd;
16+
17+
argc = parse_options(argc, argv, "test-tools", options, getcwd_usage, 0);
18+
if (argc > 0)
19+
usage_with_options(getcwd_usage, options);
20+
21+
cwd = xgetcwd();
22+
puts(cwd);
23+
free(cwd);
24+
25+
return 0;
26+
}

t/helper/test-tool.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ static struct test_cmd cmds[] = {
3333
{ "fast-rebase", cmd__fast_rebase },
3434
{ "genrandom", cmd__genrandom },
3535
{ "genzeros", cmd__genzeros },
36+
{ "getcwd", cmd__getcwd },
3637
{ "hashmap", cmd__hashmap },
3738
{ "hash-speed", cmd__hash_speed },
3839
{ "index-version", cmd__index_version },

t/helper/test-tool.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ int cmd__example_decorate(int argc, const char **argv);
2323
int cmd__fast_rebase(int argc, const char **argv);
2424
int cmd__genrandom(int argc, const char **argv);
2525
int cmd__genzeros(int argc, const char **argv);
26+
int cmd__getcwd(int argc, const char **argv);
2627
int cmd__hashmap(int argc, const char **argv);
2728
int cmd__hash_speed(int argc, const char **argv);
2829
int cmd__index_version(int argc, const char **argv);

t/t0001-init.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,10 @@ test_lazy_prereq GETCWD_IGNORES_PERMS '
356356
chmod 100 $base ||
357357
BUG "cannot prepare $base"
358358
359-
(cd $base/dir && /bin/pwd -P)
359+
(
360+
cd $base/dir &&
361+
test-tool getcwd
362+
)
360363
status=$?
361364
362365
chmod 700 $base &&

0 commit comments

Comments
 (0)