Sync with 'master'
[alt-git.git] / t / t9805-git-p4-skip-submit-edit.sh
blob72dce3d2b46f4dd103baefb7a833917e60b151b0
1 #!/bin/sh
3 test_description='git p4 skipSubmitEdit config variables'
5 TEST_PASSES_SANITIZE_LEAK=true
6 . ./lib-git-p4.sh
8 test_expect_success 'start p4d' '
9 start_p4d
12 test_expect_success 'init depot' '
14 cd "$cli" &&
15 echo file1 >file1 &&
16 p4 add file1 &&
17 p4 submit -d "change 1"
21 # this works because P4EDITOR is set to true
22 test_expect_success 'no config, unedited, say yes' '
23 git p4 clone --dest="$git" //depot &&
24 test_when_finished cleanup_git &&
26 cd "$git" &&
27 echo line >>file1 &&
28 git commit -a -m "change 2" &&
29 echo y | git p4 submit &&
30 p4 changes //depot/... >wc &&
31 test_line_count = 2 wc
35 test_expect_success 'no config, unedited, say no' '
36 git p4 clone --dest="$git" //depot &&
37 test_when_finished cleanup_git &&
39 cd "$git" &&
40 echo line >>file1 &&
41 git commit -a -m "change 3 (not really)" &&
42 printf "bad response\nn\n" | test_expect_code 1 git p4 submit &&
43 p4 changes //depot/... >wc &&
44 test_line_count = 2 wc
48 test_expect_success 'skipSubmitEdit' '
49 git p4 clone --dest="$git" //depot &&
50 test_when_finished cleanup_git &&
52 cd "$git" &&
53 git config git-p4.skipSubmitEdit true &&
54 # will fail if editor is even invoked
55 git config core.editor /bin/false &&
56 echo line >>file1 &&
57 git commit -a -m "change 3" &&
58 git p4 submit &&
59 p4 changes //depot/... >wc &&
60 test_line_count = 3 wc
64 test_expect_success 'skipSubmitEditCheck' '
65 git p4 clone --dest="$git" //depot &&
66 test_when_finished cleanup_git &&
68 cd "$git" &&
69 git config git-p4.skipSubmitEditCheck true &&
70 echo line >>file1 &&
71 git commit -a -m "change 4" &&
72 git p4 submit &&
73 p4 changes //depot/... >wc &&
74 test_line_count = 4 wc
78 # check the normal case, where the template really is edited
79 test_expect_success 'no config, edited' '
80 git p4 clone --dest="$git" //depot &&
81 test_when_finished cleanup_git &&
82 test_when_finished "rm ed.sh" &&
83 cat >ed.sh <<-EOF &&
84 #!$SHELL_PATH
85 sleep 1
86 touch "\$1"
87 exit 0
88 EOF
89 chmod 755 ed.sh &&
91 cd "$git" &&
92 echo line >>file1 &&
93 git commit -a -m "change 5" &&
94 P4EDITOR="\"$TRASH_DIRECTORY/ed.sh\"" &&
95 export P4EDITOR &&
96 git p4 submit &&
97 p4 changes //depot/... >wc &&
98 test_line_count = 5 wc
102 test_done