More robust setup.py code generation
[stgit.git] / t / t1003-new.sh
blob37034b518b2141f7bff9d668ac67b3dc3b3ddbcc
1 #!/bin/sh
3 # Copyright (c) 2007 Karl Hasselström
6 test_description='Test "stg new".'
8 . ./test-lib.sh
10 test_expect_success \
11 'Initialize the StGit repository' '
12 stg init
15 test_expect_success \
16 'Too many arguments' '
17 command_error stg new foo extra_arg 2>&1 |
18 grep -e "incorrect number of arguments"
21 test_expect_success \
22 'Create a named patch' '
23 stg new foo -m foobar &&
24 [ $(stg series --applied -c) -eq 1 ]
27 test_expect_success \
28 'Invalid patch name: space' '
29 command_error stg new "bad name" 2>&1 >/dev/null |
30 grep -e "Invalid patch name: \"bad name\""
33 test_expect_success \
34 'Invalid patch name: carat' '
35 command_error stg new "bad^name" 2>&1 >/dev/null |
36 grep -e "Invalid patch name: \"bad\^name\""
39 test_expect_success \
40 'Invalid patch name: empty' '
41 command_error stg new "" 2>&1 >/dev/null |
42 grep -e "Invalid patch name: \"\""
45 test_expect_success \
46 'Create a patch without giving a name' '
47 stg new -m yo &&
48 [ "$(echo $(stg top))" = "yo" ] &&
49 [ $(stg series --applied -c) -eq 2 ]
52 test_expect_success \
53 'Attempt to create patch with duplicate name' '
54 command_error stg new foo -m "duplicate foo" 2>&1 |
55 grep -e "foo: patch already exists"
58 test_expect_success \
59 'Attempt new with conflicts' '
60 stg new -m p0 &&
61 echo "something" > file.txt &&
62 stg add file.txt &&
63 stg refresh &&
64 stg new -m p1 &&
65 echo "something else" > file.txt &&
66 stg refresh &&
67 stg pop &&
68 stg new -m p2 &&
69 echo "something different" > file.txt &&
70 stg refresh &&
71 conflict stg push p1 &&
72 command_error stg new -m p3 2>&1 |
73 grep -e "Cannot create a new patch -- resolve conflicts first" &&
74 stg reset --hard
77 test_expect_success \
78 'Save template' '
79 stg new --save-template new-tmpl.txt &&
80 test_path_is_file new-tmpl.txt
83 test_expect_success \
84 'New with patchdescr.tmpl' '
85 echo "Patch Description Template" > .git/patchdescr.tmpl &&
86 stg new templated-patch &&
87 stg show | grep "Patch Description Template"
90 test_expect_success 'Setup fake editor' '
91 write_script fake-editor <<-\EOF
92 cat "$1" > raw_commit_message.txt
93 EOF
95 test_expect_success \
96 'New without verbose flag' '
97 test_set_editor "$(pwd)/fake-editor" &&
98 test_when_finished test_set_editor false &&
99 echo "something else" > file.txt &&
100 stg new no-verbose-patch &&
101 test_must_fail grep "something else" raw_commit_message.txt
104 test_expect_success \
105 'New with verbose flag' '
106 test_set_editor "$(pwd)/fake-editor" &&
107 test_when_finished test_set_editor false &&
108 stg new --verbose verbose-flag-patch &&
109 stg show | grep "Patch Description Template" &&
110 grep "something else" raw_commit_message.txt
113 test_expect_success \
114 'New with verbose config option' '
115 test_set_editor "$(pwd)/fake-editor" &&
116 test_when_finished test_set_editor false &&
117 test_config commit.verbose "1" &&
118 stg new verbose-config-patch &&
119 grep "something else" raw_commit_message.txt
122 test_expect_success \
123 'New with verbose config boolean option' '
124 test_set_editor "$(pwd)/fake-editor" &&
125 test_when_finished test_set_editor false &&
126 test_config commit.verbose "true" &&
127 stg new verbose-config-bool-patch &&
128 grep "something else" raw_commit_message.txt
131 test_expect_failure \
132 'Patch with slash in name' '
133 stg new bar/foo -m "patch bar/foo"
136 test_done