Skip to content

Commit

Permalink
Add test for new git default branch handling
Browse files Browse the repository at this point in the history
  • Loading branch information
cannam committed Apr 3, 2024
1 parent 02d125e commit 09749e9
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 13 deletions.
27 changes: 14 additions & 13 deletions test/tests/include.sh
Original file line number Diff line number Diff line change
Expand Up @@ -88,29 +88,30 @@ EOF
fi
}

check_id() {
local actual="$1"
local expected="$2"
local repo="$3"
if [ "$actual" != "$expected" ]; then
echo "ERROR: id for repo $repo ($actual) does not match expected ($expected)"
exit 3
fi
}

check_expected_with_extpath() {
echo "Checking external repo IDs against expected values..."
local extpath="$1"
local id_A="$2"
local id_B="$3"
local id_C="$4"
local actual_id_A=$( cd "$extpath"/A ; hg id | awk '{ print $1 }' | sed 's/\+$//' )
if [ "$actual_id_A" != "$id_A" ]; then
echo "ERROR: id for repo A ($actual_id_A) does not match expected ($id_A)"
exit 3
fi
check_id "$actual_id_A" "$id_A" "A"
local actual_id_B=$( cd "$extpath"/B ; git rev-parse HEAD )
if [ "$actual_id_B" != "$id_B" ]; then
echo "ERROR: id for repo B ($actual_id_B) does not match expected ($id_B)"
exit 3
fi
check_id "$actual_id_B" "$id_B" "B"
# NB we don't use "svn info --show-item revision" because we still
# want svn 1.8 compatibility (at the time of writing)a
# want svn 1.8 compatibility (at the time of writing)
local actual_id_C=$( cd "$extpath"/C ; svn info | grep '^Revision:' | awk '{ print $2; }' )
if [ "$actual_id_C" != "$id_C" ]; then
echo "ERROR: id for repo C ($actual_id_C) does not match expected ($id_C)"
exit 3
fi
check_id "$actual_id_C" "$id_C" "C"
check_expected_lockfile "$id_A" "$id_B" "$id_C"
}

Expand Down
64 changes: 64 additions & 0 deletions test/tests/test-git-other-default.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
#!/bin/bash

. $(dirname "$0")/include.sh

libcontent_nobranch=$(cat <<EOF
"B": {
"vcs": "git",
"service": "testfile"
},
"Bmain": {
"vcs": "git",
"service": "testfile"
}
EOF
)

libcontent_branch=$(cat <<EOF
"B": {
"vcs": "git",
"service": "testfile",
"branch": "b2"
},
"Bmain": {
"vcs": "git",
"service": "testfile",
"branch": "b2"
}
EOF
)

prepare
write_project_file "$libcontent_nobranch"

"$repoint" install

id_default=3199655c658ff337ce24f78c6d1f410f34f4c6f2
id_b2=7219cf6e6d4706295246d278a3821ea923e1dfe2

actual=$( cd ext/B ; git rev-parse HEAD )
check_id "$actual" "$id_default" "B"

actual=$( cd ext/Bmain ; git rev-parse HEAD )
check_id "$actual" "$id_default" "Bmain"

write_project_file "$libcontent_branch"

"$repoint" update

actual=$( cd ext/B ; git rev-parse HEAD )
check_id "$actual" "$id_b2" "B"

actual=$( cd ext/Bmain ; git rev-parse HEAD )
check_id "$actual" "$id_b2" "Bmain"

write_project_file "$libcontent_nobranch"

"$repoint" update

actual=$( cd ext/B ; git rev-parse HEAD )
check_id "$actual" "$id_default" "B"

actual=$( cd ext/Bmain ; git rev-parse HEAD )
check_id "$actual" "$id_default" "Bmain"

0 comments on commit 09749e9

Please sign in to comment.