@matheusbsbs / matheus-bagliano / commits / 15a4802a69
Fork 0

t6030: modernize "git bisect run" tests

Enforce consistent styling for tests on "git bisect run": - Use "write_script" to abstract away platform-specific details. - Favor current whitespace conventions. - While at it, change "introduced" to "added" in the comments to make them read better. Helped-by: Martin Ågren <martin.agren@gmail.com> Signed-off-by: Aaron Lipman <alipman88@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Aaron Lipman committed Aug 7, 2020 at 17:58 UTC 15a4802a69d0dd5e8a1b058d4a2cd5bec6c4bd6a
1 file changed +38 -48
t/t6030-bisect-porcelain.sh
+38 -48
@@ -243,32 +243,30 @@ test_expect_success 'bisect skip: with commit both bad and skipped' '
243 '
244
245 # We want to automatically find the commit that
246 -# introduced "Another" into hello.
247 -test_expect_success \
248 - '"git bisect run" simple case' \
249 - 'echo "#"\!"/bin/sh" > test_script.sh &&
250 - echo "grep Another hello > /dev/null" >> test_script.sh &&
251 - echo "test \$? -ne 0" >> test_script.sh &&
252 - chmod +x test_script.sh &&
253 - git bisect start &&
254 - git bisect good $HASH1 &&
255 - git bisect bad $HASH4 &&
256 - git bisect run ./test_script.sh > my_bisect_log.txt &&
257 - grep "$HASH3 is the first bad commit" my_bisect_log.txt &&
258 - git bisect reset'
246 +# added "Another" into hello.
247 +test_expect_success '"git bisect run" simple case' '
248 + write_script test_script.sh <<-\EOF &&
249 + ! grep Another hello >/dev/null
250 + EOF
251 + git bisect start &&
252 + git bisect good $HASH1 &&
253 + git bisect bad $HASH4 &&
254 + git bisect run ./test_script.sh >my_bisect_log.txt &&
255 + grep "$HASH3 is the first bad commit" my_bisect_log.txt &&
256 + git bisect reset
257 +'
258
259 # We want to automatically find the commit that
261 -# introduced "Ciao" into hello.
262 -test_expect_success \
263 - '"git bisect run" with more complex "git bisect start"' \
264 - 'echo "#"\!"/bin/sh" > test_script.sh &&
265 - echo "grep Ciao hello > /dev/null" >> test_script.sh &&
266 - echo "test \$? -ne 0" >> test_script.sh &&
267 - chmod +x test_script.sh &&
268 - git bisect start $HASH4 $HASH1 &&
269 - git bisect run ./test_script.sh > my_bisect_log.txt &&
270 - grep "$HASH4 is the first bad commit" my_bisect_log.txt &&
271 - git bisect reset'
260 +# added "Ciao" into hello.
261 +test_expect_success '"git bisect run" with more complex "git bisect start"' '
262 + write_script test_script.sh <<-\EOF &&
263 + ! grep Ciao hello >/dev/null
264 + EOF
265 + git bisect start $HASH4 $HASH1 &&
266 + git bisect run ./test_script.sh >my_bisect_log.txt &&
267 + grep "$HASH4 is the first bad commit" my_bisect_log.txt &&
268 + git bisect reset
269 +'
270
271 # $HASH1 is good, $HASH5 is bad, we skip $HASH3
272 # but $HASH4 is good,
@@ -295,24 +293,17 @@ HASH6=
293 test_expect_success 'bisect run & skip: cannot tell between 2' '
294 add_line_into_file "6: Yet a line." hello &&
295 HASH6=$(git rev-parse --verify HEAD) &&
298 - echo "#"\!"/bin/sh" > test_script.sh &&
299 - echo "sed -ne \\\$p hello | grep Ciao > /dev/null && exit 125" >> test_script.sh &&
300 - echo "grep line hello > /dev/null" >> test_script.sh &&
301 - echo "test \$? -ne 0" >> test_script.sh &&
302 - chmod +x test_script.sh &&
296 + write_script test_script.sh <<-\EOF &&
297 + sed -ne \$p hello | grep Ciao >/dev/null && exit 125
298 + ! grep line hello >/dev/null
299 + EOF
300 git bisect start $HASH6 $HASH1 &&
304 - if git bisect run ./test_script.sh > my_bisect_log.txt
305 - then
306 - echo Oops, should have failed.
307 - false
308 - else
309 - test $? -eq 2 &&
310 - grep "first bad commit could be any of" my_bisect_log.txt &&
311 - ! grep $HASH3 my_bisect_log.txt &&
312 - ! grep $HASH6 my_bisect_log.txt &&
313 - grep $HASH4 my_bisect_log.txt &&
314 - grep $HASH5 my_bisect_log.txt
315 - fi
301 + test_expect_code 2 git bisect run ./test_script.sh >my_bisect_log.txt &&
302 + grep "first bad commit could be any of" my_bisect_log.txt &&
303 + ! grep $HASH3 my_bisect_log.txt &&
304 + ! grep $HASH6 my_bisect_log.txt &&
305 + grep $HASH4 my_bisect_log.txt &&
306 + grep $HASH5 my_bisect_log.txt
307 '
308
309 HASH7=
@@ -320,14 +311,13 @@ test_expect_success 'bisect run & skip: find first bad' '
311 git bisect reset &&
312 add_line_into_file "7: Should be the last line." hello &&
313 HASH7=$(git rev-parse --verify HEAD) &&
323 - echo "#"\!"/bin/sh" > test_script.sh &&
324 - echo "sed -ne \\\$p hello | grep Ciao > /dev/null && exit 125" >> test_script.sh &&
325 - echo "sed -ne \\\$p hello | grep day > /dev/null && exit 125" >> test_script.sh &&
326 - echo "grep Yet hello > /dev/null" >> test_script.sh &&
327 - echo "test \$? -ne 0" >> test_script.sh &&
328 - chmod +x test_script.sh &&
314 + write_script test_script.sh <<-\EOF &&
315 + sed -ne \$p hello | grep Ciao >/dev/null && exit 125
316 + sed -ne \$p hello | grep day >/dev/null && exit 125
317 + ! grep Yet hello >/dev/null
318 + EOF
319 git bisect start $HASH7 $HASH1 &&
330 - git bisect run ./test_script.sh > my_bisect_log.txt &&
320 + git bisect run ./test_script.sh >my_bisect_log.txt &&
321 grep "$HASH6 is the first bad commit" my_bisect_log.txt
322 '
323