removed windows and linux split subdir
This commit is contained in:
parent
83dda10fa8
commit
065b982734
280 changed files with 9053 additions and 426 deletions
70
.antidote/tests/functions/mockgit
Normal file
70
.antidote/tests/functions/mockgit
Normal file
|
|
@ -0,0 +1,70 @@
|
|||
#!/bin/zsh
|
||||
#function mockgit {
|
||||
# handle these commands:
|
||||
# - `git -C "$dir" config remote.origin.url`
|
||||
# - `git -C "$dir" pull --quiet --ff --rebase --autostash`
|
||||
# - `git -C "$dir" rev-parse --short HEAD`
|
||||
# - `git clone --quiet --depth 1 --recurse-submodules --shallow-submodules --branch branch $url $dir`
|
||||
# - `git --version`
|
||||
emulate -L zsh; setopt local_options extended_glob
|
||||
local MATCH MBEGIN MEND; local -a match mbegin mend # appease 'warn_create_global'
|
||||
0=${(%):-%x}
|
||||
|
||||
local args=("$@[@]")
|
||||
local o_path o_quiet o_ff o_rebase o_autostash o_short
|
||||
local o_depth o_recurse_submodules o_shallow_submodules o_branch
|
||||
local o_init o_recursive
|
||||
zparseopts -D -E -- \
|
||||
C:=o_path \
|
||||
-short=o_short \
|
||||
-quiet=o_quiet \
|
||||
-ff=o_ff \
|
||||
-rebase=o_rebase \
|
||||
-autostash=o_autostash \
|
||||
-recurse-submodules=o_recurse_submodules \
|
||||
-shallow-submodules=o_shallow_submodules \
|
||||
-depth:=o_depth \
|
||||
-branch:=o_branch \
|
||||
-init=o_init \
|
||||
-recursive=o_recursive ||
|
||||
return 1
|
||||
|
||||
if [[ "$@" = "--version" ]]; then
|
||||
echo "0.0.0"
|
||||
elif [[ "$1" = "clone" ]]; then
|
||||
local giturl="$2"
|
||||
local bundledir="$3"
|
||||
local src="$ANTIDOTE_HOME/${bundledir:t}"
|
||||
if [[ -d $src ]]; then
|
||||
cp -r $src ${bundledir:h}
|
||||
elif ! (( $#o_quiet )); then
|
||||
echo "MOCKGIT: Cloning into '${url:t}'..."
|
||||
echo "MOCKGIT: Repository not found."
|
||||
echo "MOCKGIT: repository '$url' not found"
|
||||
fi
|
||||
elif [[ "$@" = "config remote.origin.url" ]]; then
|
||||
if [[ -e $bundledir/.git/config/remote.origin.url ]]; then
|
||||
cat $bundledir/.git/config/remote.origin.url
|
||||
else
|
||||
# un-sanitize dir into URL
|
||||
local url=$o_path[-1]
|
||||
url=${url:t}
|
||||
url=${url:gs/-AT-/\@}
|
||||
url=${url:gs/-COLON-/\:}
|
||||
url=${url:gs/-SLASH-/\/}
|
||||
echo "$url"
|
||||
fi
|
||||
elif [[ "$@" = "pull" ]]; then
|
||||
(( $#o_quiet )) || echo "MOCKGIT: Already up to date."
|
||||
elif [[ "$@" = "rev-parse HEAD" ]]; then
|
||||
#echo "a123456"
|
||||
echo ""
|
||||
elif [[ "$@" = "submodule sync" ]]; then
|
||||
# nothing to do
|
||||
elif [[ "$@" = "submodule update" ]]; then
|
||||
# nothing to do
|
||||
else
|
||||
echo >&2 "mocking not implemented for git command: git $@"
|
||||
return 1
|
||||
fi
|
||||
#}
|
||||
17
.antidote/tests/functions/subenv
Normal file
17
.antidote/tests/functions/subenv
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
#!/bin/zsh
|
||||
#function subenv {
|
||||
emulate -L zsh; setopt local_options
|
||||
|
||||
if (( $# == 0 )); then
|
||||
set -- HOME
|
||||
fi
|
||||
|
||||
local -a sedargs=(-e "s|\$HOME|$HOME|g")
|
||||
while (( $# )); do
|
||||
if [[ -v "$1" ]]; then
|
||||
sedargs+=(-e "s|${(P)1}|\$$1|g")
|
||||
fi
|
||||
shift
|
||||
done
|
||||
sed "$sedargs[@]"
|
||||
#}
|
||||
7
.antidote/tests/functions/t_reset
Normal file
7
.antidote/tests/functions/t_reset
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
#!/bin/zsh
|
||||
#function t_reset {
|
||||
0=${(%):-%x}
|
||||
t_teardown
|
||||
t_setup
|
||||
source ${0:A:h:h:h}/antidote.zsh
|
||||
#}
|
||||
54
.antidote/tests/functions/t_setup
Normal file
54
.antidote/tests/functions/t_setup
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
#!/bin/zsh
|
||||
#function t_setup {
|
||||
emulate -L zsh
|
||||
setopt local_options extended_glob glob_dots
|
||||
|
||||
0=${(%):-%x}
|
||||
local prjdir="${0:A:h:h:h}"
|
||||
local testdir="${0:A:h:h}"
|
||||
|
||||
# save path/fpath
|
||||
typeset -ga T_PREV_PATH=( $path )
|
||||
typeset -ga T_PREV_FPATH=( $fpath )
|
||||
|
||||
# save zstyles, and clear them all for the test session
|
||||
typeset -ga T_PREV_ZSTYLES=( ${(@f)"$(zstyle -L ':antidote:*')"} )
|
||||
source <(zstyle -L ':antidote:*' | awk '{print "zstyle -d",$2}')
|
||||
|
||||
# setup test functions
|
||||
fpath+=( $testdir/functions )
|
||||
autoload -Uz $testdir/functions/*
|
||||
|
||||
# mock git
|
||||
function git { mockgit "$@" }
|
||||
|
||||
# works with BSD and GNU gmktemp
|
||||
T_TEMPDIR=${$(mktemp -d -t t_antidote.XXXXXXXX):A}
|
||||
typeset -g T_PREV_HOME=$HOME
|
||||
typeset -g T_PREV_ZDOTDIR=$ZDOTDIR
|
||||
|
||||
export HOME=$T_TEMPDIR
|
||||
export ZDOTDIR=$HOME/.zsh
|
||||
typeset -g ANTIDOTE_HOME=$HOME/.cache/antidote
|
||||
|
||||
# put tmp_home into position
|
||||
for p in $testdir/tmp_home/*; do
|
||||
cp -rf $p $T_TEMPDIR
|
||||
done
|
||||
|
||||
# rename .mockgit to .git
|
||||
local mockdir
|
||||
for mockdir in $T_TEMPDIR/**/.mock*; do
|
||||
mv $mockdir ${mockdir:s/.mock/.}
|
||||
done
|
||||
|
||||
# our mock plugins use this
|
||||
typeset -ga plugins=()
|
||||
typeset -ga libs=()
|
||||
|
||||
# setup antidote
|
||||
zstyle ':antidote:tests' set-warn-options 'on'
|
||||
zstyle ':antidote:tests' cloning 'off'
|
||||
zstyle ':antidote:bundle' use-friendly-names on
|
||||
zstyle ':antidote:defer' bundle 'getantidote/zsh-defer'
|
||||
#}
|
||||
30
.antidote/tests/functions/t_setup_real
Normal file
30
.antidote/tests/functions/t_setup_real
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
#!/bin/zsh
|
||||
#function t_setup_real {
|
||||
0=${(%):-%x}
|
||||
local testdir="${0:A:h:h}"
|
||||
local prjdir="${0:A:h:h:h}"
|
||||
|
||||
# undo setup so we clone for real
|
||||
zstyle ':antidote:tests' cloning 'on'
|
||||
(( $+functions[git] )) && unfunction git
|
||||
|
||||
# unset other testing zstyles
|
||||
zstyle -d ':antidote:defer' bundle
|
||||
|
||||
# unset rupa/z
|
||||
(( $+aliases[z] )) && unalias z
|
||||
|
||||
# replace .zsh_plugins.txt with real versions
|
||||
local file
|
||||
for file in .zsh_plugins.txt .zsh_plugins.zsh; do
|
||||
[[ -f $ZDOTDIR/$file ]] && command rm -f -- "$ZDOTDIR/$file"
|
||||
[[ -f $testdir/real/$file ]] && command rm -f -- "$testdir/real/$file"
|
||||
done
|
||||
|
||||
# clean out antidote home
|
||||
[[ -d $ANTIDOTE_HOME ]] && command rm -rf -- "$ANTIDOTE_HOME"
|
||||
mkdir -p "$ANTIDOTE_HOME"
|
||||
|
||||
# source antidote
|
||||
source $prjdir/antidote.zsh
|
||||
#}
|
||||
44
.antidote/tests/functions/t_teardown
Normal file
44
.antidote/tests/functions/t_teardown
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
#!/bin/zsh
|
||||
|
||||
#function t_teardown {
|
||||
emulate -L zsh
|
||||
setopt local_options
|
||||
|
||||
# reset current session
|
||||
HOME=$T_PREV_HOME
|
||||
ZDOTDIR=$T_PREV_ZDOTDIR
|
||||
|
||||
# unfunction all antidote
|
||||
for fn in ${(k)functions}; do
|
||||
[[ $fn == *antidote* ]] && unfunction -- $fn
|
||||
done
|
||||
(( $+functions[git] )) && unfunction git
|
||||
|
||||
# unfunction zsh-defer
|
||||
(( $+functions[zsh-defer] )) && unfunction zsh-defer
|
||||
|
||||
# restore original path/fpath
|
||||
path=( $T_PREV_PATH )
|
||||
fpath=( $T_PREV_FPATH )
|
||||
|
||||
# restore original zstyles
|
||||
source <(zstyle -L ':antidote:*' | awk '{print "zstyle -d",$2}')
|
||||
source <(printf '%s\n' $T_PREV_ZSTYLES)
|
||||
|
||||
# remove tempdir
|
||||
[[ -d "$T_TEMPDIR" ]] && command rm -rf -- "$T_TEMPDIR"
|
||||
|
||||
# remove vars
|
||||
for var in \
|
||||
ANTIDOTE_HOME \
|
||||
T_TEMPDIR \
|
||||
T_PREV_HOME \
|
||||
T_PREV_ZDOTDIR \
|
||||
T_PREV_PATH \
|
||||
T_PREV_FPATH \
|
||||
plugins \
|
||||
libs
|
||||
do
|
||||
[[ -v $var ]] && unset $var
|
||||
done
|
||||
#}
|
||||
13
.antidote/tests/functions/t_unload_antidote
Normal file
13
.antidote/tests/functions/t_unload_antidote
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
#!/bin/zsh
|
||||
|
||||
emulate -L zsh
|
||||
setopt local_options
|
||||
|
||||
# unfunction all antidote
|
||||
for fn in ${(k)functions}; do
|
||||
[[ $fn == *antidote* ]] && [[ $fn != t_* ]] && unfunction -- $fn
|
||||
done
|
||||
(( $+functions[git] )) && unfunction git
|
||||
|
||||
# unfunction zsh-defer
|
||||
(( $+functions[zsh-defer] )) && unfunction zsh-defer
|
||||
Loading…
Add table
Add a link
Reference in a new issue