contrib / remote-helpers / test-bzr.shon commit Merge branch 'tb/shared-perm' (e65cdde)
   1#!/bin/sh
   2#
   3# Copyright (c) 2012 Felipe Contreras
   4#
   5
   6test_description='Test remote-bzr'
   7
   8. ./test-lib.sh
   9
  10if ! test_have_prereq PYTHON; then
  11        skip_all='skipping remote-bzr tests; python not available'
  12        test_done
  13fi
  14
  15if ! "$PYTHON_PATH" -c 'import bzrlib'; then
  16        skip_all='skipping remote-bzr tests; bzr not available'
  17        test_done
  18fi
  19
  20check () {
  21        (cd $1 &&
  22        git log --format='%s' -1 &&
  23        git symbolic-ref HEAD) > actual &&
  24        (echo $2 &&
  25        echo "refs/heads/$3") > expected &&
  26        test_cmp expected actual
  27}
  28
  29bzr whoami "A U Thor <author@example.com>"
  30
  31test_expect_success 'cloning' '
  32  (bzr init bzrrepo &&
  33  cd bzrrepo &&
  34  echo one > content &&
  35  bzr add content &&
  36  bzr commit -m one
  37  ) &&
  38
  39  git clone "bzr::$PWD/bzrrepo" gitrepo &&
  40  check gitrepo one master
  41'
  42
  43test_expect_success 'pulling' '
  44  (cd bzrrepo &&
  45  echo two > content &&
  46  bzr commit -m two
  47  ) &&
  48
  49  (cd gitrepo && git pull) &&
  50
  51  check gitrepo two master
  52'
  53
  54test_expect_success 'pushing' '
  55  (cd gitrepo &&
  56  echo three > content &&
  57  git commit -a -m three &&
  58  git push
  59  ) &&
  60
  61  echo three > expected &&
  62  cat bzrrepo/content > actual &&
  63  test_cmp expected actual
  64'
  65
  66test_expect_success 'roundtrip' '
  67  (cd gitrepo &&
  68  git pull &&
  69  git log --format="%s" -1 origin/master > actual) &&
  70  echo three > expected &&
  71  test_cmp expected actual &&
  72
  73  (cd gitrepo && git push && git pull) &&
  74
  75  (cd bzrrepo &&
  76  echo four > content &&
  77  bzr commit -m four
  78  ) &&
  79
  80  (cd gitrepo && git pull && git push) &&
  81
  82  check gitrepo four master &&
  83
  84  (cd gitrepo &&
  85  echo five > content &&
  86  git commit -a -m five &&
  87  git push && git pull
  88  ) &&
  89
  90  (cd bzrrepo && bzr revert) &&
  91
  92  echo five > expected &&
  93  cat bzrrepo/content > actual &&
  94  test_cmp expected actual
  95'
  96
  97cat > expected <<EOF
  98100644 blob 54f9d6da5c91d556e6b54340b1327573073030af    content
  99100755 blob 68769579c3eaadbe555379b9c3538e6628bae1eb    executable
 100120000 blob 6b584e8ece562ebffc15d38808cd6b98fc3d97ea    link
 101EOF
 102
 103test_expect_success 'special modes' '
 104  (cd bzrrepo &&
 105  echo exec > executable
 106  chmod +x executable &&
 107  bzr add executable
 108  bzr commit -m exec &&
 109  ln -s content link
 110  bzr add link
 111  bzr commit -m link &&
 112  mkdir dir &&
 113  bzr add dir &&
 114  bzr commit -m dir) &&
 115
 116  (cd gitrepo &&
 117  git pull
 118  git ls-tree HEAD > ../actual) &&
 119
 120  test_cmp expected actual &&
 121
 122  (cd gitrepo &&
 123  git cat-file -p HEAD:link > ../actual) &&
 124
 125  printf content > expected &&
 126  test_cmp expected actual
 127'
 128
 129cat > expected <<EOF
 130100644 blob 54f9d6da5c91d556e6b54340b1327573073030af    content
 131100755 blob 68769579c3eaadbe555379b9c3538e6628bae1eb    executable
 132120000 blob 6b584e8ece562ebffc15d38808cd6b98fc3d97ea    link
 133040000 tree 35c0caa46693cef62247ac89a680f0c5ce32b37b    movedir-new
 134EOF
 135
 136test_expect_success 'moving directory' '
 137  (cd bzrrepo &&
 138  mkdir movedir &&
 139  echo one > movedir/one &&
 140  echo two > movedir/two &&
 141  bzr add movedir &&
 142  bzr commit -m movedir &&
 143  bzr mv movedir movedir-new &&
 144  bzr commit -m movedir-new) &&
 145
 146  (cd gitrepo &&
 147  git pull &&
 148  git ls-tree HEAD > ../actual) &&
 149
 150  test_cmp expected actual
 151'
 152
 153test_expect_success 'different authors' '
 154  (cd bzrrepo &&
 155  echo john >> content &&
 156  bzr commit -m john \
 157    --author "Jane Rey <jrey@example.com>" \
 158    --author "John Doe <jdoe@example.com>") &&
 159
 160  (cd gitrepo &&
 161  git pull &&
 162  git show --format="%an <%ae>, %cn <%ce>" --quiet > ../actual) &&
 163
 164  echo "Jane Rey <jrey@example.com>, A U Thor <author@example.com>" > expected &&
 165  test_cmp expected actual
 166'
 167
 168test_expect_success 'fetch utf-8 filenames' '
 169  mkdir -p tmp && cd tmp &&
 170  test_when_finished "cd .. && rm -rf tmp && LC_ALL=C" &&
 171
 172  export LC_ALL=en_US.UTF-8
 173
 174  (
 175  bzr init bzrrepo &&
 176  cd bzrrepo &&
 177
 178  echo test >> "áéíóú" &&
 179  bzr add "áéíóú" &&
 180  bzr commit -m utf-8
 181  ) &&
 182
 183  (
 184  git clone "bzr::$PWD/bzrrepo" gitrepo &&
 185  cd gitrepo &&
 186  git ls-files > ../actual
 187  ) &&
 188
 189  echo "\"\\303\\241\\303\\251\\303\\255\\303\\263\\303\\272\"" > expected &&
 190  test_cmp expected actual
 191'
 192
 193test_expect_success 'push utf-8 filenames' '
 194  mkdir -p tmp && cd tmp &&
 195  test_when_finished "cd .. && rm -rf tmp && LC_ALL=C" &&
 196
 197  export LC_ALL=en_US.UTF-8
 198
 199  (
 200  bzr init bzrrepo &&
 201  cd bzrrepo &&
 202
 203  echo one >> content &&
 204  bzr add content &&
 205  bzr commit -m one
 206  ) &&
 207
 208  (
 209  git clone "bzr::$PWD/bzrrepo" gitrepo &&
 210  cd gitrepo &&
 211
 212  echo test >> "áéíóú" &&
 213  git add "áéíóú" &&
 214  git commit -m utf-8 &&
 215
 216  git push
 217  ) &&
 218
 219  (cd bzrrepo && bzr ls > ../actual) &&
 220  echo -e "content\náéíóú" > expected &&
 221  test_cmp expected actual
 222'
 223
 224test_done