Skip to content

Commit dc7e7bc

Browse files
ienorandgitster
authored andcommitted
t9903: add extra tests for bash.showDirtyState
Add 3 extra tests for the bash.showDirtyState config option; the tests now cover all combinations of the shell var being set/unset and the config option being missing/enabled/disabled, given a dirty file. Signed-off-by: Martin Erik Werner <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 58978e8 commit dc7e7bc

File tree

1 file changed

+37
-1
lines changed

1 file changed

+37
-1
lines changed

t/t9903-bash-prompt.sh

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,11 +360,47 @@ test_expect_success 'prompt - dirty status indicator - before root commit' '
360360
test_cmp expected "$actual"
361361
'
362362

363-
test_expect_success 'prompt - dirty status indicator - disabled by config' '
363+
test_expect_success 'prompt - dirty status indicator - shell variable unset with config disabled' '
364364
printf " (master)" > expected &&
365365
echo "dirty" > file &&
366366
test_when_finished "git reset --hard" &&
367367
test_config bash.showDirtyState false &&
368+
(
369+
sane_unset GIT_PS1_SHOWDIRTYSTATE &&
370+
__git_ps1 > "$actual"
371+
) &&
372+
test_cmp expected "$actual"
373+
'
374+
375+
test_expect_success 'prompt - dirty status indicator - shell variable unset with config enabled' '
376+
printf " (master)" > expected &&
377+
echo "dirty" > file &&
378+
test_when_finished "git reset --hard" &&
379+
test_config bash.showDirtyState true &&
380+
(
381+
sane_unset GIT_PS1_SHOWDIRTYSTATE &&
382+
__git_ps1 > "$actual"
383+
) &&
384+
test_cmp expected "$actual"
385+
'
386+
387+
test_expect_success 'prompt - dirty status indicator - shell variable set with config disabled' '
388+
printf " (master)" > expected &&
389+
echo "dirty" > file &&
390+
test_when_finished "git reset --hard" &&
391+
test_config bash.showDirtyState false &&
392+
(
393+
GIT_PS1_SHOWDIRTYSTATE=y &&
394+
__git_ps1 > "$actual"
395+
) &&
396+
test_cmp expected "$actual"
397+
'
398+
399+
test_expect_success 'prompt - dirty status indicator - shell variable set with config enabled' '
400+
printf " (master *)" > expected &&
401+
echo "dirty" > file &&
402+
test_when_finished "git reset --hard" &&
403+
test_config bash.showDirtyState true &&
368404
(
369405
GIT_PS1_SHOWDIRTYSTATE=y &&
370406
__git_ps1 > "$actual"

0 commit comments

Comments
 (0)