tests/test-init
author Matt Mackall <mpm@selenic.com>
Mon, 01 Jun 2009 13:51:21 -0500
changeset 8700 a96b049075a8
parent 7249 671b3e1eac2e
child 11640 c3e8ab80ee90
permissions -rwxr-xr-x
mq: drop unneeded files args for commit
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2599
e4b5e48052c6 Added tests for local and remote init.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff changeset
     1
#!/bin/sh
e4b5e48052c6 Added tests for local and remote init.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff changeset
     2
e4b5e48052c6 Added tests for local and remote init.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff changeset
     3
# This test tries to exercise the ssh functionality with a dummy script
e4b5e48052c6 Added tests for local and remote init.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff changeset
     4
4297
27590c19ad30 test-init: avoid a shell script
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4166
diff changeset
     5
cat <<EOF > dummyssh
27590c19ad30 test-init: avoid a shell script
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4166
diff changeset
     6
import sys
27590c19ad30 test-init: avoid a shell script
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4166
diff changeset
     7
import os
2599
e4b5e48052c6 Added tests for local and remote init.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff changeset
     8
4297
27590c19ad30 test-init: avoid a shell script
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4166
diff changeset
     9
os.chdir(os.path.dirname(sys.argv[0]))
27590c19ad30 test-init: avoid a shell script
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4166
diff changeset
    10
if sys.argv[1] != "user@dummy":
27590c19ad30 test-init: avoid a shell script
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4166
diff changeset
    11
    sys.exit(-1)
2599
e4b5e48052c6 Added tests for local and remote init.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff changeset
    12
4297
27590c19ad30 test-init: avoid a shell script
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4166
diff changeset
    13
if not os.path.exists("dummyssh"):
27590c19ad30 test-init: avoid a shell script
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4166
diff changeset
    14
    sys.exit(-1)
2599
e4b5e48052c6 Added tests for local and remote init.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff changeset
    15
4297
27590c19ad30 test-init: avoid a shell script
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4166
diff changeset
    16
log = open("dummylog", "ab")
27590c19ad30 test-init: avoid a shell script
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4166
diff changeset
    17
log.write("Got arguments")
27590c19ad30 test-init: avoid a shell script
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4166
diff changeset
    18
for i, arg in enumerate(sys.argv[1:]):
27590c19ad30 test-init: avoid a shell script
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4166
diff changeset
    19
    log.write(" %d:%s" % (i+1, arg))
27590c19ad30 test-init: avoid a shell script
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4166
diff changeset
    20
log.write("\n")
27590c19ad30 test-init: avoid a shell script
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4166
diff changeset
    21
log.close()
27590c19ad30 test-init: avoid a shell script
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4166
diff changeset
    22
r = os.system(sys.argv[2])
27590c19ad30 test-init: avoid a shell script
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4166
diff changeset
    23
sys.exit(bool(r))
2599
e4b5e48052c6 Added tests for local and remote init.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff changeset
    24
EOF
e4b5e48052c6 Added tests for local and remote init.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff changeset
    25
4166
c0271aba6abe small fixes for the parent patch
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3713
diff changeset
    26
checknewrepo()
c0271aba6abe small fixes for the parent patch
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3713
diff changeset
    27
{
c0271aba6abe small fixes for the parent patch
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3713
diff changeset
    28
    name=$1
c0271aba6abe small fixes for the parent patch
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3713
diff changeset
    29
c0271aba6abe small fixes for the parent patch
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3713
diff changeset
    30
    if [ -d $name/.hg/store ]; then
c0271aba6abe small fixes for the parent patch
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3713
diff changeset
    31
	echo store created
c0271aba6abe small fixes for the parent patch
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3713
diff changeset
    32
    fi
c0271aba6abe small fixes for the parent patch
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3713
diff changeset
    33
c0271aba6abe small fixes for the parent patch
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3713
diff changeset
    34
    if [ -f $name/.hg/00changelog.i ]; then
c0271aba6abe small fixes for the parent patch
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3713
diff changeset
    35
	echo 00changelog.i created
c0271aba6abe small fixes for the parent patch
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3713
diff changeset
    36
    fi
c0271aba6abe small fixes for the parent patch
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3713
diff changeset
    37
c0271aba6abe small fixes for the parent patch
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3713
diff changeset
    38
    cat $name/.hg/requires
c0271aba6abe small fixes for the parent patch
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3713
diff changeset
    39
}
c0271aba6abe small fixes for the parent patch
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3713
diff changeset
    40
2599
e4b5e48052c6 Added tests for local and remote init.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff changeset
    41
echo "# creating 'local'"
e4b5e48052c6 Added tests for local and remote init.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff changeset
    42
hg init local
4166
c0271aba6abe small fixes for the parent patch
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3713
diff changeset
    43
checknewrepo local
2599
e4b5e48052c6 Added tests for local and remote init.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff changeset
    44
echo this > local/foo
e4b5e48052c6 Added tests for local and remote init.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff changeset
    45
hg ci --cwd local -A -m "init" -d "1000000 0"
e4b5e48052c6 Added tests for local and remote init.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff changeset
    46
7249
671b3e1eac2e test-init: add test with format.usefncache=false
Adrian Buehlmann <adrian@cadifra.com>
parents: 4297
diff changeset
    47
echo "# creating repo with format.usestore=false"
4166
c0271aba6abe small fixes for the parent patch
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3713
diff changeset
    48
hg --config format.usestore=false init old
c0271aba6abe small fixes for the parent patch
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3713
diff changeset
    49
checknewrepo old
c0271aba6abe small fixes for the parent patch
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3713
diff changeset
    50
7249
671b3e1eac2e test-init: add test with format.usefncache=false
Adrian Buehlmann <adrian@cadifra.com>
parents: 4297
diff changeset
    51
echo "# creating repo with format.usefncache=false"
671b3e1eac2e test-init: add test with format.usefncache=false
Adrian Buehlmann <adrian@cadifra.com>
parents: 4297
diff changeset
    52
hg --config format.usefncache=false init old2
671b3e1eac2e test-init: add test with format.usefncache=false
Adrian Buehlmann <adrian@cadifra.com>
parents: 4297
diff changeset
    53
checknewrepo old2
671b3e1eac2e test-init: add test with format.usefncache=false
Adrian Buehlmann <adrian@cadifra.com>
parents: 4297
diff changeset
    54
3037
3acb76f0124d clone: simplifying dest repo creation
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 2599
diff changeset
    55
echo "#test failure"
3acb76f0124d clone: simplifying dest repo creation
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 2599
diff changeset
    56
hg init local
3acb76f0124d clone: simplifying dest repo creation
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 2599
diff changeset
    57
2599
e4b5e48052c6 Added tests for local and remote init.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff changeset
    58
echo "# init+push to remote2"
4297
27590c19ad30 test-init: avoid a shell script
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4166
diff changeset
    59
hg init -e "python ./dummyssh" ssh://user@dummy/remote2
2599
e4b5e48052c6 Added tests for local and remote init.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff changeset
    60
hg incoming -R remote2 local
4297
27590c19ad30 test-init: avoid a shell script
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4166
diff changeset
    61
hg push -R local -e "python ./dummyssh" ssh://user@dummy/remote2
2599
e4b5e48052c6 Added tests for local and remote init.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff changeset
    62
e4b5e48052c6 Added tests for local and remote init.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff changeset
    63
echo "# clone to remote1"
4297
27590c19ad30 test-init: avoid a shell script
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4166
diff changeset
    64
hg clone -e "python ./dummyssh" local ssh://user@dummy/remote1
2599
e4b5e48052c6 Added tests for local and remote init.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff changeset
    65
3037
3acb76f0124d clone: simplifying dest repo creation
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 2599
diff changeset
    66
echo "# init to existing repo"
4297
27590c19ad30 test-init: avoid a shell script
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4166
diff changeset
    67
hg init -e "python ./dummyssh" ssh://user@dummy/remote1
3037
3acb76f0124d clone: simplifying dest repo creation
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 2599
diff changeset
    68
3acb76f0124d clone: simplifying dest repo creation
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 2599
diff changeset
    69
echo "# clone to existing repo"
4297
27590c19ad30 test-init: avoid a shell script
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4166
diff changeset
    70
hg clone -e "python ./dummyssh" local ssh://user@dummy/remote1
3037
3acb76f0124d clone: simplifying dest repo creation
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 2599
diff changeset
    71
2599
e4b5e48052c6 Added tests for local and remote init.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff changeset
    72
echo "# output of dummyssh"
e4b5e48052c6 Added tests for local and remote init.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff changeset
    73
cat dummylog
e4b5e48052c6 Added tests for local and remote init.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff changeset
    74
e4b5e48052c6 Added tests for local and remote init.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff changeset
    75
echo "# comparing repositories"
e4b5e48052c6 Added tests for local and remote init.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff changeset
    76
hg tip -q -R local
e4b5e48052c6 Added tests for local and remote init.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff changeset
    77
hg tip -q -R remote1
e4b5e48052c6 Added tests for local and remote init.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff changeset
    78
hg tip -q -R remote2
e4b5e48052c6 Added tests for local and remote init.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff changeset
    79
e4b5e48052c6 Added tests for local and remote init.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff changeset
    80
echo "# check names for repositories (clashes with URL schemes, special chars)"
e4b5e48052c6 Added tests for local and remote init.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff changeset
    81
for i in bundle file hg http https old-http ssh static-http " " "with space"; do
e4b5e48052c6 Added tests for local and remote init.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff changeset
    82
  echo "# hg init \"$i\""
e4b5e48052c6 Added tests for local and remote init.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff changeset
    83
  hg init "$i"
3713
8ae88ed2a3b6 don't create the .hg/data at init time
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3037
diff changeset
    84
  test -d "$i" -a -d "$i/.hg" && echo "ok" || echo "failed"
2599
e4b5e48052c6 Added tests for local and remote init.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff changeset
    85
done
e4b5e48052c6 Added tests for local and remote init.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff changeset
    86