test-lib.sh 1007 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #!/bin/bash
  2. # Abort on error.
  3. set -e
  4. PWD=`pwd`
  5. REPO_URL=file://$PWD/svnrepo
  6. GIT_CL=$PWD/../git-cl
  7. # Set up an SVN repo that has a few commits to trunk.
  8. setup_initsvn() {
  9. echo "Setting up test SVN repo..."
  10. rm -rf svnrepo
  11. svnadmin create svnrepo
  12. rm -rf svn
  13. svn co -q $REPO_URL svn
  14. (
  15. cd svn
  16. echo "test" > test
  17. svn add -q test
  18. svn commit -q -m "initial commit"
  19. echo "test2" >> test
  20. svn commit -q -m "second commit"
  21. )
  22. }
  23. # Set up a git-svn checkout of the repo.
  24. setup_gitsvn() {
  25. echo "Setting up test git-svn repo..."
  26. rm -rf git-svn
  27. # There appears to be no way to make git-svn completely shut up, so we
  28. # redirect its output.
  29. git svn -q clone $REPO_URL git-svn >/dev/null 2>&1
  30. }
  31. cleanup() {
  32. rm -rf svnrepo svn git-svn
  33. }
  34. # Usage: test_expect_success "description of test" "test code".
  35. test_expect_success() {
  36. echo "TESTING: $1"
  37. exit_code=0
  38. sh -c "$2" || exit_code=$?
  39. if [ $exit_code != 0 ]; then
  40. echo "FAILURE: $1"
  41. return $exit_code
  42. fi
  43. }