-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup-and-run-git-tests.sh
executable file
·87 lines (68 loc) · 1.62 KB
/
setup-and-run-git-tests.sh
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
80
81
82
83
84
85
86
#! /bin/bash
DEBUG="${1}"
ROOT_FOLDER="/tmp/testing"
PROMPT_FOLDER="${ROOT_FOLDER}/prompt"
PROMPT_WT_FOLDER="${ROOT_FOLDER}/prompt_wt"
mkdir -p ${ROOT_FOLDER}
# Compile git tests
cd pkg/git
go test -c git.go git_test.go -o git_folder.test
go test -c git.go git_worktree_test.go -o git_worktree_folder.test
mv git_folder.test ${ROOT_FOLDER}
mv git_worktree_folder.test ${ROOT_FOLDER}
# Clean
rm -rf ${PROMPT_FOLDER}
rm -rf ${PROMPT_WT_FOLDER}
# Setup
mkdir -p ${PROMPT_FOLDER}
cd ${PROMPT_FOLDER}
git init
# Add file1
FILE1='file1.txt'
echo "test" >> ${FILE1}
git add ${FILE1}
git commit -m "Adding ${FILE1}"
# Add file2
FILE2='file2.txt'
echo "test" >> ${FILE2}
git add ${FILE2}
git stash push ${FILE2} -m "Adding ${FILE2}"
# Add pkg test folder
mkdir -p ${PROMPT_FOLDER}/pkg/git
cd ${PROMPT_FOLDER}/pkg/git
FILE3='file3.txt'
echo "test" >> ${FILE3}
git add ${FILE3}
git commit -m "Adding ${FILE3}"
# Add branches
git branch branch1
git branch branch2
# Clone bare
cd ${PROMPT_FOLDER}
cd ..
git clone --bare prompt prompt_wt
cd prompt_wt
# Add worktree branches
git worktree add master
git worktree add branch1
git worktree add branch2
cd master
# Add file4
FILE4='file4.txt'
echo "test" >> ${FILE4}
git add ${FILE4}
git stash push ${FILE4} -m "Adding ${FILE4}"
# Copy git.test
cp ${ROOT_FOLDER}/git_folder.test ${PROMPT_FOLDER}/pkg/git
cp ${ROOT_FOLDER}/git_worktree_folder.test ${PROMPT_WT_FOLDER}/master/pkg/git
# Clear
if [[ -z "${DEBUG}" ]]; then
clear
fi
# Run git.test
echo "PROMPT FOLDER"
cd ${PROMPT_FOLDER}/pkg/git
./git_folder.test
echo "PROMPT WORKTREE FOLDER"
cd ${PROMPT_WT_FOLDER}/master/pkg/git
./git_worktree_folder.test