|
| 1 | +#!/bin/sh |
| 2 | +# |
| 3 | +# Copyright (c) 2012 Felipe Contreras |
| 4 | +# |
| 5 | + |
| 6 | +test_description='Test remote-bzr' |
| 7 | + |
| 8 | +. ./test-lib.sh |
| 9 | + |
| 10 | +if ! test_have_prereq PYTHON; then |
| 11 | + skip_all='skipping remote-bzr tests; python not available' |
| 12 | + test_done |
| 13 | +fi |
| 14 | + |
| 15 | +if ! "$PYTHON_PATH" -c 'import bzrlib'; then |
| 16 | + skip_all='skipping remote-bzr tests; bzr not available' |
| 17 | + test_done |
| 18 | +fi |
| 19 | + |
| 20 | +cmd=' |
| 21 | +import bzrlib |
| 22 | +bzrlib.initialize() |
| 23 | +import bzrlib.plugin |
| 24 | +bzrlib.plugin.load_plugins() |
| 25 | +import bzrlib.plugins.fastimport |
| 26 | +' |
| 27 | + |
| 28 | +if ! "$PYTHON_PATH" -c "$cmd"; then |
| 29 | + echo "consider setting BZR_PLUGIN_PATH=$HOME/.bazaar/plugins" 1>&2 |
| 30 | + skip_all='skipping remote-bzr tests; bzr-fastimport not available' |
| 31 | + test_done |
| 32 | +fi |
| 33 | + |
| 34 | +check () { |
| 35 | + (cd $1 && |
| 36 | + git log --format='%s' -1 && |
| 37 | + git symbolic-ref HEAD) > actual && |
| 38 | + (echo $2 && |
| 39 | + echo "refs/heads/$3") > expected && |
| 40 | + test_cmp expected actual |
| 41 | +} |
| 42 | + |
| 43 | +bzr whoami "A U Thor <author@example.com>" |
| 44 | + |
| 45 | +test_expect_success 'cloning' ' |
| 46 | + (bzr init bzrrepo && |
| 47 | + cd bzrrepo && |
| 48 | + echo one > content && |
| 49 | + bzr add content && |
| 50 | + bzr commit -m one |
| 51 | + ) && |
| 52 | +
|
| 53 | + git clone "bzr::$PWD/bzrrepo" gitrepo && |
| 54 | + check gitrepo one master |
| 55 | +' |
| 56 | + |
| 57 | +test_expect_success 'pulling' ' |
| 58 | + (cd bzrrepo && |
| 59 | + echo two > content && |
| 60 | + bzr commit -m two |
| 61 | + ) && |
| 62 | +
|
| 63 | + (cd gitrepo && git pull) && |
| 64 | +
|
| 65 | + check gitrepo two master |
| 66 | +' |
| 67 | + |
| 68 | +test_expect_success 'pushing' ' |
| 69 | + (cd gitrepo && |
| 70 | + echo three > content && |
| 71 | + git commit -a -m three && |
| 72 | + git push |
| 73 | + ) && |
| 74 | +
|
| 75 | + echo three > expected && |
| 76 | + cat bzrrepo/content > actual && |
| 77 | + test_cmp expected actual |
| 78 | +' |
| 79 | + |
| 80 | +test_expect_success 'roundtrip' ' |
| 81 | + (cd gitrepo && |
| 82 | + git pull && |
| 83 | + git log --format="%s" -1 origin/master > actual) && |
| 84 | + echo three > expected && |
| 85 | + test_cmp expected actual && |
| 86 | +
|
| 87 | + (cd gitrepo && git push && git pull) && |
| 88 | +
|
| 89 | + (cd bzrrepo && |
| 90 | + echo four > content && |
| 91 | + bzr commit -m four |
| 92 | + ) && |
| 93 | +
|
| 94 | + (cd gitrepo && git pull && git push) && |
| 95 | +
|
| 96 | + check gitrepo four master && |
| 97 | +
|
| 98 | + (cd gitrepo && |
| 99 | + echo five > content && |
| 100 | + git commit -a -m five && |
| 101 | + git push && git pull |
| 102 | + ) && |
| 103 | +
|
| 104 | + (cd bzrrepo && bzr revert) && |
| 105 | +
|
| 106 | + echo five > expected && |
| 107 | + cat bzrrepo/content > actual && |
| 108 | + test_cmp expected actual |
| 109 | +' |
| 110 | + |
| 111 | +test_done |
0 commit comments