contrib / remote-helpers / test-bzr.shon commit remote-hg: add missing &&s in the test (8493fd1)
   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 -c 'import bzrlib'; then
  16        skip_all='skipping remote-bzr tests; bzr not available'
  17        test_done
  18fi
  19
  20check () {
  21        echo $3 > expected &&
  22        git --git-dir=$1/.git log --format='%s' -1 $2 > actual
  23        test_cmp expected actual
  24}
  25
  26bzr whoami "A U Thor <author@example.com>"
  27
  28test_expect_success 'cloning' '
  29        (
  30        bzr init bzrrepo &&
  31        cd bzrrepo &&
  32        echo one > content &&
  33        bzr add content &&
  34        bzr commit -m one
  35        ) &&
  36
  37        git clone "bzr::bzrrepo" gitrepo &&
  38        check gitrepo HEAD one
  39'
  40
  41test_expect_success 'pulling' '
  42        (
  43        cd bzrrepo &&
  44        echo two > content &&
  45        bzr commit -m two
  46        ) &&
  47
  48        (cd gitrepo && git pull) &&
  49
  50        check gitrepo HEAD two
  51'
  52
  53test_expect_success 'pushing' '
  54        (
  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        (
  68        cd gitrepo &&
  69        git pull &&
  70        git log --format="%s" -1 origin/master > actual
  71        ) &&
  72        echo three > expected &&
  73        test_cmp expected actual &&
  74
  75        (cd gitrepo && git push && git pull) &&
  76
  77        (
  78        cd bzrrepo &&
  79        echo four > content &&
  80        bzr commit -m four
  81        ) &&
  82
  83        (cd gitrepo && git pull && git push) &&
  84
  85        check gitrepo HEAD four &&
  86
  87        (
  88        cd gitrepo &&
  89        echo five > content &&
  90        git commit -a -m five &&
  91        git push && git pull
  92        ) &&
  93
  94        (cd bzrrepo && bzr revert) &&
  95
  96        echo five > expected &&
  97        cat bzrrepo/content > actual &&
  98        test_cmp expected actual
  99'
 100
 101cat > expected <<EOF
 102100644 blob 54f9d6da5c91d556e6b54340b1327573073030af    content
 103100755 blob 68769579c3eaadbe555379b9c3538e6628bae1eb    executable
 104120000 blob 6b584e8ece562ebffc15d38808cd6b98fc3d97ea    link
 105EOF
 106
 107test_expect_success 'special modes' '
 108        (
 109        cd bzrrepo &&
 110        echo exec > executable
 111        chmod +x executable &&
 112        bzr add executable
 113        bzr commit -m exec &&
 114        ln -s content link
 115        bzr add link
 116        bzr commit -m link &&
 117        mkdir dir &&
 118        bzr add dir &&
 119        bzr commit -m dir
 120        ) &&
 121
 122        (
 123        cd gitrepo &&
 124        git pull
 125        git ls-tree HEAD > ../actual
 126        ) &&
 127
 128        test_cmp expected actual &&
 129
 130        (
 131        cd gitrepo &&
 132        git cat-file -p HEAD:link > ../actual
 133        ) &&
 134
 135        printf content > expected &&
 136        test_cmp expected actual
 137'
 138
 139cat > expected <<EOF
 140100644 blob 54f9d6da5c91d556e6b54340b1327573073030af    content
 141100755 blob 68769579c3eaadbe555379b9c3538e6628bae1eb    executable
 142120000 blob 6b584e8ece562ebffc15d38808cd6b98fc3d97ea    link
 143040000 tree 35c0caa46693cef62247ac89a680f0c5ce32b37b    movedir-new
 144EOF
 145
 146test_expect_success 'moving directory' '
 147        (
 148        cd bzrrepo &&
 149        mkdir movedir &&
 150        echo one > movedir/one &&
 151        echo two > movedir/two &&
 152        bzr add movedir &&
 153        bzr commit -m movedir &&
 154        bzr mv movedir movedir-new &&
 155        bzr commit -m movedir-new
 156        ) &&
 157
 158        (
 159        cd gitrepo &&
 160        git pull &&
 161        git ls-tree HEAD > ../actual
 162        ) &&
 163
 164        test_cmp expected actual
 165'
 166
 167test_expect_success 'different authors' '
 168        (
 169        cd bzrrepo &&
 170        echo john >> content &&
 171        bzr commit -m john \
 172          --author "Jane Rey <jrey@example.com>" \
 173          --author "John Doe <jdoe@example.com>"
 174        ) &&
 175
 176        (
 177        cd gitrepo &&
 178        git pull &&
 179        git show --format="%an <%ae>, %cn <%ce>" --quiet > ../actual
 180        ) &&
 181
 182        echo "Jane Rey <jrey@example.com>, A U Thor <author@example.com>" > expected &&
 183        test_cmp expected actual
 184'
 185
 186# cleanup previous stuff
 187rm -rf bzrrepo gitrepo
 188
 189test_expect_success 'fetch utf-8 filenames' '
 190        test_when_finished "rm -rf bzrrepo gitrepo && LC_ALL=C" &&
 191
 192        LC_ALL=en_US.UTF-8
 193        export LC_ALL
 194
 195        (
 196        bzr init bzrrepo &&
 197        cd bzrrepo &&
 198
 199        echo test >> "ærø" &&
 200        bzr add "ærø" &&
 201        echo test >> "ø~?" &&
 202        bzr add "ø~?" &&
 203        bzr commit -m add-utf-8 &&
 204        echo test >> "ærø" &&
 205        bzr commit -m test-utf-8 &&
 206        bzr rm "ø~?" &&
 207        bzr mv "ærø" "ø~?" &&
 208        bzr commit -m bzr-mv-utf-8
 209        ) &&
 210
 211        (
 212        git clone "bzr::bzrrepo" gitrepo &&
 213        cd gitrepo &&
 214        git -c core.quotepath=false ls-files > ../actual
 215        ) &&
 216        echo "ø~?" > expected &&
 217        test_cmp expected actual
 218'
 219
 220test_expect_success 'push utf-8 filenames' '
 221        test_when_finished "rm -rf bzrrepo gitrepo && LC_ALL=C" &&
 222
 223        mkdir -p tmp && cd tmp &&
 224
 225        LC_ALL=en_US.UTF-8
 226        export LC_ALL
 227
 228        (
 229        bzr init bzrrepo &&
 230        cd bzrrepo &&
 231
 232        echo one >> content &&
 233        bzr add content &&
 234        bzr commit -m one
 235        ) &&
 236
 237        (
 238        git clone "bzr::bzrrepo" gitrepo &&
 239        cd gitrepo &&
 240
 241        echo test >> "ærø" &&
 242        git add "ærø" &&
 243        git commit -m utf-8 &&
 244
 245        git push
 246        ) &&
 247
 248        (cd bzrrepo && bzr ls > ../actual) &&
 249        printf "content\nærø\n" > expected &&
 250        test_cmp expected actual
 251'
 252
 253test_expect_success 'pushing a merge' '
 254        test_when_finished "rm -rf bzrrepo gitrepo" &&
 255
 256        (
 257        bzr init bzrrepo &&
 258        cd bzrrepo &&
 259        echo one > content &&
 260        bzr add content &&
 261        bzr commit -m one
 262        ) &&
 263
 264        git clone "bzr::bzrrepo" gitrepo &&
 265
 266        (
 267        cd bzrrepo &&
 268        echo two > content &&
 269        bzr commit -m two
 270        ) &&
 271
 272        (
 273        cd gitrepo &&
 274        echo three > content &&
 275        git commit -a -m three &&
 276        git fetch &&
 277        git merge origin/master || true &&
 278        echo three > content &&
 279        git commit -a --no-edit &&
 280        git push
 281        ) &&
 282
 283        echo three > expected &&
 284        cat bzrrepo/content > actual &&
 285        test_cmp expected actual
 286'
 287
 288cat > expected <<EOF
 289origin/HEAD
 290origin/branch
 291origin/trunk
 292EOF
 293
 294test_expect_success 'proper bzr repo' '
 295        test_when_finished "rm -rf bzrrepo gitrepo" &&
 296
 297        bzr init-repo bzrrepo &&
 298
 299        (
 300        bzr init bzrrepo/trunk &&
 301        cd bzrrepo/trunk &&
 302        echo one >> content &&
 303        bzr add content &&
 304        bzr commit -m one
 305        ) &&
 306
 307        (
 308        bzr branch bzrrepo/trunk bzrrepo/branch &&
 309        cd bzrrepo/branch &&
 310        echo two >> content &&
 311        bzr commit -m one
 312        ) &&
 313
 314        (
 315        git clone "bzr::bzrrepo" gitrepo &&
 316        cd gitrepo &&
 317        git for-each-ref --format "%(refname:short)" refs/remotes/origin > ../actual
 318        ) &&
 319
 320        test_cmp expected actual
 321'
 322
 323test_expect_success 'strip' '
 324        test_when_finished "rm -rf bzrrepo gitrepo" &&
 325
 326        (
 327        bzr init bzrrepo &&
 328        cd bzrrepo &&
 329
 330        echo one >> content &&
 331        bzr add content &&
 332        bzr commit -m one &&
 333
 334        echo two >> content &&
 335        bzr commit -m two
 336        ) &&
 337
 338        git clone "bzr::bzrrepo" gitrepo &&
 339
 340        (
 341        cd bzrrepo &&
 342        bzr uncommit --force &&
 343
 344        echo three >> content &&
 345        bzr commit -m three &&
 346
 347        echo four >> content &&
 348        bzr commit -m four &&
 349        bzr log --line | sed -e "s/^[0-9][0-9]*: //" > ../expected
 350        ) &&
 351
 352        (
 353        cd gitrepo &&
 354        git fetch &&
 355        git log --format="%an %ad %s" --date=short origin/master > ../actual
 356        ) &&
 357
 358        test_cmp expected actual
 359'
 360
 361test_expect_success 'export utf-8 authors' '
 362        test_when_finished "rm -rf bzrrepo gitrepo && LC_ALL=C && unset GIT_COMMITTER_NAME" &&
 363
 364        LC_ALL=en_US.UTF-8
 365        export LC_ALL
 366
 367        GIT_COMMITTER_NAME="Grégoire"
 368        export GIT_COMMITTER_NAME
 369
 370        bzr init bzrrepo &&
 371
 372        (
 373        git init gitrepo &&
 374        cd gitrepo &&
 375        echo greg >> content &&
 376        git add content &&
 377        git commit -m one &&
 378        git remote add bzr "bzr::../bzrrepo" &&
 379        git push bzr
 380        ) &&
 381
 382        (
 383        cd bzrrepo &&
 384        bzr log | grep "^committer: " > ../actual
 385        ) &&
 386
 387        echo "committer: Grégoire <committer@example.com>" > expected &&
 388        test_cmp expected actual
 389'
 390
 391test_done