-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest-isolated
executable file
·65 lines (49 loc) · 1.3 KB
/
test-isolated
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
#!/bin/bash
# This script tests the ih-setup script by creating
# a temporary home directory and setting $HOME to it,
# then starting a new shell in that directory.
# It also adds the bin directory of ih-core to the
# path to simulate having installed it using brew.
# If you pass "reset" as an argument the test directory
# will be deleted and recreated.
# Any other arguments will be passed to ih-setup in the
# new shell.
THIS_DIR=$(dirname "$(realpath "$0")")
export HOME=/tmp/ih-core-test
export ZDOTDIR=$HOME
command=${1:-""}
case "${command}" in
reset)
echo "Deleting temp home if it exists"
test -d /tmp/ih-core-test && rm -rf /tmp/ih-core-test
shift
;;
esac
echo "Using $HOME as home"
mkdir -p /tmp/ih-core-test
BIN_DIR="$THIS_DIR/../bin"
cd "$HOME" || exit
export PATH="$BIN_DIR:$PATH"
unset GR_HOME
unset DOD_HOME
unset GITHUB_USER
unset EMAIL_ADDRESS
unset INITIALS
unset GR_USERNAME
unset JIRA_USERNAME
unset AWS_DEFAULT_ROLE
unset EDITOR
for name in $VARS; do
unset "$name"
done
export BIN_DIR=$BIN_DIR
if [[ $# -gt 0 ]]; then
"$BIN_DIR/ih-setup" "$@"
if [[ ! $? ]]; then
echo "Bootstrap failed"
fi
fi
# open a new shell in our test context.
# Disable command hashing to prevent it from choosing the
# installed ih-setup over the one in the modified path
zsh --nohashcmds