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
4e279f93
Commit
4e279f93
authored
Dec 19, 2015
by
Bruno
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #198 from oh-my-fish/test-suite
Test suite
parents
e75e0551
ea4d78ff
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
266 additions
and
0 deletions
+266
-0
.gitignore
.gitignore
+2
-0
.travis.yml
.travis.yml
+2
-0
pkg/fish-spec/functions/assert.error_message.fish
pkg/fish-spec/functions/assert.error_message.fish
+31
-0
pkg/fish-spec/functions/assert.expand_operator.fish
pkg/fish-spec/functions/assert.expand_operator.fish
+10
-0
pkg/fish-spec/functions/assert.fish
pkg/fish-spec/functions/assert.fish
+9
-0
pkg/fish-spec/functions/fish-spec.fish
pkg/fish-spec/functions/fish-spec.fish
+93
-0
pkg/fish-spec/spec/assert_error_message_spec.fish
pkg/fish-spec/spec/assert_error_message_spec.fish
+54
-0
pkg/fish-spec/spec/results_spec.fish
pkg/fish-spec/spec/results_spec.fish
+43
-0
pkg/omf/spec/basic_spec.fish
pkg/omf/spec/basic_spec.fish
+22
-0
No files found.
.gitignore
View file @
4e279f93
pkg/**
!pkg/omf
!pkg/omf/**
!pkg/fish-spec
!pkg/fish-spec/**
themes/**
...
...
.travis.yml
View file @
4e279f93
...
...
@@ -17,6 +17,8 @@ before_script:
script
:
-
docker run -t oh-my-fish /usr/bin/fish "tests/run.fish"
-
docker run -t oh-my-fish /usr/bin/fish -c "cd pkg/fish-spec; fish-spec"
-
docker run -t oh-my-fish /usr/bin/fish -c "cd pkg/omf; fish-spec"
-
docker run -t oh-my-fish /usr/bin/fish "tests/test-generate-themes-doc.fish"
after_failure
:
...
...
pkg/fish-spec/functions/assert.error_message.fish
0 → 100644
View file @
4e279f93
function assert.error_message
set -l number_of_arguments (count $argv)
switch $argv[1]
case !
switch $number_of_arguments
case 3
set operator (assert.expand_operator $argv[2])
set expected $argv[3]
echo "Expected $expected to not be $operator"
case 4
set expected $argv[2]
set operator "not" (assert.expand_operator $argv[3])
set actual $argv[4]
echo "Expected $expected to $operator $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"
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"
end
end
pkg/fish-spec/functions/assert.expand_operator.fish
0 → 100644
View file @
4e279f93
function assert.expand_operator -a operator
switch $operator
case =
echo equals
case \-z
echo empty
case \*
echo $operator
end
end
pkg/fish-spec/functions/assert.fish
0 → 100644
View file @
4e279f93
function assert --wraps test
if builtin test $argv
emit assertion_success
else
set -l assertion_status $status
emit assertion_error (assert.error_message $argv)
return $assertion_status
end
end
pkg/fish-spec/functions/fish-spec.fish
0 → 100644
View file @
4e279f93
function fish-spec
# Reset internal variables
set -e __any_spec_failed
# Load each spec file
for spec_file in spec/*_spec.fish
source $spec_file
end
# Load helper file
source spec/helper.fish ^/dev/null
# Run all specs
__fish-spec.run_all_specs
not set -q __any_spec_failed
end
function __fish-spec.run_all_specs
for suite in (functions -n | grep describe_)
__fish-spec.run_suite $suite
functions -e $suite
end
end
function __fish-spec.run_suite -a suite_name
# This gets the list of specs that were defined on the test suite by
# comparing the functions names before and after the evaluation of the test suite.
set -l specs (begin
functions -n | grep it_
eval $suite_name >/dev/null
functions -n | grep it_
end | sort | uniq -u)
functions -q before_all; and before_all
for spec in $specs
emit spec_init $spec
functions -q before_each; and before_each
eval $spec
functions -q after_each; and after_each
emit spec_finished $spec
end
functions -q after_all; and after_all
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
else
echo $error_message
end
set -g __current_spec_status error
end
pkg/fish-spec/spec/assert_error_message_spec.fish
0 → 100644
View file @
4e279f93
function describe_assert_error_message
function before_each
set -g __fish_spec_output "initial test value"
end
function after_each
set -e __fish_spec_output
end
function it_has_no_output_when_the_test_succeeds
assert 1 = 1
# Reset test status
set -e __current_spec_status
assert 'initial test value' = "$__fish_spec_output"; or echo $__fish_spec_output
end
function it_supports_unary_operators
assert -z "string"
# Reset test status
set -e __current_spec_status
assert 'Expected string to be empty' = "$__fish_spec_output"; or echo $__fish_spec_output
end
function it_supports_binary_operators
assert 1 = 2
# Reset test status
set -e __current_spec_status
assert 'Expected 1 to equals 2' = "$__fish_spec_output"; or echo $__fish_spec_output
end
function it_supports_inversion_on_unary_operators
assert ! -z ""
# Reset test status
set -e __current_spec_status
assert 'Expected to not be empty' = "$__fish_spec_output"; or echo $__fish_spec_output
end
function it_supports_inversion_on_binary_operators
assert ! 1 = 1
# Reset test status
set -e __current_spec_status
assert 'Expected 1 to not equals 1' = "$__fish_spec_output"; or echo $__fish_spec_output
end
end
pkg/fish-spec/spec/results_spec.fish
0 → 100644
View file @
4e279f93
function describe_results
function after_each
set -e __fish_spec_quiet
end
function it_succeeds_when_single_assertion_succeeds
assert 1 = 1
assert success = "$__current_spec_status"
end
function it_succeeds_when_multiple_assertion_succeeds
assert 1 = 1
assert 2 = 2
assert success = "$__current_spec_status"
end
function it_fails_when_single_assertion_fails
set -g __fish_spec_output "quiet"
assert 1 = 2
set -l spec_status $__current_spec_status
# Reset internals
set -e __current_spec_status
assert error = "$spec_status"
end
function it_fails_when_one_of_the_assertions_fails
set -g __fish_spec_output "quiet"
assert 1 = 2
assert 2 = 2
set -l spec_status $__current_spec_status
# Reset internals
set -e __current_spec_status
assert error = "$spec_status"
end
end
pkg/omf/spec/basic_spec.fish
0 → 100644
View file @
4e279f93
function describe_basic_tests
function before_all
set -gx CI WORKAROUND
end
function it_has_a_help_command
set -l output (omf help)
assert 0 = $status
end
function it_has_a_doctor_command
set -l output (omf doctor)
assert 0 = $status
end
function it_install_packages
set -l remove_output (omf remove apt ^/dev/null)
set -l install_output (omf install apt)
assert 0 = $status
end
end
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