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 <peff@peff.net> Signed-off-by: Taylor Blau <me@ttaylorr.com>

Jeff King committed Sep 28, 2022 at 18:50 UTC 32696a4cbe90929ae79ea442f5102c513ce3dfaa
1 file changed +31
t/t9850-shell.sh new
+31
@@ -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