OLD | NEW |
1 #!/usr/bin/env bash | 1 #!/usr/bin/env bash |
2 | 2 |
3 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 3 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
4 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be |
5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
6 | 6 |
7 # Tests the "preupload and predcommit hooks" functionality, which lets you run | 7 # Tests the "preupload and preland hooks" functionality, which lets you run |
8 # hooks by installing a script into .git/hooks/pre-cl-* first. | 8 # hooks by installing a script into .git/hooks/pre-cl-* first. |
9 | 9 |
10 set -e | 10 set -e |
11 | 11 |
12 . ./test-lib.sh | 12 . ./test-lib.sh |
13 | 13 |
14 setup_initsvn | 14 setup_git_remote |
15 setup_gitsvn | 15 setup_git_checkout |
16 | 16 |
17 setup_hooks() { | 17 setup_hooks() { |
18 upload_retval=$1 | 18 upload_retval=$1 |
19 dcommit_retval=$2 | 19 land_retval=$2 |
20 | 20 |
21 echo > PRESUBMIT.py <<END | 21 echo > PRESUBMIT.py <<END |
22 def CheckChangeOnUpload(input_api, output_api): | 22 def CheckChangeOnUpload(input_api, output_api): |
23 return $upload_retval | 23 return $upload_retval |
24 | 24 |
25 def CheckChangeOnCommit(input_api, output_api): | 25 def CheckChangeOnCommit(input_api, output_api): |
26 return $dcommit_retval | 26 return $land_retval |
27 END | 27 END |
28 } | 28 } |
29 | 29 |
30 ( | 30 ( |
31 set -e | 31 set -e |
32 cd git-svn | 32 cd git_checkout |
33 | 33 |
34 # We need a server set up, but we don't use it. git config rietveld.server lo
calhost:1 | 34 # We need a server set up, but we don't use it. git config rietveld.server lo
calhost:1 |
35 | 35 |
36 # Install hooks that will fail on upload and commit | 36 # Install hooks that will fail on upload and commit |
37 setup_hooks 1 1 | 37 setup_hooks 1 1 |
38 | 38 |
39 echo "some work done" >> test | 39 echo "some work done" >> test |
40 git add test; git commit -q -m "work" | 40 git add test; git commit -q -m "work" |
41 | 41 |
42 # Verify git cl upload fails. | 42 # Verify git cl upload fails. |
43 test_expect_failure "git-cl upload hook fails" "$GIT_CL upload master" | 43 test_expect_failure "git-cl upload hook fails" "$GIT_CL upload master" |
44 | 44 |
45 # Verify git cl dcommit fails. | 45 # Verify git cl land fails. |
46 test_expect_failure "git-cl dcommit hook fails" "$GIT_CL dcommit master" | 46 test_expect_failure "git-cl land hook fails" "$GIT_CL land master" |
47 ) | 47 ) |
48 SUCCESS=$? | 48 SUCCESS=$? |
49 | 49 |
50 #cleanup | 50 #cleanup |
51 | 51 |
52 if [ $SUCCESS == 0 ]; then | 52 if [ $SUCCESS == 0 ]; then |
53 echo PASS | 53 echo PASS |
54 fi | 54 fi |
OLD | NEW |