Follow upstream changes -- Bytestring updates
[git-darcs-import.git] / tests / ssh.sh
blobea790c5df9d0907d7d27cde0dc43cc2e75eb54ae
1 #!/usr/bin/env bash
2 set -ev
4 if [ x${REMOTE_DIR} = x ]; then
5 REMOTE_DIR=sshtest
6 fi
8 if [ x"${USE_PUTTY}" != x ]; then
9 DARCS_SSH=plink
10 export DARCS_SSH
11 DARCS_SCP=pscp
12 export DARCS_SCP
13 DARCS_SFTP=psftp
14 export DARCS_SFTP
17 if [ x"${USE_CONTROL_MASTER}" != x ]; then
18 DARCS_SSH_FLAGS="--ssh-cm"
19 export DARCS_SSH_FLAGS
22 if [ x"${DARCS_SSH}" = x ]; then
23 SSH=ssh
24 else
25 SSH=${DARCS_SSH}
28 rm -rf tempssh
29 mkdir tempssh
30 cd tempssh
32 cleanup () {
33 cd ..
34 rm -rf tempssh
37 if [ x${REMOTE} = x ]; then
38 echo
39 echo "Note: to enable full SSH testing, set REMOTE to some SSH path first,"
40 echo " e.g. REMOTE=you@server.org $0"
41 cleanup
42 exit 0 # exit normally in case we are being run from the shell harness
45 # ================ Setting up remote repositories ===============
46 ${SSH} ${REMOTE} "\
47 rm -rf ${REMOTE_DIR}; \
48 mkdir ${REMOTE_DIR}; \
49 cd ${REMOTE_DIR}; \
51 mkdir testrepo; cd testrepo; \
52 darcs init; \
53 echo moi > _darcs/prefs/author; \
54 touch a; darcs add a; darcs record a --ignore-times -am 'add file a'; \
55 echo 'first line' > a; darcs record a --ignore-times -am 'add first line to a'; \
56 cd ..; \
58 darcs get testrepo testrepo-pull; \
59 cd testrepo-pull; \
60 echo moi > _darcs/prefs/author; \
61 touch b; darcs add b; darcs record b --ignore-times -am 'add file b'; \
62 echo 'other line' > b; darcs record b --ignore-times -am 'add other line to b'; \
63 cd ..; \
65 darcs get testrepo testrepo-push; \
66 darcs get testrepo testrepo-send; \
69 # ================ Settings ===============
70 echo ${DARCS_SSH_FLAGS}
71 echo ${DARCS_SSH}
72 echo ${DARCS_SCP}
73 echo ${DARCS_SFTP}
75 # ================ Checking darcs get ==================
76 ${DARCS} get ${DARCS_SSH_FLAGS} ${REMOTE}:${REMOTE_DIR}/testrepo ${DARCS_SSH_FLAGS}
77 # check that the test repo made it over
78 [ -d testrepo ]
79 [ -d testrepo/_darcs ]
80 [ -f testrepo/a ]
82 # if the above test is disabled we just init a blank repo
83 # so that the other tests can continue
84 if [ ! -d testrepo ]; then
85 mkdir testrepo
86 cd testrepo
87 darcs init
88 cd ..
91 # ================ Checking darcs pull =================
92 ${DARCS} get ${DARCS_SSH_FLAGS} testrepo testrepo-pull
93 cd testrepo-pull
94 echo yy | ${DARCS} pull ${DARCS_SSH_FLAGS} ${REMOTE}:${REMOTE_DIR}/testrepo-pull
95 # see if the changes got pulled over
96 grep "other line" b
98 cd ..
100 # ================ Checking darcs push and send ================="
101 ${DARCS} get ${DARCS_SSH_FLAGS} testrepo testrepo-push
102 cd testrepo-push
103 echo moi > _darcs/prefs/author
104 echo "second line" >> a; ${DARCS} record a --ignore-times -am "add second line to a"
105 touch c; ${DARCS} add c
106 ${DARCS} record --ignore-times -am "add file c" c
107 echo yy | ${DARCS} push ${DARCS_SSH_FLAGS} ${REMOTE}:${REMOTE_DIR}/testrepo-push
108 # check that the file c got pushed over
109 ${SSH} ${REMOTE} "[ -f ${REMOTE_DIR}/testrepo-push/c ]"
110 echo yy | ${DARCS} send ${DARCS_SSH_FLAGS} ${REMOTE}:${REMOTE_DIR}/testrepo-send -o mybundle.dpatch
111 # check that the bundle was created
112 grep "add file c" mybundle.dpatch
113 cd ..
115 # ================ Checking darcs put =================="
116 cd testrepo
117 ${DARCS} put ${DARCS_SSH_FLAGS} ${REMOTE}:${REMOTE_DIR}/testrepo-put
118 # check that the put was successful
119 ${SSH} ${REMOTE} "[ -d ${REMOTE_DIR}/testrepo-put/_darcs ]"
120 ${SSH} ${REMOTE} "[ -f ${REMOTE_DIR}/testrepo-put/a ]"
121 cd ..
123 # ======== Checking push over ssh with a conflict ========="
124 ${SSH} ${REMOTE} "echo apply no-allow-conflicts >> ${REMOTE_DIR}/testrepo-put/_darcs/prefs/defaults"
126 cd testrepo
127 echo 'change for remote' > a
128 darcs record --ignore-times -am 'change for remote'
129 darcs push -a
130 darcs ob --last 1 -a
131 echo 'change for local' > a
132 darcs record --ignore-times -am 'change for local'
134 if darcs push -a 2>&1 | grep -q 'conflicts options to apply' ; then
135 # do nothing.
136 echo "OK";
137 else
138 exit 1;
141 cd ..
143 cleanup