Browse Source

Merge branch 'ew/tests'

* ew/tests:
  t6000lib: workaround a possible dash bug
  t5500-fetch-pack: remove local (bashism) usage.
  tests: Remove heredoc usage inside quotes
  t3300-funny-names: shell portability fixes
maint
Junio C Hamano 19 years ago
parent
commit
481176f752
  1. 48
      t/t2101-update-index-reupdate.sh
  2. 51
      t/t3300-funny-names.sh
  3. 17
      t/t4012-diff-binary.sh
  4. 30
      t/t5500-fetch-pack.sh
  5. 4
      t/t6000lib.sh

48
t/t2101-update-index-reupdate.sh

@ -8,15 +8,16 @@ test_description='git-update-index --again test.


. ./test-lib.sh . ./test-lib.sh


cat > expected <<\EOF
100644 3b18e512dba79e4c8300dd08aeb37f8e728b8dad 0 file1
100644 9db8893856a8a02eaa73470054b7c1c5a7c82e47 0 file2
EOF
test_expect_success 'update-index --add' \ test_expect_success 'update-index --add' \
'echo hello world >file1 && 'echo hello world >file1 &&
echo goodbye people >file2 && echo goodbye people >file2 &&
git-update-index --add file1 file2 && git-update-index --add file1 file2 &&
git-ls-files -s >current && git-ls-files -s >current &&
cmp current - <<\EOF cmp current expected'
100644 3b18e512dba79e4c8300dd08aeb37f8e728b8dad 0 file1
100644 9db8893856a8a02eaa73470054b7c1c5a7c82e47 0 file2
EOF'


test_expect_success 'update-index --again' \ test_expect_success 'update-index --again' \
'rm -f file1 && 'rm -f file1 &&
@ -29,20 +30,22 @@ test_expect_success 'update-index --again' \
echo happy - failed as expected echo happy - failed as expected
fi && fi &&
git-ls-files -s >current && git-ls-files -s >current &&
cmp current - <<\EOF cmp current expected'
100644 3b18e512dba79e4c8300dd08aeb37f8e728b8dad 0 file1
100644 9db8893856a8a02eaa73470054b7c1c5a7c82e47 0 file2
EOF'


cat > expected <<\EOF
100644 0f1ae1422c2bf43f117d3dbd715c988a9ed2103f 0 file2
EOF
test_expect_success 'update-index --remove --again' \ test_expect_success 'update-index --remove --again' \
'git-update-index --remove --again && 'git-update-index --remove --again &&
git-ls-files -s >current && git-ls-files -s >current &&
cmp current - <<\EOF cmp current expected'
100644 0f1ae1422c2bf43f117d3dbd715c988a9ed2103f 0 file2
EOF'


test_expect_success 'first commit' 'git-commit -m initial' test_expect_success 'first commit' 'git-commit -m initial'


cat > expected <<\EOF
100644 53ab446c3f4e42ce9bb728a0ccb283a101be4979 0 dir1/file3
100644 0f1ae1422c2bf43f117d3dbd715c988a9ed2103f 0 file2
EOF
test_expect_success 'update-index again' \ test_expect_success 'update-index again' \
'mkdir -p dir1 && 'mkdir -p dir1 &&
echo hello world >dir1/file3 && echo hello world >dir1/file3 &&
@ -52,11 +55,12 @@ test_expect_success 'update-index again' \
echo happy >dir1/file3 && echo happy >dir1/file3 &&
git-update-index --again && git-update-index --again &&
git-ls-files -s >current && git-ls-files -s >current &&
cmp current - <<\EOF cmp current expected'
100644 53ab446c3f4e42ce9bb728a0ccb283a101be4979 0 dir1/file3
100644 0f1ae1422c2bf43f117d3dbd715c988a9ed2103f 0 file2
EOF'


