OLD | NEW |
(Empty) | |
| 1 #!/bin/bash |
| 2 |
| 3 # Abort on error. |
| 4 set -e |
| 5 |
| 6 PWD=`pwd` |
| 7 REPO_URL=file://$PWD/svnrepo |
| 8 GITREPO_PATH=$PWD/gitrepo |
| 9 GITREPO_URL=file://$GITREPO_PATH |
| 10 GIT_CL=$PWD/../git-cl |
| 11 |
| 12 # Set up an SVN repo that has a few commits to trunk. |
| 13 setup_initsvn() { |
| 14 echo "Setting up test SVN repo..." |
| 15 rm -rf svnrepo |
| 16 svnadmin create svnrepo |
| 17 |
| 18 rm -rf svn |
| 19 svn co -q $REPO_URL svn |
| 20 ( |
| 21 cd svn |
| 22 echo "test" > test |
| 23 svn add -q test |
| 24 svn commit -q -m "initial commit" |
| 25 echo "test2" >> test |
| 26 svn commit -q -m "second commit" |
| 27 ) |
| 28 } |
| 29 |
| 30 # Set up a git-svn checkout of the repo. |
| 31 setup_gitsvn() { |
| 32 echo "Setting up test git-svn repo..." |
| 33 rm -rf git-svn |
| 34 # There appears to be no way to make git-svn completely shut up, so we |
| 35 # redirect its output. |
| 36 git svn -q clone $REPO_URL git-svn >/dev/null 2>&1 |
| 37 } |
| 38 |
| 39 # Set up a git repo that has a few commits to master. |
| 40 setup_initgit() { |
| 41 echo "Setting up test upstream git repo..." |
| 42 rm -rf gitrepo |
| 43 mkdir gitrepo |
| 44 |
| 45 ( |
| 46 cd gitrepo |
| 47 git init -q |
| 48 echo "test" > test |
| 49 git add test |
| 50 git commit -qam "initial commit" |
| 51 echo "test2" >> test |
| 52 git commit -qam "second commit" |
| 53 # Hack: make sure master is not the current branch |
| 54 # otherwise push will give a warning |
| 55 git checkout -q -b foo |
| 56 ) |
| 57 } |
| 58 |
| 59 # Set up a git checkout of the repo. |
| 60 setup_gitgit() { |
| 61 echo "Setting up test git repo..." |
| 62 rm -rf git-git |
| 63 git clone -q $GITREPO_URL git-git |
| 64 } |
| 65 |
| 66 cleanup() { |
| 67 rm -rf gitrepo svnrepo svn git-git git-svn |
| 68 } |
| 69 |
| 70 # Usage: test_expect_success "description of test" "test code". |
| 71 test_expect_success() { |
| 72 echo "TESTING: $1" |
| 73 exit_code=0 |
| 74 sh -c "$2" || exit_code=$? |
| 75 if [ $exit_code != 0 ]; then |
| 76 echo "FAILURE: $1" |
| 77 return $exit_code |
| 78 fi |
| 79 } |
| 80 |
| 81 # Usage: test_expect_failure "description of test" "test code". |
| 82 test_expect_failure() { |
| 83 echo "TESTING: $1" |
| 84 exit_code=0 |
| 85 sh -c "$2" || exit_code=$? |
| 86 if [ $exit_code = 0 ]; then |
| 87 echo "SUCCESS, BUT EXPECTED FAILURE: $1" |
| 88 return $exit_code |
| 89 fi |
| 90 } |
| 91 |
| 92 # Grab the XSRF token from the review server and print it to stdout. |
| 93 print_xsrf_token() { |
| 94 curl --cookie dev_appserver_login="test@example.com:False" \ |
| 95 --header 'X-Requesting-XSRF-Token: 1' \ |
| 96 http://localhost:8080/xsrf_token 2>/dev/null |
| 97 } |
OLD | NEW |