diff --git a/test/bash_it/bash_it.bats b/test/bash_it/bash_it.bats index 2957b956..bd3995b6 100644 --- a/test/bash_it/bash_it.bats +++ b/test/bash_it/bash_it.bats @@ -61,7 +61,7 @@ function local_teardown { run alias test_alias &> /dev/null assert_success - assert_line "0" "alias test_alias='b'" + assert_line -n 0 "alias test_alias='b'" } @test "bash-it: load aliases in priority order" { @@ -84,7 +84,7 @@ function local_teardown { run alias test_alias &> /dev/null assert_success - assert_line "0" "alias test_alias='a'" + assert_line -n 0 "alias test_alias='a'" } @test "bash-it: load aliases and plugins in priority order" { @@ -109,7 +109,7 @@ function local_teardown { run alias test_alias &> /dev/null assert_success - assert_line "0" "alias test_alias='c'" + assert_line -n 0 "alias test_alias='c'" } @test "bash-it: load aliases, plugins and completions in priority order" { @@ -136,7 +136,7 @@ function local_teardown { run alias test_alias &> /dev/null assert_success # "b" wins since completions are loaded last in the old directory structure - assert_line "0" "alias test_alias='b'" + assert_line -n 0 "alias test_alias='b'" } @test "bash-it: load aliases, plugins and completions in priority order, even if the priority says otherwise" { @@ -163,7 +163,7 @@ function local_teardown { run alias test_alias &> /dev/null assert_success # "b" wins since completions are loaded last in the old directory structure - assert_line "0" "alias test_alias='b'" + assert_line -n 0 "alias test_alias='b'" } @test "bash-it: load aliases and plugins in priority order, with one alias higher than plugins" { @@ -190,7 +190,7 @@ function local_teardown { assert_success # This will be c, loaded from the c plugin, since the individual directories # are loaded one by one. - assert_line "0" "alias test_alias='c'" + assert_line -n 0 "alias test_alias='c'" } @test "bash-it: load global aliases in order" { @@ -212,7 +212,7 @@ function local_teardown { run alias test_alias &> /dev/null assert_success - assert_line "0" "alias test_alias='b'" + assert_line -n 0 "alias test_alias='b'" } @test "bash-it: load global aliases in priority order" { @@ -234,7 +234,7 @@ function local_teardown { run alias test_alias &> /dev/null assert_success - assert_line "0" "alias test_alias='a'" + assert_line -n 0 "alias test_alias='a'" } @test "bash-it: load global aliases and plugins in priority order" { @@ -258,7 +258,7 @@ function local_teardown { run alias test_alias &> /dev/null assert_success - assert_line "0" "alias test_alias='c'" + assert_line -n 0 "alias test_alias='c'" } @test "bash-it: load global aliases and plugins in priority order, with one alias higher than plugins" { @@ -284,7 +284,7 @@ function local_teardown { assert_success # This will be a, loaded from the a aliases, since the global directory # loads all component types at once - assert_line "0" "alias test_alias='a'" + assert_line -n 0 "alias test_alias='a'" } @test "bash-it: load global aliases and plugins in priority order, individual old directories are loaded later" { @@ -314,7 +314,7 @@ function local_teardown { assert_success # This will be "b", loaded from the b aliases in the individual directory, since # the individual directories are loaded after the global one. - assert_line "0" "alias test_alias='b'" + assert_line -n 0 "alias test_alias='b'" } @test "bash-it: load enabled aliases from new structure, priority-based" { diff --git a/test/completion/bash-it.completion.bats b/test/completion/bash-it.completion.bats index 6b93afeb..b8aef96f 100644 --- a/test/completion/bash-it.completion.bats +++ b/test/completion/bash-it.completion.bats @@ -74,92 +74,92 @@ function __check_completion () { @test "completion bash-it: help - show options" { run __check_completion 'bash-it help ' - assert_line "0" "aliases completions migrate plugins update" + assert_line -n 0 "aliases completions migrate plugins update" } @test "completion bash-it: help - aliases v" { run __check_completion 'bash-it help aliases v' - assert_line "0" "vagrant vault vim" + assert_line -n 0 "vagrant vault vim" } @test "completion bash-it: update - show no options" { run __check_completion 'bash-it update ' - assert_line "0" "" + assert_line -n 0 "" } @test "completion bash-it: search - show no options" { run __check_completion 'bash-it search ' - assert_line "0" "" + assert_line -n 0 "" } @test "completion bash-it: migrate - show no options" { run __check_completion 'bash-it migrate ' - assert_line "0" "" + assert_line -n 0 "" } @test "completion bash-it: show options" { run __check_completion 'bash-it ' - assert_line "0" "disable enable help migrate search show update version" + assert_line -n 0 "disable enable help migrate search show update version" } @test "completion bash-it: bash-ti - show options" { run __check_completion 'bash-ti ' - assert_line "0" "disable enable help migrate search show update version" + assert_line -n 0 "disable enable help migrate search show update version" } @test "completion bash-it: shit - show options" { run __check_completion 'shit ' - assert_line "0" "disable enable help migrate search show update version" + assert_line -n 0 "disable enable help migrate search show update version" } @test "completion bash-it: bashit - show options" { run __check_completion 'bashit ' - assert_line "0" "disable enable help migrate search show update version" + assert_line -n 0 "disable enable help migrate search show update version" } @test "completion bash-it: batshit - show options" { run __check_completion 'batshit ' - assert_line "0" "disable enable help migrate search show update version" + assert_line -n 0 "disable enable help migrate search show update version" } @test "completion bash-it: bash_it - show options" { run __check_completion 'bash_it ' - assert_line "0" "disable enable help migrate search show update version" + assert_line -n 0 "disable enable help migrate search show update version" } @test "completion bash-it: show - show options" { run __check_completion 'bash-it show ' - assert_line "0" "aliases completions plugins" + assert_line -n 0 "aliases completions plugins" } @test "completion bash-it: enable - show options" { run __check_completion 'bash-it enable ' - assert_line "0" "alias completion plugin" + assert_line -n 0 "alias completion plugin" } @test "completion bash-it: enable - show options a" { run __check_completion 'bash-it enable a' - assert_line "0" "alias" + assert_line -n 0 "alias" } @test "completion bash-it: disable - show options" { run __check_completion 'bash-it disable ' - assert_line "0" "alias completion plugin" + assert_line -n 0 "alias completion plugin" } @test "completion bash-it: disable - show options a" { run __check_completion 'bash-it disable a' - assert_line "0" "alias" + assert_line -n 0 "alias" } @test "completion bash-it: disable - provide nothing when atom is not enabled" { run __check_completion 'bash-it disable alias ato' - assert_line "0" "" + assert_line -n 0 "" } @test "completion bash-it: disable - provide all when atom is not enabled" { run __check_completion 'bash-it disable alias a' - assert_line "0" "all" + assert_line -n 0 "all" } @test "completion bash-it: disable - provide the a* aliases when atom is enabled with the old location and name" { @@ -170,7 +170,7 @@ function __check_completion () { assert [ -L "$BASH_IT/completion/enabled/apm.completion.bash" ] run __check_completion 'bash-it disable alias a' - assert_line "0" "all atom" + assert_line -n 0 "all atom" } @test "completion bash-it: disable - provide the a* aliases when atom is enabled with the old location and priority-based name" { @@ -181,7 +181,7 @@ function __check_completion () { assert [ -L "$BASH_IT/completion/enabled/350---apm.completion.bash" ] run __check_completion 'bash-it disable alias a' - assert_line "0" "all atom" + assert_line -n 0 "all atom" } @test "completion bash-it: disable - provide the a* aliases when atom is enabled with the new location and priority-based name" { @@ -192,7 +192,7 @@ function __check_completion () { assert [ -L "$BASH_IT/enabled/350---apm.completion.bash" ] run __check_completion 'bash-it disable alias a' - assert_line "0" "all atom" + assert_line -n 0 "all atom" } @test "completion bash-it: disable - provide the docker-machine plugin when docker-machine is enabled with the old location and name" { @@ -203,7 +203,7 @@ function __check_completion () { assert [ -L "$BASH_IT/plugins/enabled/docker-machine.plugin.bash" ] run __check_completion 'bash-it disable plugin docker' - assert_line "0" "docker-machine" + assert_line -n 0 "docker-machine" } @test "completion bash-it: disable - provide the docker-machine plugin when docker-machine is enabled with the old location and priority-based name" { @@ -214,7 +214,7 @@ function __check_completion () { assert [ -L "$BASH_IT/plugins/enabled/350---docker-machine.plugin.bash" ] run __check_completion 'bash-it disable plugin docker' - assert_line "0" "docker-machine" + assert_line -n 0 "docker-machine" } @test "completion bash-it: disable - provide the docker-machine plugin when docker-machine is enabled with the new location and priority-based name" { @@ -225,7 +225,7 @@ function __check_completion () { assert [ -L "$BASH_IT/enabled/350---docker-machine.plugin.bash" ] run __check_completion 'bash-it disable plugin docker' - assert_line "0" "docker-machine" + assert_line -n 0 "docker-machine" } @test "completion bash-it: disable - provide the todo.txt-cli aliases when todo plugin is enabled with the old location and name" { @@ -236,7 +236,7 @@ function __check_completion () { assert [ -L "$BASH_IT/plugins/enabled/todo.plugin.bash" ] run __check_completion 'bash-it disable alias to' - assert_line "0" "todo.txt-cli" + assert_line -n 0 "todo.txt-cli" } @test "completion bash-it: disable - provide the todo.txt-cli aliases when todo plugin is enabled with the old location and priority-based name" { @@ -247,7 +247,7 @@ function __check_completion () { assert [ -L "$BASH_IT/plugins/enabled/350---todo.plugin.bash" ] run __check_completion 'bash-it disable alias to' - assert_line "0" "todo.txt-cli" + assert_line -n 0 "todo.txt-cli" } @test "completion bash-it: disable - provide the todo.txt-cli aliases when todo plugin is enabled with the new location and priority-based name" { @@ -258,17 +258,17 @@ function __check_completion () { assert [ -L "$BASH_IT/enabled/350---todo.plugin.bash" ] run __check_completion 'bash-it disable alias to' - assert_line "0" "todo.txt-cli" + assert_line -n 0 "todo.txt-cli" } @test "completion bash-it: enable - provide the atom aliases when not enabled" { run __check_completion 'bash-it enable alias ato' - assert_line "0" "atom" + assert_line -n 0 "atom" } @test "completion bash-it: enable - provide the a* aliases when not enabled" { run __check_completion 'bash-it enable alias a' - assert_line "0" "all ag ansible apt atom" + assert_line -n 0 "all ag ansible apt atom" } @test "completion bash-it: enable - provide the a* aliases when atom is enabled with the old location and name" { @@ -276,7 +276,7 @@ function __check_completion () { assert [ -L "$BASH_IT/aliases/enabled/atom.aliases.bash" ] run __check_completion 'bash-it enable alias a' - assert_line "0" "all ag ansible apt" + assert_line -n 0 "all ag ansible apt" } @test "completion bash-it: enable - provide the a* aliases when atom is enabled with the old location and priority-based name" { @@ -284,7 +284,7 @@ function __check_completion () { assert [ -L "$BASH_IT/aliases/enabled/150---atom.aliases.bash" ] run __check_completion 'bash-it enable alias a' - assert_line "0" "all ag ansible apt" + assert_line -n 0 "all ag ansible apt" } @test "completion bash-it: enable - provide the a* aliases when atom is enabled with the new location and priority-based name" { @@ -292,7 +292,7 @@ function __check_completion () { assert [ -L "$BASH_IT/enabled/150---atom.aliases.bash" ] run __check_completion 'bash-it enable alias a' - assert_line "0" "all ag ansible apt" + assert_line -n 0 "all ag ansible apt" } @test "completion bash-it: enable - provide the docker-* plugins when nothing is enabled with the old location and name" { @@ -300,7 +300,7 @@ function __check_completion () { assert [ -L "$BASH_IT/aliases/enabled/docker-compose.aliases.bash" ] run __check_completion 'bash-it enable plugin docker' - assert_line "0" "docker-compose docker-machine docker" + assert_line -n 0 "docker-compose docker-machine docker" } @test "completion bash-it: enable - provide the docker-* plugins when nothing is enabled with the old location and priority-based name" { @@ -308,7 +308,7 @@ function __check_completion () { assert [ -L "$BASH_IT/aliases/enabled/150---docker-compose.aliases.bash" ] run __check_completion 'bash-it enable plugin docker' - assert_line "0" "docker-compose docker-machine docker" + assert_line -n 0 "docker-compose docker-machine docker" } @test "completion bash-it: enable - provide the docker-* plugins when nothing is enabled with the new location and priority-based name" { @@ -316,7 +316,7 @@ function __check_completion () { assert [ -L "$BASH_IT/enabled/150---docker-compose.aliases.bash" ] run __check_completion 'bash-it enable plugin docker' - assert_line "0" "docker-compose docker-machine docker" + assert_line -n 0 "docker-compose docker-machine docker" } @test "completion bash-it: enable - provide the docker-* completions when nothing is enabled with the old location and name" { @@ -324,7 +324,7 @@ function __check_completion () { assert [ -L "$BASH_IT/aliases/enabled/docker-compose.aliases.bash" ] run __check_completion 'bash-it enable completion docker' - assert_line "0" "docker docker-compose docker-machine" + assert_line -n 0 "docker docker-compose docker-machine" } @test "completion bash-it: enable - provide the docker-* completions when nothing is enabled with the old location and priority-based name" { @@ -332,7 +332,7 @@ function __check_completion () { assert [ -L "$BASH_IT/aliases/enabled/150---docker-compose.aliases.bash" ] run __check_completion 'bash-it enable completion docker' - assert_line "0" "docker docker-compose docker-machine" + assert_line -n 0 "docker docker-compose docker-machine" } @test "completion bash-it: enable - provide the docker-* completions when nothing is enabled with the new location and priority-based name" { @@ -340,7 +340,7 @@ function __check_completion () { assert [ -L "$BASH_IT/enabled/150---docker-compose.aliases.bash" ] run __check_completion 'bash-it enable completion docker' - assert_line "0" "docker docker-compose docker-machine" + assert_line -n 0 "docker docker-compose docker-machine" } @test "completion bash-it: enable - provide the todo.txt-cli aliases when todo plugin is enabled with the old location and name" { @@ -348,7 +348,7 @@ function __check_completion () { assert [ -L "$BASH_IT/plugins/enabled/todo.plugin.bash" ] run __check_completion 'bash-it enable alias to' - assert_line "0" "todo.txt-cli" + assert_line -n 0 "todo.txt-cli" } @test "completion bash-it: enable - provide the todo.txt-cli aliases when todo plugin is enabled with the old location and priority-based name" { @@ -356,7 +356,7 @@ function __check_completion () { assert [ -L "$BASH_IT/plugins/enabled/350---todo.plugin.bash" ] run __check_completion 'bash-it enable alias to' - assert_line "0" "todo.txt-cli" + assert_line -n 0 "todo.txt-cli" } @test "completion bash-it: enable - provide the todo.txt-cli aliases when todo plugin is enabled with the new location and priority-based name" { @@ -364,5 +364,5 @@ function __check_completion () { assert [ -L "$BASH_IT/enabled/350---todo.plugin.bash" ] run __check_completion 'bash-it enable alias to' - assert_line "0" "todo.txt-cli" + assert_line -n 0 "todo.txt-cli" } diff --git a/test/lib/helpers.bats b/test/lib/helpers.bats index 92fbf117..db956fc2 100644 --- a/test/lib/helpers.bats +++ b/test/lib/helpers.bats @@ -52,17 +52,17 @@ function local_setup { @test "helpers: bash-it help aliases ag" { run bash-it help aliases "ag" - assert_line "0" "ag='ag --smart-case --pager=\"less -MIRFX'" + assert_line -n 0 "ag='ag --smart-case --pager=\"less -MIRFX'" } @test "helpers: bash-it help aliases without any aliases enabled" { run bash-it help aliases - assert_line "0" "" + assert_line -n 0 "" } @test "helpers: bash-it help list aliases without any aliases enabled" { run _help-list-aliases "$BASH_IT/aliases/available/ag.aliases.bash" - assert_line "0" "ag:" + assert_line -n 0 "ag:" } @test "helpers: bash-it help list aliases with ag aliases enabled" { @@ -70,7 +70,7 @@ function local_setup { assert [ -L "$BASH_IT/aliases/enabled/150---ag.aliases.bash" ] run _help-list-aliases "$BASH_IT/aliases/enabled/150---ag.aliases.bash" - assert_line "0" "ag:" + assert_line -n 0 "ag:" } @test "helpers: bash-it help list aliases with todo.txt-cli aliases enabled" { @@ -78,7 +78,7 @@ function local_setup { assert [ -L "$BASH_IT/aliases/enabled/150---todo.txt-cli.aliases.bash" ] run _help-list-aliases "$BASH_IT/aliases/enabled/150---todo.txt-cli.aliases.bash" - assert_line "0" "todo.txt-cli:" + assert_line -n 0 "todo.txt-cli:" } @test "helpers: bash-it help list aliases with docker-compose aliases enabled" { @@ -86,7 +86,7 @@ function local_setup { assert [ -L "$BASH_IT/aliases/enabled/150---docker-compose.aliases.bash" ] run _help-list-aliases "$BASH_IT/aliases/enabled/150---docker-compose.aliases.bash" - assert_line "0" "docker-compose:" + assert_line -n 0 "docker-compose:" } @test "helpers: bash-it help list aliases with ag aliases enabled in global directory" { @@ -94,7 +94,7 @@ function local_setup { assert [ -L "$BASH_IT/enabled/150---ag.aliases.bash" ] run _help-list-aliases "$BASH_IT/enabled/150---ag.aliases.bash" - assert_line "0" "ag:" + assert_line -n 0 "ag:" } @test "helpers: bash-it help aliases one alias enabled in the old directory" { @@ -102,50 +102,50 @@ function local_setup { assert [ -L "$BASH_IT/aliases/enabled/150---ag.aliases.bash" ] run bash-it help aliases - assert_line "0" "ag:" + assert_line -n 0 "ag:" } @test "helpers: bash-it help aliases one alias enabled in global directory" { run bash-it enable alias "ag" - assert_line "0" 'ag enabled with priority 150.' + assert_line -n 0 'ag enabled with priority 150.' assert [ -L "$BASH_IT/enabled/150---ag.aliases.bash" ] run bash-it enable plugin "aws" - assert_line "0" 'aws enabled with priority 250.' + assert_line -n 0 'aws enabled with priority 250.' assert [ -L "$BASH_IT/enabled/250---aws.plugin.bash" ] run bash-it help aliases - assert_line "0" "ag:" - assert_line "1" "ag='ag --smart-case --pager=\"less -MIRFX'" + assert_line -n 0 "ag:" + assert_line -n 1 "ag='ag --smart-case --pager=\"less -MIRFX'" } @test "helpers: enable the todo.txt-cli aliases through the bash-it function" { run bash-it enable alias "todo.txt-cli" - assert_line "0" 'todo.txt-cli enabled with priority 150.' + assert_line -n 0 'todo.txt-cli enabled with priority 150.' assert [ -L "$BASH_IT/enabled/150---todo.txt-cli.aliases.bash" ] } @test "helpers: enable the curl aliases" { run _enable-alias "curl" - assert_line "0" 'curl enabled with priority 150.' + assert_line -n 0 'curl enabled with priority 150.' assert [ -L "$BASH_IT/enabled/150---curl.aliases.bash" ] } @test "helpers: enable the apm completion through the bash-it function" { run bash-it enable completion "apm" - assert_line "0" 'apm enabled with priority 350.' + assert_line -n 0 'apm enabled with priority 350.' assert [ -L "$BASH_IT/enabled/350---apm.completion.bash" ] } @test "helpers: enable the brew completion" { run _enable-completion "brew" - assert_line "0" 'brew enabled with priority 350.' + assert_line -n 0 'brew enabled with priority 350.' assert [ -L "$BASH_IT/enabled/350---brew.completion.bash" ] } @test "helpers: enable the node plugin" { run _enable-plugin "node" - assert_line "0" 'node enabled with priority 250.' + assert_line -n 0 'node enabled with priority 250.' assert [ -L "$BASH_IT/enabled/250---node.plugin.bash" ] assert_equal "../plugins/available/node.plugin.bash" "`readlink $BASH_IT/enabled/250---node.plugin.bash`" @@ -153,34 +153,34 @@ function local_setup { @test "helpers: enable the node plugin through the bash-it function" { run bash-it enable plugin "node" - assert_line "0" 'node enabled with priority 250.' + assert_line -n 0 'node enabled with priority 250.' assert [ -L "$BASH_IT/enabled/250---node.plugin.bash" ] } @test "helpers: enable the node and nvm plugins through the bash-it function" { run bash-it enable plugin "node" "nvm" - assert_line "0" 'node enabled with priority 250.' - assert_line "1" 'nvm enabled with priority 225.' + assert_line -n 0 'node enabled with priority 250.' + assert_line -n 1 'nvm enabled with priority 225.' assert [ -L "$BASH_IT/enabled/250---node.plugin.bash" ] assert [ -L "$BASH_IT/enabled/225---nvm.plugin.bash" ] } @test "helpers: enable the foo-unkown and nvm plugins through the bash-it function" { run bash-it enable plugin "foo-unknown" "nvm" - assert_line "0" 'sorry, foo-unknown does not appear to be an available plugin.' - assert_line "1" 'nvm enabled with priority 225.' + assert_line -n 0 'sorry, foo-unknown does not appear to be an available plugin.' + assert_line -n 1 'nvm enabled with priority 225.' assert [ -L "$BASH_IT/enabled/225---nvm.plugin.bash" ] } @test "helpers: enable the nvm plugin" { run _enable-plugin "nvm" - assert_line "0" 'nvm enabled with priority 225.' + assert_line -n 0 'nvm enabled with priority 225.' assert [ -L "$BASH_IT/enabled/225---nvm.plugin.bash" ] } @test "helpers: enable an unknown plugin" { run _enable-plugin "unknown-foo" - assert_line "0" 'sorry, unknown-foo does not appear to be an available plugin.' + assert_line -n 0 'sorry, unknown-foo does not appear to be an available plugin.' # Check for both old an new structure assert [ ! -L "$BASH_IT/plugins/enabled/250---unknown-foo.plugin.bash" ] @@ -193,7 +193,7 @@ function local_setup { @test "helpers: enable an unknown plugin through the bash-it function" { run bash-it enable plugin "unknown-foo" echo "${lines[@]}" - assert_line "0" 'sorry, unknown-foo does not appear to be an available plugin.' + assert_line -n 0 'sorry, unknown-foo does not appear to be an available plugin.' # Check for both old an new structure assert [ ! -L "$BASH_IT/plugins/enabled/250---unknown-foo.plugin.bash" ] @@ -205,17 +205,17 @@ function local_setup { @test "helpers: disable a plugin that is not enabled" { run _disable-plugin "sdkman" - assert_line "0" 'sorry, sdkman does not appear to be an enabled plugin.' + assert_line -n 0 'sorry, sdkman does not appear to be an enabled plugin.' } @test "helpers: enable and disable the nvm plugin" { run _enable-plugin "nvm" - assert_line "0" 'nvm enabled with priority 225.' + assert_line -n 0 'nvm enabled with priority 225.' assert [ -L "$BASH_IT/enabled/225---nvm.plugin.bash" ] assert [ ! -L "$BASH_IT/plugins/enabled/225---nvm.plugin.bash" ] run _disable-plugin "nvm" - assert_line "0" 'nvm disabled.' + assert_line -n 0 'nvm disabled.' assert [ ! -L "$BASH_IT/enabled/225---nvm.plugin.bash" ] } @@ -225,7 +225,7 @@ function local_setup { assert [ ! -L "$BASH_IT/enabled/225---nvm.plugin.bash" ] run _disable-plugin "nvm" - assert_line "0" 'nvm disabled.' + assert_line -n 0 'nvm disabled.' assert [ ! -L "$BASH_IT/plugins/enabled/225---nvm.plugin.bash" ] assert [ ! -L "$BASH_IT/enabled/225---nvm.plugin.bash" ] } @@ -235,7 +235,7 @@ function local_setup { assert [ -L "$BASH_IT/plugins/enabled/nvm.plugin.bash" ] run _disable-plugin "nvm" - assert_line "0" 'nvm disabled.' + assert_line -n 0 'nvm disabled.' assert [ ! -L "$BASH_IT/plugins/enabled/nvm.plugin.bash" ] } @@ -244,7 +244,7 @@ function local_setup { assert [ -L "$BASH_IT/plugins/enabled/nvm.plugin.bash" ] run _enable-plugin "nvm" - assert_line "0" 'nvm is already enabled.' + assert_line -n 0 'nvm is already enabled.' assert [ -L "$BASH_IT/plugins/enabled/nvm.plugin.bash" ] assert [ ! -L "$BASH_IT/plugins/enabled/225---nvm.plugin.bash" ] assert [ ! -L "$BASH_IT/enabled/225---nvm.plugin.bash" ] @@ -255,7 +255,7 @@ function local_setup { assert [ -L "$BASH_IT/plugins/enabled/225---nvm.plugin.bash" ] run _enable-plugin "nvm" - assert_line "0" 'nvm is already enabled.' + assert_line -n 0 'nvm is already enabled.' assert [ ! -L "$BASH_IT/plugins/enabled/nvm.plugin.bash" ] assert [ -L "$BASH_IT/plugins/enabled/225---nvm.plugin.bash" ] assert [ ! -L "$BASH_IT/enabled/225---nvm.plugin.bash" ] @@ -263,11 +263,11 @@ function local_setup { @test "helpers: enable the nvm plugin twice" { run _enable-plugin "nvm" - assert_line "0" 'nvm enabled with priority 225.' + assert_line -n 0 'nvm enabled with priority 225.' assert [ -L "$BASH_IT/enabled/225---nvm.plugin.bash" ] run _enable-plugin "nvm" - assert_line "0" 'nvm is already enabled.' + assert_line -n 0 'nvm is already enabled.' assert [ -L "$BASH_IT/enabled/225---nvm.plugin.bash" ] } @@ -279,13 +279,13 @@ function local_setup { assert [ -L "$BASH_IT/plugins/enabled/250---dirs.plugin.bash" ] run _bash-it-migrate - assert_line "0" 'Migrating plugin dirs.' - assert_line "1" 'dirs disabled.' - assert_line "2" 'dirs enabled with priority 250.' - assert_line "3" 'Migrating completion dirs.' - assert_line "4" 'dirs disabled.' - assert_line "5" 'dirs enabled with priority 350.' - assert_line "6" 'If any migration errors were reported, please try the following: reload && bash-it migrate' + assert_line -n 0 'Migrating plugin dirs.' + assert_line -n 1 'dirs disabled.' + assert_line -n 2 'dirs enabled with priority 250.' + assert_line -n 3 'Migrating completion dirs.' + assert_line -n 4 'dirs disabled.' + assert_line -n 5 'dirs enabled with priority 350.' + assert_line -n 6 'If any migration errors were reported, please try the following: reload && bash-it migrate' assert [ -L "$BASH_IT/enabled/350---dirs.completion.bash" ] assert [ -L "$BASH_IT/enabled/250---dirs.plugin.bash" ] @@ -307,9 +307,9 @@ function local_setup { assert [ -L "$BASH_IT/enabled/250---ssh.plugin.bash" ] run _bash-it-migrate - assert_line "0" 'Migrating alias todo.txt-cli.' - assert_line "1" 'todo.txt-cli disabled.' - assert_line "2" 'todo.txt-cli enabled with priority 150.' + assert_line -n 0 'Migrating alias todo.txt-cli.' + assert_line -n 1 'todo.txt-cli disabled.' + assert_line -n 2 'todo.txt-cli enabled with priority 150.' assert [ -L "$BASH_IT/enabled/225---nvm.plugin.bash" ] assert [ -L "$BASH_IT/enabled/250---node.plugin.bash" ] @@ -433,11 +433,11 @@ function __migrate_all_components() { assert [ -L "$BASH_IT/plugins/enabled/nvm.plugin.bash" ] run bash-it enable plugin "node" - assert_line "0" 'Migrating plugin nvm.' - assert_line "1" 'nvm disabled.' - assert_line "2" 'nvm enabled with priority 225.' - assert_line "3" 'If any migration errors were reported, please try the following: reload && bash-it migrate' - assert_line "4" 'node enabled with priority 250.' + assert_line -n 0 'Migrating plugin nvm.' + assert_line -n 1 'nvm disabled.' + assert_line -n 2 'nvm enabled with priority 225.' + assert_line -n 3 'If any migration errors were reported, please try the following: reload && bash-it migrate' + assert_line -n 4 'node enabled with priority 250.' assert [ ! -L "$BASH_IT/plugins/enabled/nvm.plugin.bash" ] assert [ -L "$BASH_IT/enabled/225---nvm.plugin.bash" ] assert [ -L "$BASH_IT/enabled/250---node.plugin.bash" ] @@ -450,14 +450,14 @@ function __migrate_all_components() { assert [ -L "$BASH_IT/plugins/enabled/250---node.plugin.bash" ] run bash-it disable plugin "node" - assert_line "0" 'Migrating plugin node.' - assert_line "1" 'node disabled.' - assert_line "2" 'node enabled with priority 250.' - assert_line "3" 'Migrating plugin nvm.' - assert_line "4" 'nvm disabled.' - assert_line "5" 'nvm enabled with priority 225.' - assert_line "6" 'If any migration errors were reported, please try the following: reload && bash-it migrate' - assert_line "7" 'node disabled.' + assert_line -n 0 'Migrating plugin node.' + assert_line -n 1 'node disabled.' + assert_line -n 2 'node enabled with priority 250.' + assert_line -n 3 'Migrating plugin nvm.' + assert_line -n 4 'nvm disabled.' + assert_line -n 5 'nvm enabled with priority 225.' + assert_line -n 6 'If any migration errors were reported, please try the following: reload && bash-it migrate' + assert_line -n 7 'node disabled.' assert [ ! -L "$BASH_IT/plugins/enabled/nvm.plugin.bash" ] assert [ -L "$BASH_IT/enabled/225---nvm.plugin.bash" ] assert [ ! -L "$BASH_IT/plugins/enabled/250---node.plugin.bash" ] @@ -539,7 +539,7 @@ function __migrate_all_components() { @test "helpers: enable the ansible aliases through the bash-it function" { run bash-it enable alias "ansible" - assert_line "0" 'ansible enabled with priority 150.' + assert_line -n 0 'ansible enabled with priority 150.' assert [ -L "$BASH_IT/enabled/150---ansible.aliases.bash" ] } @@ -549,7 +549,7 @@ function __migrate_all_components() { @test "helpers: describe the nvm plugin after enabling it" { run _enable-plugin "nvm" - assert_line "0" 'nvm enabled with priority 225.' + assert_line -n 0 'nvm enabled with priority 225.' assert [ -L "$BASH_IT/enabled/225---nvm.plugin.bash" ] _bash-it-plugins | grep "nvm" | grep "\[x\]" diff --git a/test/lib/search.bats b/test/lib/search.bats index 0993d0b1..1043c1a4 100644 --- a/test/lib/search.bats +++ b/test/lib/search.bats @@ -54,15 +54,15 @@ function local_setup { run _bash-it-search 'ruby' 'gem' 'bundle' 'rake' 'rails' '--disable' run _enable-alias 'rails' run _bash-it-search 'ruby' 'gem' 'bundle' 'rake' 'rails' - assert_line "0" ' aliases => bundler ✓rails' - assert_line "1" ' plugins => chruby chruby-auto rails ruby' - assert_line "2" ' completions => bundler gem rake' + assert_line -n 0 ' aliases => bundler ✓rails' + assert_line -n 1 ' plugins => chruby chruby-auto rails ruby' + assert_line -n 2 ' completions => bundler gem rake' } @test "search: (all enabled) ruby gem bundle rake rails" { run _bash-it-search 'ruby' 'gem' 'bundle' 'rake' '-chruby' 'rails' '--enable' run _bash-it-search 'ruby' 'gem' 'bundle' 'rake' '-chruby' 'rails' - assert_line "0" ' aliases => ✓bundler ✓rails' - assert_line "1" ' plugins => ✓rails ✓ruby' - assert_line "2" ' completions => ✓bundler ✓gem ✓rake' + assert_line -n 0 ' aliases => ✓bundler ✓rails' + assert_line -n 1 ' plugins => ✓rails ✓ruby' + assert_line -n 2 ' completions => ✓bundler ✓gem ✓rake' } diff --git a/test/plugins/ruby.plugin.bats b/test/plugins/ruby.plugin.bats index 87c971b2..ab11bda1 100755 --- a/test/plugins/ruby.plugin.bats +++ b/test/plugins/ruby.plugin.bats @@ -33,7 +33,7 @@ function local_teardown { @test "plugins ruby: remove_gem is defined" { run type remove_gem - assert_line 1 "remove_gem () " + assert_line -n 1 "remove_gem () " } @test "plugins ruby: PATH includes ~/.gem/ruby/bin" { diff --git a/test/run b/test/run index 7bbbb511..f6e57d45 100755 --- a/test/run +++ b/test/run @@ -3,13 +3,10 @@ test_directory="$(cd "$(dirname "$0")" && pwd)" #bats_executable="${test_directory}/../bats/bin/bats" bats_executable="${test_directory}/../test_lib/bats-core/bin/bats" -[ ! -e $bats_executable ] && \ - git submodule init && git submodule update +git submodule init && git submodule update if [ -z "${BASH_IT}" ]; then export BASH_IT=$(cd ${test_directory} && dirname $(pwd)) fi -echo "Bats: $bats_executable" - exec $bats_executable ${CI:+--tap} ${test_directory}/{bash_it,completion,install,lib,plugins,themes} diff --git a/test/test_helper.bash b/test/test_helper.bash index 08638b54..fa9ed2e8 100644 --- a/test/test_helper.bash +++ b/test/test_helper.bash @@ -13,6 +13,12 @@ if [ "$BASH_IT_ROOT" != "${BASH_IT_TEST_DIR}/root" ]; then export BASH_IT=$BASH_IT_TEST_DIR fi +export TEST_MAIN_DIR="${BATS_TEST_DIRNAME}/.." +export TEST_DEPS_DIR="${TEST_DEPS_DIR-${TEST_MAIN_DIR}/../test_lib}" + +load "${TEST_DEPS_DIR}/bats-support/load.bash" +load "${TEST_DEPS_DIR}/bats-assert/load.bash" + local_setup() { true } @@ -32,77 +38,3 @@ teardown() { rm -rf "${BASH_IT_TEST_DIR}" } - -assert() { - if ! "$@"; then - flunk "failed: $@" - fi -} - -flunk() { - { if [ "$#" -eq 0 ]; then cat - - else echo "$@" - fi - } | sed "s:${BASH_IT_TEST_DIR}:TEST_DIR:g" >&2 - return 1 -} - -assert_success() { - if [ "$status" -ne 0 ]; then - flunk "command failed with exit status $status" - elif [ "$#" -gt 0 ]; then - assert_output "$1" - fi -} - -assert_failure() { - if [ "$status" -eq 0 ]; then - flunk "expected failed exit status" - elif [ "$#" -gt 0 ]; then - assert_output "$1" - fi -} - -assert_equal() { - if [ "$1" != "$2" ]; then - { echo "expected: $1" - echo "actual: $2" - } | flunk - fi -} - -assert_output() { - local expected - if [ $# -eq 0 ]; then expected="$(cat -)" - else expected="$1" - fi - assert_equal "$expected" "$output" -} - -assert_line() { - if [ "$1" -ge 0 ] 2>/dev/null; then - assert_equal "$2" "${lines[$1]}" - else - local line - for line in "${lines[@]}"; do - if [ "$line" = "$1" ]; then return 0; fi - done - flunk "expected line \`$1'" - fi -} - -refute_line() { - if [ "$1" -ge 0 ] 2>/dev/null; then - local num_lines="${#lines[@]}" - if [ "$1" -lt "$num_lines" ]; then - flunk "output has $num_lines lines" - fi - else - local line - for line in "${lines[@]}"; do - if [ "$line" = "$1" ]; then - flunk "expected to not find line \`$line'" - fi - done - fi -} diff --git a/test/themes/base.theme.bats b/test/themes/base.theme.bats index ab320c81..2cf809dc 100644 --- a/test/themes/base.theme.bats +++ b/test/themes/base.theme.bats @@ -26,7 +26,7 @@ load ../../themes/base.theme run battery_char assert_success - assert_line "0" "" + assert_line -n 0 "" run type -a battery_char assert_line " echo -n" @@ -53,7 +53,7 @@ load ../../themes/base.theme run battery_charge assert_success - assert_line "0" "" + assert_line -n 0 "" } @test 'themes base: battery_charge should exist if battery plugin loaded' {