Commit 8fac0ca4 authored by Bruno Pinto's avatar Bruno Pinto

Improve failure reports

Show name of the test that failed with the failure message.
parent 3d1a90e2
function __fish-spec.spec_init -e spec_init -a spec
set -g __current_spec_name (echo $spec | sed 's/^[0-9]*_//;s/_/ /g;s/^it/It/')
set -e __current_spec_output
set -e __current_spec_status
end
......@@ -20,7 +22,12 @@ function __fish-spec.spec_success -e spec_success
end
function __fish-spec.spec_error -e spec_error
echo -n 'F'
echo -e "\n\nFailure: $__current_spec_name"
if not set -q __current_spec_quiet
echo (omf::em) $__current_spec_output(omf::off)
end
set -g __any_spec_failed true
end
......@@ -34,11 +41,6 @@ end
function __fish-spec_assertion_error -e assertion_error -a error_message
# Mimics output redirect inside an event handler
if set -q __fish_spec_output
set __fish_spec_output $error_message
else
echo $error_message
end
set -g __current_spec_output $error_message
set -g __current_spec_status error
end
function describe_assert_error_message
function before_each
set -g __fish_spec_output "initial test value"
set -g __current_spec_quiet
end
function after_each
set -e __fish_spec_output
set -e __current_spec_quiet
end
function it_has_no_output_when_the_test_succeeds
......@@ -13,7 +13,7 @@ function describe_assert_error_message
# Reset test status
set -e __current_spec_status
assert 'initial test value' = "$__fish_spec_output"; or echo $__fish_spec_output
assert -z "$__current_spec_output"
end
function it_supports_unary_operators
......@@ -22,7 +22,7 @@ function describe_assert_error_message
# Reset test status
set -e __current_spec_status
assert 'Expected string to be empty' = "$__fish_spec_output"; or echo $__fish_spec_output
assert 'Expected string to be empty' = "$__current_spec_output"
end
function it_supports_binary_operators
......@@ -31,7 +31,7 @@ function describe_assert_error_message
# Reset test status
set -e __current_spec_status
assert 'Expected 1 to equals 2' = "$__fish_spec_output"; or echo $__fish_spec_output
assert 'Expected 1 to equals 2' = "$__current_spec_output"
end
function it_supports_inversion_on_unary_operators
......@@ -40,7 +40,7 @@ function describe_assert_error_message
# Reset test status
set -e __current_spec_status
assert 'Expected to not be empty' = "$__fish_spec_output"; or echo $__fish_spec_output
assert 'Expected to not be empty' = "$__current_spec_output"
end
function it_supports_inversion_on_binary_operators
......@@ -49,6 +49,6 @@ function describe_assert_error_message
# Reset test status
set -e __current_spec_status
assert 'Expected 1 to not equals 1' = "$__fish_spec_output"; or echo $__fish_spec_output
assert 'Expected 1 to not equals 1' = "$__current_spec_output"
end
end
function describe_results
function after_each
set -e __fish_spec_quiet
end
function it_succeeds_when_single_assertion_succeeds
assert 1 = 1
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment