blob: a66ce37091e1c09c5afe4e277d5caa149a959fe1 [file] [log] [blame]
[email protected]cc51cd02010-12-23 00:48:391#!/bin/bash
2
3# Abort on error.
4set -e
5
[email protected]01da4f82012-01-24 21:54:516export DEPOT_TOOLS_UPDATE=0
7
[email protected]cc51cd02010-12-23 00:48:398PWD=`pwd`
9REPO_URL=file://$PWD/svnrepo
[email protected]866276c2011-03-18 20:09:3110TRUNK_URL=$REPO_URL/trunk
11BRANCH_URL=$REPO_URL/branches/some_branch
[email protected]cc51cd02010-12-23 00:48:3912GITREPO_PATH=$PWD/gitrepo
13GITREPO_URL=file://$GITREPO_PATH
14GIT_CL=$PWD/../git-cl
15
16# Set up an SVN repo that has a few commits to trunk.
17setup_initsvn() {
18 echo "Setting up test SVN repo..."
19 rm -rf svnrepo
20 svnadmin create svnrepo
[email protected]a1851452011-03-11 22:54:0221 # Need this in order for Mac SnowLeopard to work
22 echo "enable-rep-sharing = false" >> svnrepo/db/fsfs.conf
23
[email protected]866276c2011-03-18 20:09:3124 svn mkdir -q -m 'creating trunk' --parents $TRUNK_URL
25
[email protected]cc51cd02010-12-23 00:48:3926 rm -rf svn
[email protected]866276c2011-03-18 20:09:3127 svn co -q $TRUNK_URL svn
[email protected]cc51cd02010-12-23 00:48:3928 (
29 cd svn
30 echo "test" > test
31 svn add -q test
32 svn commit -q -m "initial commit"
33 echo "test2" >> test
34 svn commit -q -m "second commit"
35 )
[email protected]866276c2011-03-18 20:09:3136
37 svn cp -q -m 'branching' --parents $TRUNK_URL $BRANCH_URL
[email protected]cc51cd02010-12-23 00:48:3938}
39
40# Set up a git-svn checkout of the repo.
41setup_gitsvn() {
42 echo "Setting up test git-svn repo..."
43 rm -rf git-svn
44 # There appears to be no way to make git-svn completely shut up, so we
45 # redirect its output.
[email protected]866276c2011-03-18 20:09:3146 git svn -q clone -s $REPO_URL git-svn >/dev/null 2>&1
[email protected]cc51cd02010-12-23 00:48:3947}
48
49# Set up a git repo that has a few commits to master.
50setup_initgit() {
51 echo "Setting up test upstream git repo..."
52 rm -rf gitrepo
53 mkdir gitrepo
54
55 (
56 cd gitrepo
57 git init -q
58 echo "test" > test
59 git add test
60 git commit -qam "initial commit"
61 echo "test2" >> test
62 git commit -qam "second commit"
63 # Hack: make sure master is not the current branch
64 # otherwise push will give a warning
65 git checkout -q -b foo
66 )
67}
68
69# Set up a git checkout of the repo.
70setup_gitgit() {
71 echo "Setting up test git repo..."
72 rm -rf git-git
73 git clone -q $GITREPO_URL git-git
74}
75
76cleanup() {
77 rm -rf gitrepo svnrepo svn git-git git-svn
78}
79
80# Usage: test_expect_success "description of test" "test code".
81test_expect_success() {
82 echo "TESTING: $1"
83 exit_code=0
84 sh -c "$2" || exit_code=$?
85 if [ $exit_code != 0 ]; then
86 echo "FAILURE: $1"
87 return $exit_code
88 fi
89}
90
91# Usage: test_expect_failure "description of test" "test code".
92test_expect_failure() {
93 echo "TESTING: $1"
94 exit_code=0
95 sh -c "$2" || exit_code=$?
96 if [ $exit_code = 0 ]; then
97 echo "SUCCESS, BUT EXPECTED FAILURE: $1"
98 return $exit_code
99 fi
100}
101
102# Grab the XSRF token from the review server and print it to stdout.
103print_xsrf_token() {
104 curl --cookie dev_appserver_login="[email protected]:False" \
105 --header 'X-Requesting-XSRF-Token: 1' \
106 http://localhost:8080/xsrf_token 2>/dev/null
107}