Skip to content

Commit 32696a4

Browse files
peffttaylorr
authored andcommitted
shell: add basic tests
We have no tests of even basic functionality of git-shell. Let's add a couple of obvious ones. This will serve as a framework for adding tests for new things we fix, as well as making sure we don't screw anything up too badly while doing so. Signed-off-by: Jeff King <[email protected]> Signed-off-by: Taylor Blau <[email protected]>
1 parent a1d4f67 commit 32696a4

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

t/t9850-shell.sh

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/bin/sh
2+
3+
test_description='git shell tests'
4+
. ./test-lib.sh
5+
6+
test_expect_success 'shell allows upload-pack' '
7+
printf 0000 >input &&
8+
git upload-pack . <input >expect &&
9+
git shell -c "git-upload-pack $SQ.$SQ" <input >actual &&
10+
test_cmp expect actual
11+
'
12+
13+
test_expect_success 'shell forbids other commands' '
14+
test_must_fail git shell -c "git config foo.bar baz"
15+
'
16+
17+
test_expect_success 'shell forbids interactive use by default' '
18+
test_must_fail git shell
19+
'
20+
21+
test_expect_success 'shell allows interactive command' '
22+
mkdir git-shell-commands &&
23+
write_script git-shell-commands/ping <<-\EOF &&
24+
echo pong
25+
EOF
26+
echo pong >expect &&
27+
echo ping | git shell >actual &&
28+
test_cmp expect actual
29+
'
30+
31+
test_done

0 commit comments

Comments
 (0)