-
-
Notifications
You must be signed in to change notification settings - Fork 275
/
ein.sh
204 lines (191 loc) · 7.51 KB
/
ein.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
# Must be sourced into the main journey test
set -eu
if test "$kind" = "max"; then
title "Porcelain ${kind}"
(
(when "running a debug-only panic test"
snapshot="$snapshot/panic-behaviour"
(with "the --quiet option set"
it "fails as expected" && {
WITH_SNAPSHOT="$snapshot/expected-failure" \
expect_run_sh 101 "$exe -q panic"
}
)
(with "NO --quiet option set"
it "fails as expected" && {
WITH_SNAPSHOT="$snapshot/expected-failure-in-thread" \
expect_run_sh 101 "$exe panic"
}
)
(not_on_ci # due to different TTY settings, the output differs, it's OK for now
(with "progress option set"
it "fails as expected" && {
WITH_SNAPSHOT="$snapshot/expected-failure-in-thread-with-progress" \
expect_run_sh $WITH_FAILURE "$exe --progress panic"
}
)
)
)
snapshot="$snapshot/porcelain"
(with_program tree
(when "using the 'tool' subcommand"
title "ein tool"
(with "a repo with a tiny commit history"
(small-repo-in-sandbox
title "ein tool estimate-hours"
(when "running 'estimate-hours'"
snapshot="$snapshot/estimate-hours"
(with "no arguments"
it "succeeds and prints only a summary" && {
WITH_SNAPSHOT="$snapshot/no-args-success" \
expect_run_sh $SUCCESSFULLY "$exe tool estimate-hours 2>/dev/null"
}
)
(with "the show-pii argument"
it "succeeds and shows information identifying people before the summary" && {
WITH_SNAPSHOT="$snapshot/show-pii-success" \
expect_run_sh $SUCCESSFULLY "$exe tool estimate-hours --show-pii 2>/dev/null"
}
)
(with "the omit-unify-identities argument"
it "succeeds and doesn't show unified identities (in this case there is only one author anyway)" && {
WITH_SNAPSHOT="$snapshot/no-unify-identities-success" \
expect_run_sh $SUCCESSFULLY "$exe t estimate-hours --omit-unify-identities 2>/dev/null"
}
)
(with "the --file-stats argument"
it "succeeds and shows file statistics" && {
WITH_SNAPSHOT="$snapshot/file-stats-success" \
expect_run_sh $SUCCESSFULLY "$exe tool estimate-hours --file-stats 2>/dev/null"
}
)
(with "the --line-stats argument"
it "succeeds and shows line statistics" && {
WITH_SNAPSHOT="$snapshot/line-stats-success" \
expect_run_sh $SUCCESSFULLY "$exe tool estimate-hours --line-stats 2>/dev/null"
}
)
(with "all --stats arguments and pii"
it "succeeds and shows all statistics" && {
WITH_SNAPSHOT="$snapshot/all-stats-success" \
expect_run_sh $SUCCESSFULLY "$exe tool estimate-hours -pfl 2>/dev/null"
}
)
(with "a branch name that doesn't exist"
it "fails and shows a decent enough error message" && {
WITH_SNAPSHOT="$snapshot/invalid-branch-name-failure" \
expect_run_sh $WITH_FAILURE "$exe -q t estimate-hours . foobar"
}
)
)
)
)
(with "a mix of repositories"
(sandbox
repo-with-remotes dir/one-origin origin https://example.com/one-origin
repo-with-remotes origin-and-fork origin https://example.com/origin-and-fork fork https://example.com/other/origin-and-fork
repo-with-remotes special-origin special-name https://example.com/special-origin
repo-with-remotes no-origin
repo-with-remotes a-non-bare-repo-with-extension.git origin https://example.com/a-repo-with-extension.git
snapshot="$snapshot/tool"
title "ein tool find"
(when "running 'find'"
snapshot="$snapshot/find"
(with "no arguments"
it "succeeds and prints a list of repository work directories" && {
WITH_SNAPSHOT="$snapshot/no-args-success" \
expect_run_sh $SUCCESSFULLY "$exe tool find 2>/dev/null"
}
)
)
title "ein tool organize"
(when "running 'organize'"
snapshot="$snapshot/organize"
(with "no arguments"
it "succeeds and informs about the operations that it WOULD do" && {
WITH_SNAPSHOT="$snapshot/no-args-success" \
expect_run_sh $SUCCESSFULLY "$exe tool organize 2>/dev/null"
}
it "does not change the directory structure at all" && {
WITH_SNAPSHOT="$snapshot/initial-directory-structure" \
expect_run $SUCCESSFULLY tree -L 2
}
)
(with "--execute"
it "succeeds" && {
WITH_SNAPSHOT="$snapshot/execute-success" \
expect_run_sh $SUCCESSFULLY "$exe tool organize --execute 2>/dev/null"
}
it "changes the directory structure" && {
WITH_SNAPSHOT="$snapshot/directory-structure-after-organize" \
expect_run $SUCCESSFULLY tree -L 2
}
)
(with "--execute again"
it "succeeds" && {
WITH_SNAPSHOT="$snapshot/execute-success" \
expect_run_sh $SUCCESSFULLY "$exe tool organize --execute 2>/dev/null"
}
it "does not alter the directory structure as these are already in place" && {
WITH_SNAPSHOT="$snapshot/directory-structure-after-organize" \
expect_run $SUCCESSFULLY tree -L 2
}
)
)
(with "running with no further arguments"
it "succeeds and informs about possible operations" && {
WITH_SNAPSHOT="$snapshot/no-args-failure" \
expect_run_sh $WITH_CLAP_FAILURE "$exe t"
}
)
)
)
)
)
title "ein init"
(when "running 'init'"
snapshot="$snapshot/init"
(with "no argument"
(with "an empty directory"
(sandbox
it "succeeds" && {
WITH_SNAPSHOT="$snapshot/success" \
expect_run $SUCCESSFULLY "$exe" init
}
it "matches the output of baseline git init" && {
rm .git/config # this one is altered, ignore
expect_snapshot "$fixtures/baseline-init" .git
}
(when "trying to initialize the same directory again"
it "fails" && {
WITH_SNAPSHOT="$snapshot/fail" \
expect_run $WITH_FAILURE "$exe" init
}
)
)
)
)
(with "a single argument denoting the directory to initialize"
DIR=foo/bar
(with "a multi-element directory: $DIR"
(sandbox
it "succeeds" && {
WITH_SNAPSHOT="$snapshot/success-with-multi-element-directory" \
expect_run $SUCCESSFULLY "$exe" init $DIR
}
it "matches the output of baseline git init" && {
rm $DIR/.git/config # this one is altered, ignore
expect_snapshot "$fixtures/baseline-init" $DIR/.git
}
(when "trying to initialize the same directory again"
it "fails" && {
WITH_SNAPSHOT="$snapshot/fail-with-multi-element-directory" \
expect_run $WITH_FAILURE "$exe" init $DIR
}
)
)
)
)
)
)
fi