-
Notifications
You must be signed in to change notification settings - Fork 0
/
test-helpers.zsh
79 lines (66 loc) · 1.64 KB
/
test-helpers.zsh
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
# Ensure we only use our git configuration. ($HOME is a temporary directory.)
export GIT_CONFIG_GLOBAL=$HOME/.gitconfig GIT_CONFIG_SYSTEM=/dev/null
# Disable warning message about git-status-vars
export IGNORE_GIT_STATUS_VARS=1
# GitHub actions fail if these are not set.
git config --global user.email "null@example.com"
git config --global user.name "Test Runner"
source danielparks-zsh-theme.plugin.zsh
after_test () {
(
_danielparks_theme_precmd 2>&1
print -P "${PROMPT}your-command here"
) | sed -e 's/^/ /'
}
assert_prompt_exit_eq () {
check_arguments assert_preprompt_eq 3 "$@"
assert_eq "$(_danielparks_theme_precmd 2>&1)" "$(print -Pn "$2")"
set +e
( return $1 )
_danielparks_theme_precmd &>/dev/null
set -e
assert_eq "$PROMPT" "$3"
}
assert_prompt_eq () {
check_arguments assert_preprompt_eq 2 "$@"
assert_prompt_exit_eq 0 "$@"
}
assert_git_info_eq () {
check_arguments assert_git_info_eq 1 "$@"
assert_eq "$(_danielparks_theme_git_info 2>&1)" "$1"
}
assert_git_info_fallback_eq () {
check_arguments assert_git_info_fallback_eq 1 "$@"
assert_eq "$(_danielparks_theme_git_info_fallback 2>&1)" "$1"
}
mkdir_cd () {
check_arguments mkdir_cd 1 "$@"
mkdir -p $1
cd $1
}
cd_repo () {
check_arguments cd_repo 1 "$@"
cd ~/$1
}
create_cd_repo () {
check_arguments create_cd_repo 1 "$@"
mkdir_cd ~/"$1"
git init --quiet
}
clone_cd_repo () {
check_arguments clone_cd_repo 2 "$@"
cd
git clone --quiet "$1" "$2"
cd "$2"
}
change_files_then_commit () {
for file in "$@" ; do
echo $EPOCHREALTIME >$file
done
git add "$@"
git commit --quiet -m "Modified: $*"
}
make_commit_repo () {
git init --quiet
change_files_then_commit a b
}