From 97bbe9afe81c2d018dbcf54235f33b0549adf385 Mon Sep 17 00:00:00 2001 From: Koichi Nakashima Date: Wed, 27 May 2020 20:14:52 +0900 Subject: [PATCH] Fix Optimize coverage measurement --- lib/core/evaluation.sh | 2 +- spec/core/evaluation_spec.sh | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/lib/core/evaluation.sh b/lib/core/evaluation.sh index 6366dcb7..112fb525 100644 --- a/lib/core/evaluation.sh +++ b/lib/core/evaluation.sh @@ -21,7 +21,7 @@ shellspec_evaluation_call() { set "$SHELLSPEC_ERREXIT" "${SHELLSPEC_SHELL_OPTION:-eval}" "${SHELLSPEC_SHELL_OPTIONS:-:}" set +e - shellspec_evaluation_call_data shellspec_evaluation_call_function "$@" + shellspec_evaluation_call_data shellspec_evaluation_call_function "$@" &&: set -e -- $? shellspec_evaluation_cleanup "$1" } diff --git a/spec/core/evaluation_spec.sh b/spec/core/evaluation_spec.sh index d2337639..bc60db8f 100644 --- a/spec/core/evaluation_spec.sh +++ b/spec/core/evaluation_spec.sh @@ -73,6 +73,12 @@ Describe "core/evaluation.sh" The status should equal 0 End + It 'catches error when even enable errexit within function' + evaluation() { set -e; return 123; } + When call evaluation + The status should eq 123 + End + It 'reads data from stdin' Data "data" When call cat @@ -156,6 +162,12 @@ Describe "core/evaluation.sh" The status should equal 0 End + It 'catches error when even enable errexit within function' + evaluation() { set -e; return 123; } + When run evaluation + The status should eq 123 + End + It 'reads data from stdin' Data "data" When run command cat