Skip to content

Commit

Permalink
Revert "Add BeforeAll/AfterAll"
Browse files Browse the repository at this point in the history
This reverts commit 80fac44.
  • Loading branch information
ko1nksm committed Nov 29, 2019
1 parent 8670210 commit 5139e6b
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 46 deletions.
6 changes: 0 additions & 6 deletions lib/core/dsl.sh
Expand Up @@ -56,7 +56,6 @@ shellspec_description() {
shellspec_example_group() {
shellspec_description "example_group" "${1:-}${1:+$SHELLSPEC_VT}"
shellspec_yield
shellspec_call_after_hooks ALL
}

shellspec_example_block() {
Expand Down Expand Up @@ -95,8 +94,6 @@ shellspec_example() {
shellspec_output EXAMPLE
shellspec_output SUCCEEDED
else
shellspec_call_before_hooks ALL
shellspec_mark_executed_group "$SHELLSPEC_GROUP_ID"
shellspec_profile_start
case $- in
*e*)
Expand Down Expand Up @@ -269,9 +266,6 @@ shellspec_the() {
shellspec_statement_preposition "$@"
}

shellspec_proxy shellspec_before_all "shellspec_register_before_hook ALL"
shellspec_proxy shellspec_after_all "shellspec_register_after_hook ALL"

shellspec_proxy shellspec_before "shellspec_register_before_hook EACH"
shellspec_proxy shellspec_after "shellspec_register_after_hook EACH"

Expand Down
43 changes: 6 additions & 37 deletions lib/core/hook.sh
Expand Up @@ -9,9 +9,9 @@ shellspec_register_hook() {
shift 2; \
while [ \$# -gt 0 ]; do \
SHELLSPEC_$1_$2_INDEX=\$((\$SHELLSPEC_$1_$2_INDEX + 1)); \
shellspec_hook_index SHELLSPEC_$1_$2_\$SHELLSPEC_$1_$2_INDEX \"\$1\"; \
shellspec_hook_index $1 $2 \$SHELLSPEC_$1_$2_INDEX \"\$1\"; \
shift; \
done
done; \
"
eval "$SHELLSPEC_EVAL"
}
Expand All @@ -20,28 +20,13 @@ shellspec_proxy shellspec_register_before_hook "shellspec_register_hook BEFORE"
shellspec_proxy shellspec_register_after_hook "shellspec_register_hook AFTER"

shellspec_hook_index() {
eval "$1=\$SHELLSPEC_SPEC_NO@\$SHELLSPEC_GROUP_ID@\$SHELLSPEC_AUX_LINENO:\$2"
eval "SHELLSPEC_$1_$2_$3=\$4:\${SHELLSPEC_AUX_LINENO:-}"
}

shellspec_call_hook() {
eval "SHELLSPEC_HOOK=\${$2#*:} SHELLSPEC_HOOK_ID=\${$2%:*}"
#shellcheck disable=SC2034
SHELLSPEC_HOOK_LINENO=${SHELLSPEC_HOOK_ID##*@}

case $1 in
BEFORE-ALL) shellspec_marked_tag "$SHELLSPEC_HOOK_ID" && return 0 ;;
AFTER-ALL)
[ "${SHELLSPEC_HOOK_ID%@*}" = "$SHELLSPEC_SPEC_NO@$SHELLSPEC_GROUP_ID" ] || return 0
shellspec_marked_tag "${SHELLSPEC_HOOK_ID%@*}" || return 0
esac

eval "SHELLSPEC_HOOK=\${$1%:*} SHELLSPEC_HOOK_LINENO=\${$1#*:}"
eval "$SHELLSPEC_HOOK &&:" &&:
SHELLSPEC_HOOK_STATUS=$?

case $1 in
BEFORE-ALL) shellspec_mark_tag "$SHELLSPEC_HOOK_ID"
esac

return $SHELLSPEC_HOOK_STATUS
}

Expand All @@ -50,7 +35,7 @@ shellspec_call_before_hooks() {
shellspec_call_before_hooks "$1" 1
else
eval "[ \"\${2:-1}\" -gt \"\$SHELLSPEC_BEFORE_$1_INDEX\" ] &&:" && return 0
shellspec_call_hook "BEFORE-$1" "SHELLSPEC_BEFORE_$1_${2:-1}" || return $?
shellspec_call_hook "SHELLSPEC_BEFORE_$1_${2:-1}" || return $?
shellspec_call_before_hooks "$1" "$((${2:-1} + 1))"
fi
}
Expand All @@ -61,27 +46,11 @@ shellspec_call_after_hooks() {
shellspec_call_after_hooks "$1" "$2"
else
[ "$2" -lt 1 ] && return 0
shellspec_call_hook "AFTER-$1" "SHELLSPEC_AFTER_$1_$2" || return $?
shellspec_call_hook "SHELLSPEC_AFTER_$1_$2" || return $?
shellspec_call_after_hooks "$1" $(($2 - 1))
fi
}

shellspec_mark_executed_group() {
shellspec_mark_tag "$SHELLSPEC_SPEC_NO@$1"
case $1 in (*-*)
shellspec_mark_executed_group "${1%-*}"
esac
}

shellspec_mark_tag() {
[ -e "$SHELLSPEC_TMPBASE/$1" ] || : > "$SHELLSPEC_TMPBASE/$1"
}

shellspec_marked_tag() {
[ -e "$SHELLSPEC_TMPBASE/$1" ]
}

shellspec_create_hook EACH
shellspec_create_hook CALL
shellspec_create_hook RUN
shellspec_create_hook ALL
2 changes: 0 additions & 2 deletions lib/libexec/grammar.sh
Expand Up @@ -52,8 +52,6 @@ mapping() {
Path ) control path "$2" ;;
File ) control path "$2" ;;
Dir ) control path "$2" ;;
BeforeAll ) control before_all "$2" ;;
AfterAll ) control after_all "$2" ;;
Before ) control before "$2" ;;
After ) control after "$2" ;;
BeforeCall ) control before_call "$2" ;;
Expand Down
2 changes: 1 addition & 1 deletion lib/libexec/parallel-executor.sh
Expand Up @@ -31,7 +31,7 @@ reduce() {
}

executor() {
SHELLSPEC_JOBDIR="$SHELLSPEC_TMPBASE/$$.jobs"
SHELLSPEC_JOBDIR="$SHELLSPEC_TMPBASE/jobs"

mkdir "$SHELLSPEC_JOBDIR"

Expand Down

0 comments on commit 5139e6b

Please sign in to comment.