cat > expected <<\EOF
100644 d7fb3f695f06c759dbf3ab00046e7cc2da22d10f 0 dir1/file3
100644 0f1ae1422c2bf43f117d3dbd715c988a9ed2103f 0 file2
EOF
test_expect_success 'update-index --update from subdir' \ test_expect_success 'update-index --update from subdir' \
'echo not so happy >file2 && 'echo not so happy >file2 &&
cd dir1 && cd dir1 &&
@ -64,19 +68,17 @@ test_expect_success 'update-index --update from subdir' \
git-update-index --again && git-update-index --again &&
cd .. && cd .. &&
git-ls-files -s >current && git-ls-files -s >current &&
cmp current - <<\EOF cmp current expected'
100644 d7fb3f695f06c759dbf3ab00046e7cc2da22d10f 0 dir1/file3
100644 0f1ae1422c2bf43f117d3dbd715c988a9ed2103f 0 file2
EOF'


cat > expected <<\EOF
100644 594fb5bb1759d90998e2bf2a38261ae8e243c760 0 dir1/file3
100644 0f1ae1422c2bf43f117d3dbd715c988a9ed2103f 0 file2
EOF
test_expect_success 'update-index --update with pathspec' \ test_expect_success 'update-index --update with pathspec' \
'echo very happy >file2 && 'echo very happy >file2 &&
cat file2 >dir1/file3 && cat file2 >dir1/file3 &&
git-update-index --again dir1/ && git-update-index --again dir1/ &&
git-ls-files -s >current && git-ls-files -s >current &&
cmp current - <<\EOF cmp current expected'
100644 594fb5bb1759d90998e2bf2a38261ae8e243c760 0 dir1/file3
100644 0f1ae1422c2bf43f117d3dbd715c988a9ed2103f 0 file2
EOF'


test_done test_done

51
t/t3300-funny-names.sh

@ -40,9 +40,11 @@ test_expect_success 'git-ls-files no-funny' \
t0=`git-write-tree` t0=`git-write-tree`
echo "$t0" >t0 echo "$t0" >t0


echo 'just space cat > expected <<\EOF
just space
no-funny no-funny
"tabs\t,\" (dq) and spaces"' >expected "tabs\t,\" (dq) and spaces"
EOF
test_expect_success 'git-ls-files with-funny' \ test_expect_success 'git-ls-files with-funny' \
'git-update-index --add "$p1" && 'git-update-index --add "$p1" &&
git-ls-files >current && git-ls-files >current &&
@ -58,14 +60,18 @@ test_expect_success 'git-ls-files -z with-funny' \
t1=`git-write-tree` t1=`git-write-tree`
echo "$t1" >t1 echo "$t1" >t1


echo 'just space cat > expected <<\EOF
just space
no-funny no-funny
"tabs\t,\" (dq) and spaces"' >expected "tabs\t,\" (dq) and spaces"
EOF
test_expect_success 'git-ls-tree with funny' \ test_expect_success 'git-ls-tree with funny' \
'git-ls-tree -r $t1 | sed -e "s/^[^ ]* //" >current && 'git-ls-tree -r $t1 | sed -e "s/^[^ ]* //" >current &&
diff -u expected current' diff -u expected current'


echo 'A "tabs\t,\" (dq) and spaces"' >expected cat > expected <<\EOF
A "tabs\t,\" (dq) and spaces"
EOF
test_expect_success 'git-diff-index with-funny' \ test_expect_success 'git-diff-index with-funny' \
'git-diff-index --name-status $t0 >current && 'git-diff-index --name-status $t0 >current &&
diff -u expected current' diff -u expected current'
@ -84,53 +90,62 @@ test_expect_success 'git-diff-tree -z with-funny' \
'git-diff-tree -z --name-status $t0 $t1 | tr \\0 \\012 >current && 'git-diff-tree -z --name-status $t0 $t1 | tr \\0 \\012 >current &&
diff -u expected current' diff -u expected current'


