Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
O
oh-my-fish
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nanahira
oh-my-fish
Commits
74d4e90f
Commit
74d4e90f
authored
Dec 23, 2015
by
Bruno
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #203 from oh-my-fish/better-test-output
Better test output
parents
0b66c436
58daae02
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
97 additions
and
58 deletions
+97
-58
pkg/fish-spec/basic_formatter.fish
pkg/fish-spec/basic_formatter.fish
+59
-0
pkg/fish-spec/functions/assert.error_message.fish
pkg/fish-spec/functions/assert.error_message.fish
+6
-6
pkg/fish-spec/functions/fish-spec.fish
pkg/fish-spec/functions/fish-spec.fish
+14
-40
pkg/fish-spec/spec/assert_error_message_spec.fish
pkg/fish-spec/spec/assert_error_message_spec.fish
+8
-8
pkg/fish-spec/spec/results_spec.fish
pkg/fish-spec/spec/results_spec.fish
+0
-4
pkg/fish-spec/utils/epoch.c
pkg/fish-spec/utils/epoch.c
+10
-0
pkg/fish-spec/utils/epoch.linux
pkg/fish-spec/utils/epoch.linux
+0
-0
pkg/fish-spec/utils/epoch.osx
pkg/fish-spec/utils/epoch.osx
+0
-0
No files found.
pkg/fish-spec/basic_formatter.fish
0 → 100644
View file @
74d4e90f
function __fish-spec.all_specs_init -e all_specs_init -a spec
set -g __fish_spec_start_time (__fish-spec.current_time)
end
function __fish-spec.all_specs_finished -e all_specs_finished -a spec
set -l __fish_spec_end_time (__fish-spec.current_time)
set -l diff (math "scale=3;($__fish_spec_end_time - $__fish_spec_start_time) / 1000")
echo -en '\n\nFinished in '
printf '%g' $diff
echo ' seconds'
end
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
function __fish-spec.spec_finished -e spec_finished -a spec
functions -e $spec
switch "$__current_spec_status"
case success
emit spec_success
case error
emit spec_error
case '*'
emit spec_no_assertions
end
end
function __fish-spec.spec_success -e spec_success
echo -n '.'
end
function __fish-spec.spec_error -e spec_error
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
function __fish-spec.spec_no_assertions -e spec_no_assertions
echo -n 'N/A'
end
function __fish-spec_assertion_success -e assertion_success
set -q __current_spec_status; or set -g __current_spec_status success
end
function __fish-spec_assertion_error -e assertion_error -a error_message
# Mimics output redirect inside an event handler
set -g __current_spec_output $error_message
set -g __current_spec_status error
end
pkg/fish-spec/functions/assert.error_message.fish
View file @
74d4e90f
...
...
@@ -6,26 +6,26 @@ function assert.error_message
switch $number_of_arguments
case 3
set operator (assert.expand_operator $argv[2])
set
expected
$argv[3]
echo "Expected
$expected to not be $operator
"
set
actual
$argv[3]
echo "Expected
result to not be $operator but it was $actual
"
case 4
set expected $argv[2]
set operator "not" (assert.expand_operator $argv[3])
set actual $argv[4]
echo "Expected
$expected to $operator
$actual"
echo "Expected
result to $operator $expected but it was
$actual"
case \*
return 1
end
case \-\*
test $number_of_arguments != 2; and return 1
set operator (assert.expand_operator $argv[1])
set
expected
$argv[2]
echo "Expected
$expected to be $operator
"
set
actual
$argv[2]
echo "Expected
result to be $operator but it was $actual
"
case \*
test $number_of_arguments != 3; and return 1
set expected $argv[1]
set operator (assert.expand_operator $argv[2])
set actual $argv[3]
echo "Expected
$expected to $operator
$actual"
echo "Expected
result to $operator $expected but it was
$actual"
end
end
pkg/fish-spec/functions/fish-spec.fish
View file @
74d4e90f
function fish-spec
set -g __fish_spec_dir (dirname (dirname (status -f)))
# Source formatter
source $__fish_spec_dir/basic_formatter.fish
# Reset internal variables
set -e __any_spec_failed
...
...
@@ -10,9 +15,13 @@ function fish-spec
# Load helper file
source spec/helper.fish ^/dev/null
emit all_specs_init
# Run all specs
__fish-spec.run_all_specs
emit all_specs_finished
not set -q __any_spec_failed
end
...
...
@@ -47,47 +56,12 @@ function __fish-spec.run_suite -a suite_name
functions -e before_all before_each after_each after_all
end
function __fish-spec.spec_init -e spec_init -a spec
set -e __current_spec_status
end
function __fish-spec.spec_finished -e spec_finished -a spec
functions -e $spec
switch "$__current_spec_status"
case success
emit spec_success
case error
emit spec_error
case '*'
emit spec_no_assertions
end
end
function __fish-spec.spec_success -e spec_success
echo -n '.'
end
function __fish-spec.spec_error -e spec_error
echo -n 'F'
set -g __any_spec_failed true
end
function __fish-spec.spec_no_assertions -e spec_no_assertions
echo -n 'N/A'
end
function __fish-spec_assertion_success -e assertion_success
set -q __current_spec_status; or set -g __current_spec_status success
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
function __fish-spec.current_time
if test (uname) = 'Darwin'
set filename 'epoch.osx'
else
echo $error_message
set filename 'epoch.linux'
end
set -g __current_spec_status error
eval $__fish_spec_dir/utils/$filename
end
pkg/fish-spec/spec/assert_error_message_spec.fish
View file @
74d4e90f
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_outpu
t
set -e __
current_spec_quie
t
end
function it_has_no_output_when_the_test_succeeds
...
...
@@ -13,16 +13,16 @@ 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
assert -z "
string
"
assert -z "
abc
"
# Reset test status
set -e __current_spec_status
assert 'Expected
string to be empty' = "$__fish_spec_output"; or echo $__fish_spec_output
assert 'Expected
result to be empty but it was abc' = "$__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
result to equals 1 but it was 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
result to not be empty but it was ' = "$__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
result to not equals 1 but it was 1' = "$__current_spec_output"
end
end
pkg/fish-spec/spec/results_spec.fish
View file @
74d4e90f
function describe_results
function after_each
set -e __fish_spec_quiet
end
function it_succeeds_when_single_assertion_succeeds
assert 1 = 1
...
...
pkg/fish-spec/utils/epoch.c
0 → 100644
View file @
74d4e90f
#include <stdio.h>
#include <sys/time.h>
int
main
(
int
argc
,
char
**
argv
)
{
struct
timeval
time_struct
;
gettimeofday
(
&
time_struct
,
0
);
printf
(
"%lld"
,
(
time_struct
.
tv_sec
*
1000ll
)
+
(
time_struct
.
tv_usec
/
1000ll
));
return
0
;
}
pkg/fish-spec/utils/epoch.linux
0 → 100755
View file @
74d4e90f
File added
pkg/fish-spec/utils/epoch.osx
0 → 100755
View file @
74d4e90f
File added
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment