summaryrefslogtreecommitdiff
path: root/t/t7900-index-helper.sh
blob: 12b5bf73b0ca75ae42440b2e712b5eab37621099 (plain)
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
#!/bin/sh
#
# Copyright (c) 2016, Twitter, Inc
#

test_description='git-index-helper

Testing git index-helper
'

. ./test-lib.sh

git index-helper -h 2>/dev/null
test $? = 129 ||
{
	skip_all='skipping index-helper tests: no index-helper executable'
	test_done
}

test_expect_success 'index-helper smoke test' '
	# We need an existing commit so that the index exists (otherwise,
	# the index-helper will not be autostarted)
	test_commit x &&
	git index-helper --exit-after 1 &&
	test_path_is_missing .git/index-helper.sock
'

test_expect_success 'index-helper creates usable path file and can be killed' '
	test_when_finished "git index-helper --kill" &&
	test_path_is_missing .git/index-helper.sock &&
	git index-helper --detach &&
	test -S .git/index-helper.sock &&
	git index-helper --kill &&
	test_path_is_missing .git/index-helper.sock
'

test_expect_success 'index-helper will not start if already running' '
	test_when_finished "git index-helper --kill" &&
	git index-helper --detach &&
	test -S .git/index-helper.sock &&
	test_must_fail git index-helper 2>err &&
	test -S .git/index-helper.sock &&
	grep "Already running" err
'

test_expect_success 'index-helper is quiet with --autorun' '
	test_when_finished "git index-helper --kill" &&
	git index-helper --kill &&
	git index-helper --detach &&
	test -S .git/index-helper.sock &&
	git index-helper --autorun
'

test_expect_success 'index-helper autorun works' '
	test_when_finished "git index-helper --kill" &&
	rm -f .git/index-helper.sock &&
	git status &&
	test_path_is_missing .git/index-helper.sock &&
	test_config indexhelper.autorun true &&
	git status &&
	test -S .git/index-helper.sock &&
	git status 2>err &&
	test -S .git/index-helper.sock &&
	test_must_be_empty err &&
	git index-helper --kill &&
	test_config indexhelper.autorun false &&
	git status &&
	test_path_is_missing .git/index-helper.sock
'

test_expect_success 'indexhelper.exitafter config works' '
	test_when_finished "git index-helper --kill" &&
	test_config indexhelper.exitafter 1 &&
	git index-helper --detach &&
	sleep 3 &&
	test_path_is_missing .git/index-helper.sock
'

test_done