[email protected] | cc51cd0 | 2010-12-23 00:48:39 | [diff] [blame] | 1 | #!/bin/bash |
2 | |||||
3 | # Abort on error. | ||||
4 | set -e | ||||
5 | |||||
[email protected] | 01da4f8 | 2012-01-24 21:54:51 | [diff] [blame^] | 6 | export DEPOT_TOOLS_UPDATE=0 |
7 | |||||
[email protected] | cc51cd0 | 2010-12-23 00:48:39 | [diff] [blame] | 8 | PWD=`pwd` |
9 | REPO_URL=file://$PWD/svnrepo | ||||
[email protected] | 866276c | 2011-03-18 20:09:31 | [diff] [blame] | 10 | TRUNK_URL=$REPO_URL/trunk |
11 | BRANCH_URL=$REPO_URL/branches/some_branch | ||||
[email protected] | cc51cd0 | 2010-12-23 00:48:39 | [diff] [blame] | 12 | GITREPO_PATH=$PWD/gitrepo |
13 | GITREPO_URL=file://$GITREPO_PATH | ||||
14 | GIT_CL=$PWD/../git-cl | ||||
15 | |||||
16 | # Set up an SVN repo that has a few commits to trunk. | ||||
17 | setup_initsvn() { | ||||
18 | echo "Setting up test SVN repo..." | ||||
19 | rm -rf svnrepo | ||||
20 | svnadmin create svnrepo | ||||
[email protected] | a185145 | 2011-03-11 22:54:02 | [diff] [blame] | 21 | # Need this in order for Mac SnowLeopard to work |
22 | echo "enable-rep-sharing = false" >> svnrepo/db/fsfs.conf | ||||
23 | |||||
[email protected] | 866276c | 2011-03-18 20:09:31 | [diff] [blame] | 24 | svn mkdir -q -m 'creating trunk' --parents $TRUNK_URL |
25 | |||||
[email protected] | cc51cd0 | 2010-12-23 00:48:39 | [diff] [blame] | 26 | rm -rf svn |
[email protected] | 866276c | 2011-03-18 20:09:31 | [diff] [blame] | 27 | svn co -q $TRUNK_URL svn |
[email protected] | cc51cd0 | 2010-12-23 00:48:39 | [diff] [blame] | 28 | ( |
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] | 866276c | 2011-03-18 20:09:31 | [diff] [blame] | 36 | |
37 | svn cp -q -m 'branching' --parents $TRUNK_URL $BRANCH_URL | ||||
[email protected] | cc51cd0 | 2010-12-23 00:48:39 | [diff] [blame] | 38 | } |
39 | |||||
40 | # Set up a git-svn checkout of the repo. | ||||
41 | setup_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] | 866276c | 2011-03-18 20:09:31 | [diff] [blame] | 46 | git svn -q clone -s $REPO_URL git-svn >/dev/null 2>&1 |
[email protected] | cc51cd0 | 2010-12-23 00:48:39 | [diff] [blame] | 47 | } |
48 | |||||
49 | # Set up a git repo that has a few commits to master. | ||||
50 | setup_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. | ||||
70 | setup_gitgit() { | ||||
71 | echo "Setting up test git repo..." | ||||
72 | rm -rf git-git | ||||
73 | git clone -q $GITREPO_URL git-git | ||||
74 | } | ||||
75 | |||||
76 | cleanup() { | ||||
77 | rm -rf gitrepo svnrepo svn git-git git-svn | ||||
78 | } | ||||
79 | |||||
80 | # Usage: test_expect_success "description of test" "test code". | ||||
81 | test_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". | ||||
92 | test_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. | ||||
103 | print_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 | } |