Skip to content

Commit a37a672

Browse files
committed
Fix e2e to always specify branch name
As git changes the default from "master" to "main", it's not predictable. Now the test owns the decision.
1 parent e3a2130 commit a37a672

File tree

1 file changed

+39
-19
lines changed

1 file changed

+39
-19
lines changed

test_e2e.sh

Lines changed: 39 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -78,13 +78,15 @@ if [[ -z "$DIR" ]]; then
7878
echo "Failed to make a temp dir"
7979
exit 1
8080
fi
81+
echo
8182
echo "test root is $DIR"
83+
echo
8284

8385
REPO="$DIR/repo"
8486
function init_repo() {
8587
rm -rf "$REPO"
8688
mkdir -p "$REPO"
87-
git -C "$REPO" init -q
89+
git -C "$REPO" init -q -b e2e-branch
8890
touch "$REPO"/file
8991
git -C "$REPO" add file
9092
git -C "$REPO" commit -aqm "init file"
@@ -153,7 +155,7 @@ git -C "$REPO" commit -qam "$TESTCASE"
153155
GIT_SYNC \
154156
--one-time \
155157
--repo="file://$REPO" \
156-
--branch=master \
158+
--branch=e2e-branch \
157159
--rev=HEAD \
158160
--root="$ROOT" \
159161
--dest="link" \
@@ -165,12 +167,13 @@ assert_file_eq "$ROOT"/link/file "$TESTCASE"
165167
pass
166168

167169
##############################################
168-
# Test default syncing
170+
# Test default syncing (master)
169171
##############################################
170-
testcase "default-sync"
172+
testcase "default-sync-master"
171173
# First sync
172174
echo "$TESTCASE 1" > "$REPO"/file
173175
git -C "$REPO" commit -qam "$TESTCASE 1"
176+
git -C "$REPO" checkout -q -b master
174177
GIT_SYNC \
175178
--wait=0.1 \
176179
--repo="file://$REPO" \
@@ -207,7 +210,7 @@ git -C "$REPO" commit -qam "$TESTCASE 1"
207210
GIT_SYNC \
208211
--wait=0.1 \
209212
--repo="file://$REPO" \
210-
--branch=master \
213+
--branch=e2e-branch \
211214
--rev=HEAD \
212215
--root="$ROOT" \
213216
--dest="link" \
@@ -241,7 +244,7 @@ BRANCH="$TESTCASE"--BRANCH
241244
git -C "$REPO" checkout -q -b "$BRANCH"
242245
echo "$TESTCASE 1" > "$REPO"/file
243246
git -C "$REPO" commit -qam "$TESTCASE 1"
244-
git -C "$REPO" checkout -q master
247+
git -C "$REPO" checkout -q e2e-branch
245248
GIT_SYNC \
246249
--wait=0.1 \
247250
--repo="file://$REPO" \
@@ -257,15 +260,15 @@ assert_file_eq "$ROOT"/link/file "$TESTCASE 1"
257260
git -C "$REPO" checkout -q "$BRANCH"
258261
echo "$TESTCASE 2" > "$REPO"/file
259262
git -C "$REPO" commit -qam "$TESTCASE 2"
260-
git -C "$REPO" checkout -q master
263+
git -C "$REPO" checkout -q e2e-branch
261264
sleep 3
262265
assert_link_exists "$ROOT"/link
263266
assert_file_exists "$ROOT"/link/file
264267
assert_file_eq "$ROOT"/link/file "$TESTCASE 2"
265268
# Move the branch backward
266269
git -C "$REPO" checkout -q "$BRANCH"
267270
git -C "$REPO" reset -q --hard HEAD^
268-
git -C "$REPO" checkout -q master
271+
git -C "$REPO" checkout -q e2e-branch
269272
sleep 3
270273
assert_link_exists "$ROOT"/link
271274
assert_file_exists "$ROOT"/link/file
@@ -285,6 +288,7 @@ git -C "$REPO" tag -f "$TAG" >/dev/null
285288
GIT_SYNC \
286289
--wait=0.1 \
287290
--repo="file://$REPO" \
291+
--branch=e2e-branch \
288292
--rev="$TAG" \
289293
--root="$ROOT" \
290294
--dest="link" \
@@ -330,6 +334,7 @@ git -C "$REPO" tag -af "$TAG" -m "$TESTCASE 1" >/dev/null
330334
GIT_SYNC \
331335
--wait=0.1 \
332336
--repo="file://$REPO" \
337+
--branch=e2e-branch \
333338
--rev="$TAG" \
334339
--root="$ROOT" \
335340
--dest="link" \
@@ -374,6 +379,7 @@ REV=$(git -C "$REPO" rev-list -n1 HEAD)
374379
GIT_SYNC \
375380
--wait=0.1 \
376381
--repo="file://$REPO" \
382+
--branch=e2e-branch \
377383
--rev="$REV" \
378384
--root="$ROOT" \
379385
--dest="link" \
@@ -409,6 +415,7 @@ REV=$(git -C "$REPO" rev-list -n1 HEAD)
409415
GIT_SYNC \
410416
--one-time \
411417
--repo="file://$REPO" \
418+
--branch=e2e-branch \
412419
--rev="$REV" \
413420
--root="$ROOT" \
414421
--dest="link" \
@@ -429,6 +436,7 @@ git -C "$REPO" commit -qam "$TESTCASE 1"
429436
GIT_SYNC \
430437
--one-time \
431438
--repo="file://$REPO" \
439+
--branch=e2e-branch \
432440
--root="$ROOT" \
433441
--dest="link" \
434442
> "$DIR"/log."$TESTCASE" 2>&1
@@ -441,6 +449,7 @@ rm -f "$ROOT"/link
441449
GIT_SYNC \
442450
--one-time \
443451
--repo="file://$REPO" \
452+
--branch=e2e-branch \
444453
--root="$ROOT" \
445454
--dest="link" \
446455
> "$DIR"/log."$TESTCASE" 2>&1
@@ -462,6 +471,7 @@ GIT_SYNC \
462471
--one-time \
463472
--timeout=1 \
464473
--repo="file://$REPO" \
474+
--branch=e2e-branch \
465475
--root="$ROOT" \
466476
--dest="link" \
467477
> "$DIR"/log."$TESTCASE" 2>&1 || true
@@ -473,6 +483,7 @@ GIT_SYNC \
473483
--wait=0.1 \
474484
--timeout=16 \
475485
--repo="file://$REPO" \
486+
--branch=e2e-branch \
476487
--root="$ROOT" \
477488
--dest="link" \
478489
> "$DIR"/log."$TESTCASE" 2>&1 &
@@ -501,6 +512,7 @@ git -C "$REPO" commit -qam "$TESTCASE 1"
501512
GIT_SYNC \
502513
--wait=0.1 \
503514
--repo="file://$REPO" \
515+
--branch=e2e-branch \
504516
--depth="$expected_depth" \
505517
--root="$ROOT" \
506518
--dest="link" \
@@ -550,7 +562,7 @@ GIT_SYNC \
550562
--password="wrong" \
551563
--one-time \
552564
--repo="file://$REPO" \
553-
--branch=master \
565+
--branch=e2e-branch \
554566
--rev=HEAD \
555567
--root="$ROOT" \
556568
--dest="link" \
@@ -564,7 +576,7 @@ GIT_SYNC \
564576
--password="my-password" \
565577
--one-time \
566578
--repo="file://$REPO" \
567-
--branch=master \
579+
--branch=e2e-branch \
568580
--rev=HEAD \
569581
--root="$ROOT" \
570582
--dest="link" \
@@ -595,7 +607,7 @@ GIT_SYNC \
595607
--askpass-url="http://localhost:$NCPORT/git_askpass" \
596608
--one-time \
597609
--repo="file://$REPO" \
598-
--branch=master \
610+
--branch=e2e-branch \
599611
--rev=HEAD \
600612
--root="$ROOT" \
601613
--dest="link" \
@@ -615,7 +627,7 @@ GIT_SYNC \
615627
--askpass-url="http://localhost:$NCPORT/git_askpass" \
616628
--one-time \
617629
--repo="file://$REPO" \
618-
--branch=master \
630+
--branch=e2e-branch \
619631
--rev=HEAD \
620632
--root="$ROOT" \
621633
--dest="link" \
@@ -636,6 +648,7 @@ git -C "$REPO" commit -qam "$TESTCASE 1"
636648
GIT_SYNC \
637649
--wait=0.1 \
638650
--repo="file://$REPO" \
651+
--branch=e2e-branch \
639652
--root="$ROOT" \
640653
--dest="link" \
641654
--sync-hook-command="$SYNC_HOOK_COMMAND" \
@@ -668,6 +681,7 @@ echo "$TESTCASE 1" > "$REPO"/file
668681
git -C "$REPO" commit -qam "$TESTCASE 1"
669682
GIT_SYNC \
670683
--repo="file://$REPO" \
684+
--branch=e2e-branch \
671685
--root="$ROOT" \
672686
--webhook-url="http://127.0.0.1:$NCPORT" \
673687
--webhook-success-status=200 \
@@ -710,6 +724,7 @@ echo "$TESTCASE 1" > "$REPO"/file
710724
git -C "$REPO" commit -qam "$TESTCASE 1"
711725
GIT_SYNC \
712726
--repo="file://$REPO" \
727+
--branch=e2e-branch \
713728
--root="$ROOT" \
714729
--webhook-url="http://127.0.0.1:$NCPORT" \
715730
--webhook-success-status=-1 \
@@ -736,6 +751,7 @@ git -C "$REPO" commit -qam "$TESTCASE 1"
736751
GIT_SYNC \
737752
--git="$SLOW_GIT" \
738753
--repo="file://$REPO" \
754+
--branch=e2e-branch \
739755
--root="$ROOT" \
740756
--http-bind=":$BINDPORT" \
741757
--http-metrics \
@@ -776,7 +792,7 @@ SUBMODULE_REPO_NAME="sub"
776792
SUBMODULE="$DIR/$SUBMODULE_REPO_NAME"
777793
mkdir "$SUBMODULE"
778794

779-
git -C "$SUBMODULE" init -q
795+
git -C "$SUBMODULE" init -q -b e2e-branch
780796
echo "submodule" > "$SUBMODULE"/submodule
781797
git -C "$SUBMODULE" add submodule
782798
git -C "$SUBMODULE" commit -aqm "init submodule file"
@@ -786,7 +802,7 @@ NESTED_SUBMODULE_REPO_NAME="nested-sub"
786802
NESTED_SUBMODULE="$DIR/$NESTED_SUBMODULE_REPO_NAME"
787803
mkdir "$NESTED_SUBMODULE"
788804

789-
git -C "$NESTED_SUBMODULE" init -q
805+
git -C "$NESTED_SUBMODULE" init -q -b e2e-branch
790806
echo "nested-submodule" > "$NESTED_SUBMODULE"/nested-submodule
791807
git -C "$NESTED_SUBMODULE" add nested-submodule
792808
git -C "$NESTED_SUBMODULE" commit -aqm "init nested-submodule file"
@@ -797,6 +813,7 @@ git -C "$REPO" commit -aqm "add submodule"
797813
GIT_SYNC \
798814
--wait=0.1 \
799815
--repo="file://$REPO" \
816+
--branch=e2e-branch \
800817
--root="$ROOT" \
801818
--dest="link" \
802819
> "$DIR"/log."$TESTCASE" 2>&1 &
@@ -871,7 +888,7 @@ SUBMODULE_REPO_NAME="sub"
871888
SUBMODULE="$DIR/$SUBMODULE_REPO_NAME"
872889
mkdir "$SUBMODULE"
873890

874-
git -C "$SUBMODULE" init > /dev/null
891+
git -C "$SUBMODULE" init -b e2e-branch > /dev/null
875892

876893
# First sync
877894
expected_depth="1"
@@ -884,6 +901,7 @@ git -C "$REPO" commit -qam "$TESTCASE 1"
884901
GIT_SYNC \
885902
--wait=0.1 \
886903
--repo="file://$REPO" \
904+
--branch=e2e-branch \
887905
--depth="$expected_depth" \
888906
--root="$ROOT" \
889907
--dest="link" \
@@ -947,7 +965,7 @@ SUBMODULE_REPO_NAME="sub"
947965
SUBMODULE="$DIR/$SUBMODULE_REPO_NAME"
948966
mkdir "$SUBMODULE"
949967

950-
git -C "$SUBMODULE" init -q
968+
git -C "$SUBMODULE" init -q -b e2e-branch
951969
echo "submodule" > "$SUBMODULE"/submodule
952970
git -C "$SUBMODULE" add submodule
953971
git -C "$SUBMODULE" commit -aqm "init submodule file"
@@ -960,6 +978,7 @@ GIT_SYNC \
960978
--submodules=off \
961979
--wait=0.1 \
962980
--repo="file://$REPO" \
981+
--branch=e2e-branch \
963982
--root="$ROOT" \
964983
--dest="link" \
965984
> "$DIR"/log."$TESTCASE" 2>&1 &
@@ -978,7 +997,7 @@ SUBMODULE_REPO_NAME="sub"
978997
SUBMODULE="$DIR/$SUBMODULE_REPO_NAME"
979998
mkdir "$SUBMODULE"
980999

981-
git -C "$SUBMODULE" init -q
1000+
git -C "$SUBMODULE" init -q -b e2e-branch
9821001
echo "submodule" > "$SUBMODULE"/submodule
9831002
git -C "$SUBMODULE" add submodule
9841003
git -C "$SUBMODULE" commit -aqm "init submodule file"
@@ -987,7 +1006,7 @@ NESTED_SUBMODULE_REPO_NAME="nested-sub"
9871006
NESTED_SUBMODULE="$DIR/$NESTED_SUBMODULE_REPO_NAME"
9881007
mkdir "$NESTED_SUBMODULE"
9891008

990-
git -C "$NESTED_SUBMODULE" init -q
1009+
git -C "$NESTED_SUBMODULE" init -q -b e2e-branch
9911010
echo "nested-submodule" > "$NESTED_SUBMODULE"/nested-submodule
9921011
git -C "$NESTED_SUBMODULE" add nested-submodule
9931012
git -C "$NESTED_SUBMODULE" commit -aqm "init nested-submodule file"
@@ -1002,6 +1021,7 @@ GIT_SYNC \
10021021
--submodules=shallow \
10031022
--wait=0.1 \
10041023
--repo="file://$REPO" \
1024+
--branch=e2e-branch \
10051025
--root="$ROOT" \
10061026
--dest="link" \
10071027
> "$DIR"/log."$TESTCASE" 2>&1 &
@@ -1035,7 +1055,7 @@ GIT_SYNC \
10351055
--ssh \
10361056
--ssh-known-hosts=false \
10371057
--repo="test@$IP:/src" \
1038-
--branch=master \
1058+
--branch=e2e-branch \
10391059
--rev=HEAD \
10401060
--root="$ROOT" \
10411061
--dest="link" \

0 commit comments

Comments
 (0)