echo 'CNUM no-funny "tabs\t,\" (dq) and spaces"' >expected cat > expected <<\EOF
CNUM no-funny "tabs\t,\" (dq) and spaces"
EOF
test_expect_success 'git-diff-tree -C with-funny' \ test_expect_success 'git-diff-tree -C with-funny' \
'git-diff-tree -C --find-copies-harder --name-status \ 'git-diff-tree -C --find-copies-harder --name-status \
$t0 $t1 | sed -e 's/^C[0-9]*/CNUM/' >current && $t0 $t1 | sed -e 's/^C[0-9]*/CNUM/' >current &&
diff -u expected current' diff -u expected current'


echo 'RNUM no-funny "tabs\t,\" (dq) and spaces"' >expected cat > expected <<\EOF
RNUM no-funny "tabs\t,\" (dq) and spaces"
EOF
test_expect_success 'git-diff-tree delete with-funny' \ test_expect_success 'git-diff-tree delete with-funny' \
'git-update-index --force-remove "$p0" && 'git-update-index --force-remove "$p0" &&
git-diff-index -M --name-status \ git-diff-index -M --name-status \
$t0 | sed -e 's/^R[0-9]*/RNUM/' >current && $t0 | sed -e 's/^R[0-9]*/RNUM/' >current &&
diff -u expected current' diff -u expected current'


echo 'diff --git a/no-funny "b/tabs\t,\" (dq) and spaces" cat > expected <<\EOF
diff --git a/no-funny "b/tabs\t,\" (dq) and spaces"
similarity index NUM% similarity index NUM%
rename from no-funny rename from no-funny
rename to "tabs\t,\" (dq) and spaces"' >expected rename to "tabs\t,\" (dq) and spaces"

EOF
test_expect_success 'git-diff-tree delete with-funny' \ test_expect_success 'git-diff-tree delete with-funny' \
'git-diff-index -M -p $t0 | 'git-diff-index -M -p $t0 |
sed -e "s/index [0-9]*%/index NUM%/" >current && sed -e "s/index [0-9]*%/index NUM%/" >current &&
diff -u expected current' diff -u expected current'


chmod +x "$p1" chmod +x "$p1"
echo 'diff --git a/no-funny "b/tabs\t,\" (dq) and spaces" cat > expected <<\EOF
diff --git a/no-funny "b/tabs\t,\" (dq) and spaces"
old mode 100644 old mode 100644
new mode 100755 new mode 100755
similarity index NUM% similarity index NUM%
rename from no-funny rename from no-funny
rename to "tabs\t,\" (dq) and spaces"' >expected rename to "tabs\t,\" (dq) and spaces"

EOF
test_expect_success 'git-diff-tree delete with-funny' \ test_expect_success 'git-diff-tree delete with-funny' \
'git-diff-index -M -p $t0 | 'git-diff-index -M -p $t0 |
sed -e "s/index [0-9]*%/index NUM%/" >current && sed -e "s/index [0-9]*%/index NUM%/" >current &&
diff -u expected current' diff -u expected current'


echo >expected ' "tabs\t,\" (dq) and spaces" cat >expected <<\EOF
1 files changed, 0 insertions(+), 0 deletions(-)' "tabs\t,\" (dq) and spaces"
1 files changed, 0 insertions(+), 0 deletions(-)
EOF
test_expect_success 'git-diff-tree rename with-funny applied' \ test_expect_success 'git-diff-tree rename with-funny applied' \
'git-diff-index -M -p $t0 | 'git-diff-index -M -p $t0 |
git-apply --stat | sed -e "s/|.*//" -e "s/ *\$//" >current && git-apply --stat | sed -e "s/|.*//" -e "s/ *\$//" >current &&
diff -u expected current' diff -u expected current'


echo >expected ' no-funny cat > expected <<\EOF
no-funny
"tabs\t,\" (dq) and spaces" "tabs\t,\" (dq) and spaces"
2 files changed, 3 insertions(+), 3 deletions(-)' 2 files changed, 3 insertions(+), 3 deletions(-)

EOF
test_expect_success 'git-diff-tree delete with-funny applied' \ test_expect_success 'git-diff-tree delete with-funny applied' \
'git-diff-index -p $t0 | 'git-diff-index -p $t0 |
git-apply --stat | sed -e "s/|.*//" -e "s/ *\$//" >current && git-apply --stat | sed -e "s/|.*//" -e "s/ *\$//" >current &&

