Andrew's git
/
gitweb.git
/ diff
summary
|
log
|
commit
| diff |
tree
commit
grep
author
committer
pickaxe
?
re
t/helper: merge test-path-utils into test-tool
author
Nguyễn Thái Ngọc Duy
<pclouds@gmail.com>
Sat, 24 Mar 2018 07:44:49 +0000
(08:44 +0100)
committer
Junio C Hamano
<gitster@pobox.com>
Tue, 27 Mar 2018 15:45:47 +0000
(08:45 -0700)
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Makefile
patch
|
blob
|
history
t/helper/test-path-utils.c
patch
|
blob
|
history
t/helper/test-tool.c
patch
|
blob
|
history
t/helper/test-tool.h
patch
|
blob
|
history
t/lib-git-p4.sh
patch
|
blob
|
history
t/t0060-path-utils.sh
patch
|
blob
|
history
t/t1501-work-tree.sh
patch
|
blob
|
history
raw
|
patch
|
inline
| side by side (parent:
c033cc1
)
diff --git
a/Makefile
b/Makefile
index 91af906d085354596d790524bf52f1d2978acc20..751ea6cad746a39e9973e3291f00b346b0cef718 100644
(file)
--- a/
Makefile
+++ b/
Makefile
@@
-669,6
+669,7
@@
TEST_BUILTINS_OBJS += test-match-trees.o
TEST_BUILTINS_OBJS += test-mergesort.o
TEST_BUILTINS_OBJS += test-mktemp.o
TEST_BUILTINS_OBJS += test-online-cpus.o
TEST_BUILTINS_OBJS += test-mergesort.o
TEST_BUILTINS_OBJS += test-mktemp.o
TEST_BUILTINS_OBJS += test-online-cpus.o
+TEST_BUILTINS_OBJS += test-path-utils.o
TEST_BUILTINS_OBJS += test-sha1.o
TEST_PROGRAMS_NEED_X += test-dump-fsmonitor
TEST_BUILTINS_OBJS += test-sha1.o
TEST_PROGRAMS_NEED_X += test-dump-fsmonitor
@@
-676,7
+677,6
@@
TEST_PROGRAMS_NEED_X += test-dump-untracked-cache
TEST_PROGRAMS_NEED_X += test-fake-ssh
TEST_PROGRAMS_NEED_X += test-line-buffer
TEST_PROGRAMS_NEED_X += test-parse-options
TEST_PROGRAMS_NEED_X += test-fake-ssh
TEST_PROGRAMS_NEED_X += test-line-buffer
TEST_PROGRAMS_NEED_X += test-parse-options
-TEST_PROGRAMS_NEED_X += test-path-utils
TEST_PROGRAMS_NEED_X += test-prio-queue
TEST_PROGRAMS_NEED_X += test-read-cache
TEST_PROGRAMS_NEED_X += test-write-cache
TEST_PROGRAMS_NEED_X += test-prio-queue
TEST_PROGRAMS_NEED_X += test-read-cache
TEST_PROGRAMS_NEED_X += test-write-cache
diff --git
a/t/helper/test-path-utils.c
b/t/helper/test-path-utils.c
index 2b3c5092a199835ea2e84339b473a9e29778178d..e115d44ac26e1d4fed48a5fd82632e5a93a487e6 100644
(file)
--- a/
t/helper/test-path-utils.c
+++ b/
t/helper/test-path-utils.c
@@
-1,3
+1,4
@@
+#include "test-tool.h"
#include "cache.h"
#include "string-list.h"
#include "cache.h"
#include "string-list.h"
@@
-170,7
+171,7
@@
static struct test_data dirname_data[] = {
{ NULL, NULL }
};
{ NULL, NULL }
};
-int cmd_
main
(int argc, const char **argv)
+int cmd_
_path_utils
(int argc, const char **argv)
{
if (argc == 3 && !strcmp(argv[1], "normalize_path_copy")) {
char *buf = xmallocz(strlen(argv[2]));
{
if (argc == 3 && !strcmp(argv[1], "normalize_path_copy")) {
char *buf = xmallocz(strlen(argv[2]));
diff --git
a/t/helper/test-tool.c
b/t/helper/test-tool.c
index bca32f23fae4fa7d48a9abf2fe8a7bfb63f9bd29..baec861cc248b9a3f940944574bd140e6849bccc 100644
(file)
--- a/
t/helper/test-tool.c
+++ b/
t/helper/test-tool.c
@@
-24,6
+24,7
@@
static struct test_cmd cmds[] = {
{ "mergesort", cmd__mergesort },
{ "mktemp", cmd__mktemp },
{ "online-cpus", cmd__online_cpus },
{ "mergesort", cmd__mergesort },
{ "mktemp", cmd__mktemp },
{ "online-cpus", cmd__online_cpus },
+ { "path-utils", cmd__path_utils },
{ "sha1", cmd__sha1 },
};
{ "sha1", cmd__sha1 },
};
diff --git
a/t/helper/test-tool.h
b/t/helper/test-tool.h
index aeabc9740f807c394c6c431a118c90a81db33fb6..3b7ced01f5154df550f583cdff2f15398210e34c 100644
(file)
--- a/
t/helper/test-tool.h
+++ b/
t/helper/test-tool.h
@@
-18,6
+18,7
@@
int cmd__match_trees(int argc, const char **argv);
int cmd__mergesort(int argc, const char **argv);
int cmd__mktemp(int argc, const char **argv);
int cmd__online_cpus(int argc, const char **argv);
int cmd__mergesort(int argc, const char **argv);
int cmd__mktemp(int argc, const char **argv);
int cmd__online_cpus(int argc, const char **argv);
+int cmd__path_utils(int argc, const char **argv);
int cmd__sha1(int argc, const char **argv);
#endif
int cmd__sha1(int argc, const char **argv);
#endif
diff --git
a/t/lib-git-p4.sh
b/t/lib-git-p4.sh
index 54fd5a6ca02757f77004d0f8babfcc6d616162c0..c27599474cf2f272b53e2e76997e5e38af0fe647 100644
(file)
--- a/
t/lib-git-p4.sh
+++ b/
t/lib-git-p4.sh
@@
-39,7
+39,7
@@
native_path () {
then
path=$(cygpath --windows "$path")
else
then
path=$(cygpath --windows "$path")
else
- path=$(test-path-utils real_path "$path")
+ path=$(test-
tool
path-utils real_path "$path")
fi &&
echo "$path"
}
fi &&
echo "$path"
}
diff --git
a/t/t0060-path-utils.sh
b/t/t0060-path-utils.sh
index 7ea2bb515bd80cc026a18dbfdf4a66cb77d27f20..f46e3c4995509f62f954231f53321f1d24756eff 100755
(executable)
--- a/
t/t0060-path-utils.sh
+++ b/
t/t0060-path-utils.sh
@@
-8,15
+8,15
@@
test_description='Test various path utilities'
. ./test-lib.sh
norm_path() {
. ./test-lib.sh
norm_path() {
- expected=$(test-path-utils print_path "$2")
+ expected=$(test-
tool
path-utils print_path "$2")
test_expect_success $3 "normalize path: $1 => $2" \
test_expect_success $3 "normalize path: $1 => $2" \
- "test \"\$(test-path-utils normalize_path_copy '$1')\" = '$expected'"
+ "test \"\$(test-
tool
path-utils normalize_path_copy '$1')\" = '$expected'"
}
relative_path() {
}
relative_path() {
- expected=$(test-path-utils print_path "$3")
+ expected=$(test-
tool
path-utils print_path "$3")
test_expect_success $4 "relative path: $1 $2 => $3" \
test_expect_success $4 "relative path: $1 $2 => $3" \
- "test \"\$(test-path-utils relative_path '$1' '$2')\" = '$expected'"
+ "test \"\$(test-
tool
path-utils relative_path '$1' '$2')\" = '$expected'"
}
test_submodule_relative_url() {
}
test_submodule_relative_url() {
@@
-37,7
+37,7
@@
test_git_path() {
# On Windows, we are using MSYS's bash, which mangles the paths.
# Absolute paths are anchored at the MSYS installation directory,
# which means that the path / accounts for this many characters:
# On Windows, we are using MSYS's bash, which mangles the paths.
# Absolute paths are anchored at the MSYS installation directory,
# which means that the path / accounts for this many characters:
-rootoff=$(test-path-utils normalize_path_copy / | wc -c)
+rootoff=$(test-
tool
path-utils normalize_path_copy / | wc -c)
# Account for the trailing LF:
if test $rootoff = 2; then
rootoff= # we are on Unix
# Account for the trailing LF:
if test $rootoff = 2; then
rootoff= # we are on Unix
@@
-46,7
+46,7
@@
else
# In MSYS2, the root directory "/" is translated into a Windows
# directory *with* trailing slash. Let's test for that and adjust
# our expected longest ancestor length accordingly.
# In MSYS2, the root directory "/" is translated into a Windows
# directory *with* trailing slash. Let's test for that and adjust
# our expected longest ancestor length accordingly.
- case "$(test-path-utils print_path /)" in
+ case "$(test-
tool
path-utils print_path /)" in
*/) rootslash=1;;
*) rootslash=0;;
esac
*/) rootslash=1;;
*) rootslash=0;;
esac
@@
-61,7
+61,7
@@
ancestor() {
expected=$(($expected+$rootoff))
fi
test_expect_success "longest ancestor: $1 $2 => $expected" \
expected=$(($expected+$rootoff))
fi
test_expect_success "longest ancestor: $1 $2 => $expected" \
- "actual=\$(test-path-utils longest_ancestor_length '$1' '$2') &&
+ "actual=\$(test-
tool
path-utils longest_ancestor_length '$1' '$2') &&
test \"\$actual\" = '$expected'"
}
test \"\$actual\" = '$expected'"
}
@@
-77,8
+77,8
@@
case $(uname -s) in
;;
esac
;;
esac
-test_expect_success basename 'test-path-utils basename'
-test_expect_success dirname 'test-path-utils dirname'
+test_expect_success basename 'test-
tool
path-utils basename'
+test_expect_success dirname 'test-
tool
path-utils dirname'
norm_path "" ""
norm_path . ""
norm_path "" ""
norm_path . ""
@@
-157,48
+157,48
@@
ancestor /foo/bar /foo:/bar 4
ancestor /foo/bar /bar -1
test_expect_success 'strip_path_suffix' '
ancestor /foo/bar /bar -1
test_expect_success 'strip_path_suffix' '
- test c:/msysgit = $(test-path-utils strip_path_suffix \
+ test c:/msysgit = $(test-
tool
path-utils strip_path_suffix \
c:/msysgit/libexec//git-core libexec/git-core)
'
test_expect_success 'absolute path rejects the empty string' '
c:/msysgit/libexec//git-core libexec/git-core)
'
test_expect_success 'absolute path rejects the empty string' '
- test_must_fail test-path-utils absolute_path ""
+ test_must_fail test-
tool
path-utils absolute_path ""
'
test_expect_success 'real path rejects the empty string' '
'
test_expect_success 'real path rejects the empty string' '
- test_must_fail test-path-utils real_path ""
+ test_must_fail test-
tool
path-utils real_path ""
'
test_expect_success POSIX 'real path works on absolute paths 1' '
nopath="hopefully-absent-path" &&
'
test_expect_success POSIX 'real path works on absolute paths 1' '
nopath="hopefully-absent-path" &&
- test "/" = "$(test-path-utils real_path "/")" &&
- test "/$nopath" = "$(test-path-utils real_path "/$nopath")"
+ test "/" = "$(test-
tool
path-utils real_path "/")" &&
+ test "/$nopath" = "$(test-
tool
path-utils real_path "/$nopath")"
'
test_expect_success 'real path works on absolute paths 2' '
nopath="hopefully-absent-path" &&
# Find an existing top-level directory for the remaining tests:
d=$(pwd -P | sed -e "s|^\([^/]*/[^/]*\)/.*|\1|") &&
'
test_expect_success 'real path works on absolute paths 2' '
nopath="hopefully-absent-path" &&
# Find an existing top-level directory for the remaining tests:
d=$(pwd -P | sed -e "s|^\([^/]*/[^/]*\)/.*|\1|") &&
- test "$d" = "$(test-path-utils real_path "$d")" &&
- test "$d/$nopath" = "$(test-path-utils real_path "$d/$nopath")"
+ test "$d" = "$(test-
tool
path-utils real_path "$d")" &&
+ test "$d/$nopath" = "$(test-
tool
path-utils real_path "$d/$nopath")"
'
test_expect_success POSIX 'real path removes extra leading slashes' '
nopath="hopefully-absent-path" &&
'
test_expect_success POSIX 'real path removes extra leading slashes' '
nopath="hopefully-absent-path" &&
- test "/" = "$(test-path-utils real_path "///")" &&
- test "/$nopath" = "$(test-path-utils real_path "///$nopath")" &&
+ test "/" = "$(test-
tool
path-utils real_path "///")" &&
+ test "/$nopath" = "$(test-
tool
path-utils real_path "///$nopath")" &&
# Find an existing top-level directory for the remaining tests:
d=$(pwd -P | sed -e "s|^\([^/]*/[^/]*\)/.*|\1|") &&
# Find an existing top-level directory for the remaining tests:
d=$(pwd -P | sed -e "s|^\([^/]*/[^/]*\)/.*|\1|") &&
- test "$d" = "$(test-path-utils real_path "//$d")" &&
- test "$d/$nopath" = "$(test-path-utils real_path "//$d/$nopath")"
+ test "$d" = "$(test-
tool
path-utils real_path "//$d")" &&
+ test "$d/$nopath" = "$(test-
tool
path-utils real_path "//$d/$nopath")"
'
test_expect_success 'real path removes other extra slashes' '
nopath="hopefully-absent-path" &&
# Find an existing top-level directory for the remaining tests:
d=$(pwd -P | sed -e "s|^\([^/]*/[^/]*\)/.*|\1|") &&
'
test_expect_success 'real path removes other extra slashes' '
nopath="hopefully-absent-path" &&
# Find an existing top-level directory for the remaining tests:
d=$(pwd -P | sed -e "s|^\([^/]*/[^/]*\)/.*|\1|") &&
- test "$d" = "$(test-path-utils real_path "$d///")" &&
- test "$d/$nopath" = "$(test-path-utils real_path "$d///$nopath")"
+ test "$d" = "$(test-
tool
path-utils real_path "$d///")" &&
+ test "$d/$nopath" = "$(test-
tool
path-utils real_path "$d///$nopath")"
'
test_expect_success SYMLINKS 'real path works on symlinks' '
'
test_expect_success SYMLINKS 'real path works on symlinks' '
@@
-209,35
+209,35
@@
test_expect_success SYMLINKS 'real path works on symlinks' '
mkdir third &&
dir="$(cd .git; pwd -P)" &&
dir2=third/../second/other/.git &&
mkdir third &&
dir="$(cd .git; pwd -P)" &&
dir2=third/../second/other/.git &&
- test "$dir" = "$(test-path-utils real_path $dir2)" &&
+ test "$dir" = "$(test-
tool
path-utils real_path $dir2)" &&
file="$dir"/index &&
file="$dir"/index &&
- test "$file" = "$(test-path-utils real_path $dir2/index)" &&
+ test "$file" = "$(test-
tool
path-utils real_path $dir2/index)" &&
basename=blub &&
basename=blub &&
- test "$dir/$basename" = "$(cd .git && test-path-utils real_path "$basename")" &&
+ test "$dir/$basename" = "$(cd .git && test-
tool
path-utils real_path "$basename")" &&
ln -s ../first/file .git/syml &&
sym="$(cd first; pwd -P)"/file &&
ln -s ../first/file .git/syml &&
sym="$(cd first; pwd -P)"/file &&
- test "$sym" = "$(test-path-utils real_path "$dir2/syml")"
+ test "$sym" = "$(test-
tool
path-utils real_path "$dir2/syml")"
'
test_expect_success SYMLINKS 'prefix_path works with absolute paths to work tree symlinks' '
ln -s target symlink &&
'
test_expect_success SYMLINKS 'prefix_path works with absolute paths to work tree symlinks' '
ln -s target symlink &&
- test "$(test-path-utils prefix_path prefix "$(pwd)/symlink")" = "symlink"
+ test "$(test-
tool
path-utils prefix_path prefix "$(pwd)/symlink")" = "symlink"
'
test_expect_success 'prefix_path works with only absolute path to work tree' '
echo "" >expected &&
'
test_expect_success 'prefix_path works with only absolute path to work tree' '
echo "" >expected &&
- test-path-utils prefix_path prefix "$(pwd)" >actual &&
+ test-
tool
path-utils prefix_path prefix "$(pwd)" >actual &&
test_cmp expected actual
'
test_expect_success 'prefix_path rejects absolute path to dir with same beginning as work tree' '
test_cmp expected actual
'
test_expect_success 'prefix_path rejects absolute path to dir with same beginning as work tree' '
- test_must_fail test-path-utils prefix_path prefix "$(pwd)a"
+ test_must_fail test-
tool
path-utils prefix_path prefix "$(pwd)a"
'
test_expect_success SYMLINKS 'prefix_path works with absolute path to a symlink to work tree having same beginning as work tree' '
git init repo &&
ln -s repo repolink &&
'
test_expect_success SYMLINKS 'prefix_path works with absolute path to a symlink to work tree having same beginning as work tree' '
git init repo &&
ln -s repo repolink &&
- test "a" = "$(cd repo && test-path-utils prefix_path prefix "$(pwd)/../repolink/a")"
+ test "a" = "$(cd repo && test-
tool
path-utils prefix_path prefix "$(pwd)/../repolink/a")"
'
relative_path /foo/a/b/c/ /foo/a/b/ c/
'
relative_path /foo/a/b/c/ /foo/a/b/ c/
diff --git
a/t/t1501-work-tree.sh
b/t/t1501-work-tree.sh
index b06210ec5e8ffa30b59314b1c79ebc9bdb8f6476..b07cb9140e1b1fe1df0c08eea487bbf5916fe31d 100755
(executable)
--- a/
t/t1501-work-tree.sh
+++ b/
t/t1501-work-tree.sh
@@
-360,7
+360,7
@@
test_expect_success 'GIT_DIR set (1)' '
(
cd work &&
GIT_DIR=../gitfile git rev-parse --git-common-dir >actual &&
(
cd work &&
GIT_DIR=../gitfile git rev-parse --git-common-dir >actual &&
- test-path-utils real_path "$TRASH_DIRECTORY/repo.git" >expect &&
+ test-
tool
path-utils real_path "$TRASH_DIRECTORY/repo.git" >expect &&
test_cmp expect actual
)
'
test_cmp expect actual
)
'
@@
-371,7
+371,7
@@
test_expect_success 'GIT_DIR set (2)' '
(
cd work &&
GIT_DIR=../gitfile git rev-parse --git-common-dir >actual &&
(
cd work &&
GIT_DIR=../gitfile git rev-parse --git-common-dir >actual &&
- test-path-utils real_path "$TRASH_DIRECTORY/repo.git" >expect &&
+ test-
tool
path-utils real_path "$TRASH_DIRECTORY/repo.git" >expect &&
test_cmp expect actual
)
'
test_cmp expect actual
)
'
@@
-382,7
+382,7
@@
test_expect_success 'Auto discovery' '
(
cd work &&
git rev-parse --git-common-dir >actual &&
(
cd work &&
git rev-parse --git-common-dir >actual &&
- test-path-utils real_path "$TRASH_DIRECTORY/repo.git" >expect &&
+ test-
tool
path-utils real_path "$TRASH_DIRECTORY/repo.git" >expect &&
test_cmp expect actual &&
echo haha >data1 &&
git add data1 &&
test_cmp expect actual &&
echo haha >data1 &&
git add data1 &&
@@
-400,7
+400,7
@@
test_expect_success '$GIT_DIR/common overrides core.worktree' '
(
cd work &&
git rev-parse --git-common-dir >actual &&
(
cd work &&
git rev-parse --git-common-dir >actual &&
- test-path-utils real_path "$TRASH_DIRECTORY/repo.git" >expect &&
+ test-
tool
path-utils real_path "$TRASH_DIRECTORY/repo.git" >expect &&
test_cmp expect actual &&
echo haha >data2 &&
git add data2 &&
test_cmp expect actual &&
echo haha >data2 &&
git add data2 &&