17
t/t4012-diff-binary.sh

@ -16,25 +16,20 @@ test_expect_success 'prepare repository' \
echo git >c && echo git >c &&
cat b b >d' cat b b >d'


test_expect_success 'diff without --binary' \ cat > expected <<\EOF
'git-diff | git-apply --stat --summary >current &&
cmp current - <<\EOF
a | 2 +- a | 2 +-
b | Bin b | Bin
c | 2 +- c | 2 +-
d | Bin d | Bin
4 files changed, 2 insertions(+), 2 deletions(-) 4 files changed, 2 insertions(+), 2 deletions(-)
EOF' EOF
test_expect_success 'diff without --binary' \
'git-diff | git-apply --stat --summary >current &&
cmp current expected'


test_expect_success 'diff with --binary' \ test_expect_success 'diff with --binary' \
'git-diff --binary | git-apply --stat --summary >current && 'git-diff --binary | git-apply --stat --summary >current &&
cmp current - <<\EOF cmp current expected'
a | 2 +-
b | Bin
c | 2 +-
d | Bin
4 files changed, 2 insertions(+), 2 deletions(-)
EOF'


# apply needs to be able to skip the binary material correctly # apply needs to be able to skip the binary material correctly
# in order to report the line number of a corrupt patch. # in order to report the line number of a corrupt patch.

30
t/t5500-fetch-pack.sh

@ -12,11 +12,11 @@ test_description='Testing multi_ack pack fetching


# Some convenience functions # Some convenience functions


function add () { add () {
local name=$1 name=$1
local text="$@" text="$@"
local branch=${name:0:1} branch=`echo $name | sed -e 's/^\(.\).*$/\1/'`
local parents="" parents=""


shift shift
while test $1; do while test $1; do
@ -36,13 +36,13 @@ function add () {
eval ${branch}TIP=$commit eval ${branch}TIP=$commit
} }


function count_objects () { count_objects () {
ls .git/objects/??/* 2>>log2.txt | wc -l | tr -d " " ls .git/objects/??/* 2>>log2.txt | wc -l | tr -d " "
} }


function test_expect_object_count () { test_expect_object_count () {
local message=$1 message=$1
local count=$2 count=$2


output="$(count_objects)" output="$(count_objects)"
test_expect_success \ test_expect_success \
@ -50,18 +50,18 @@ function test_expect_object_count () {
"test $count = $output" "test $count = $output"
} }


function pull_to_client () { pull_to_client () {
local number=$1 number=$1
local heads=$2 heads=$2
local count=$3 count=$3
local no_strict_count_check=$4 no_strict_count_check=$4


cd client cd client
test_expect_success "$number pull" \ test_expect_success "$number pull" \
"git-fetch-pack -k -v .. $heads" "git-fetch-pack -k -v .. $heads"
case "$heads" in *A*) echo $ATIP > .git/refs/heads/A;; esac case "$heads" in *A*) echo $ATIP > .git/refs/heads/A;; esac
case "$heads" in *B*) echo $BTIP > .git/refs/heads/B;; esac case "$heads" in *B*) echo $BTIP > .git/refs/heads/B;; esac
git-symbolic-ref HEAD refs/heads/${heads:0:1} git-symbolic-ref HEAD refs/heads/`echo $heads | sed -e 's/^\(.\).*$/\1/'`


test_expect_success "fsck" 'git-fsck-objects --full > fsck.txt 2>&1' test_expect_success "fsck" 'git-fsck-objects --full > fsck.txt 2>&1'



4
t/t6000lib.sh

@ -69,7 +69,9 @@ on_committer_date()
{ {
_date=$1 _date=$1
shift 1 shift 1
GIT_COMMITTER_DATE=$_date "$@" export GIT_COMMITTER_DATE="$_date"
"$@"
unset GIT_COMMITTER_DATE
} }


# Execute a command and suppress any error output. # Execute a command and suppress any error output.

Loading…
Cancel
Save