From da6b27166f44e3ba2566a668d81d2a99d80c3845 Mon Sep 17 00:00:00 2001 From: John D Pell Date: Thu, 21 Oct 2021 02:52:26 -0400 Subject: [PATCH] tests: new file `test_helper_libs.bash` For testing non-core files, just `load ../test_helper_libs` after `load ../test_helper` instead of trying to guess which libs must be loaded, in which order, for testing to succeed. `_command_exists` spews log messages, so our test log is littered with `_log_debug not found`. This fixes that too. --- clean_files.txt | 1 + test/lib/helpers.bats | 6 +----- test/lib/search.bats | 5 +---- test/lib/utilities.bats | 5 +---- test/plugins/alias-completion.plugin.bats | 3 +-- test/plugins/base.plugin.bats | 3 +-- test/plugins/battery.plugin.bats | 3 +-- test/plugins/cmd-returned-notify.plugin.bats | 2 +- test/plugins/go.plugin.bats | 2 +- test/plugins/ruby.plugin.bats | 2 +- test/plugins/xterm.plugin.bats | 3 +-- test/test_helper_libs.bash | 6 ++++++ test/themes/base.theme.bats | 4 +--- test/themes/base.theme.git.bats | 4 +--- test/themes/base.theme.svn.bats | 4 +--- 15 files changed, 20 insertions(+), 33 deletions(-) create mode 100644 test/test_helper_libs.bash diff --git a/clean_files.txt b/clean_files.txt index 4ecda787..242d7327 100644 --- a/clean_files.txt +++ b/clean_files.txt @@ -123,6 +123,7 @@ plugins/available/zoxide.plugin.bash # test/plugins/alias-completion.plugin.bats test/test_helper.bash +test/test_helper_libs.bash # themes # diff --git a/test/lib/helpers.bats b/test/lib/helpers.bats index ea7bc68e..4df36277 100644 --- a/test/lib/helpers.bats +++ b/test/lib/helpers.bats @@ -1,11 +1,7 @@ #!/usr/bin/env bats load ../test_helper -load ../../lib/log -load ../../lib/utilities -load ../../lib/search - -load ../../lib/helpers +load ../test_helper_libs load ../../plugins/available/base.plugin function local_setup { diff --git a/test/lib/search.bats b/test/lib/search.bats index 6a54a62d..c8a95027 100644 --- a/test/lib/search.bats +++ b/test/lib/search.bats @@ -1,10 +1,7 @@ #!/usr/bin/env bats load ../test_helper -load ../../lib/log -load ../../lib/helpers -load ../../lib/utilities -load ../../lib/search +load ../test_helper_libs load ../../plugins/available/base.plugin load ../../aliases/available/git.aliases diff --git a/test/lib/utilities.bats b/test/lib/utilities.bats index 9554a2db..67e6a640 100644 --- a/test/lib/utilities.bats +++ b/test/lib/utilities.bats @@ -1,10 +1,7 @@ #!/usr/bin/env bats load ../test_helper -load ../../lib/log -load ../../lib/helpers -load ../../lib/utilities -load ../../lib/search +load ../test_helper_libs function local_setup { setup_test_fixture diff --git a/test/plugins/alias-completion.plugin.bats b/test/plugins/alias-completion.plugin.bats index b0ad2659..20d13cf2 100644 --- a/test/plugins/alias-completion.plugin.bats +++ b/test/plugins/alias-completion.plugin.bats @@ -1,8 +1,7 @@ #!/usr/bin/env bats load ../test_helper -load ../../lib/log -load ../../lib/helpers +load ../test_helper_libs load ../../completion/available/capistrano.completion diff --git a/test/plugins/base.plugin.bats b/test/plugins/base.plugin.bats index 2f1cd327..05081a8a 100644 --- a/test/plugins/base.plugin.bats +++ b/test/plugins/base.plugin.bats @@ -1,8 +1,7 @@ #!/usr/bin/env bats load ../test_helper -load ../../lib/log -load ../../lib/helpers +load ../test_helper_libs load ../../plugins/available/base.plugin @test 'plugins base: ips()' { diff --git a/test/plugins/battery.plugin.bats b/test/plugins/battery.plugin.bats index b7ea5e8a..eac6d021 100644 --- a/test/plugins/battery.plugin.bats +++ b/test/plugins/battery.plugin.bats @@ -1,8 +1,7 @@ #!/usr/bin/env bats load ../test_helper -load "${BASH_IT}/lib/log.bash" -load "${BASH_IT}/lib/helpers.bash" +load ../test_helper_libs load ../../plugins/available/battery.plugin diff --git a/test/plugins/cmd-returned-notify.plugin.bats b/test/plugins/cmd-returned-notify.plugin.bats index 8e14f565..daf58330 100644 --- a/test/plugins/cmd-returned-notify.plugin.bats +++ b/test/plugins/cmd-returned-notify.plugin.bats @@ -1,7 +1,7 @@ #!/usr/bin/env bats load ../test_helper -load ../../lib/helpers +load ../test_helper_libs load ../../vendor/init.d/preexec load ../../plugins/available/cmd-returned-notify.plugin diff --git a/test/plugins/go.plugin.bats b/test/plugins/go.plugin.bats index f421bbf7..4021e643 100644 --- a/test/plugins/go.plugin.bats +++ b/test/plugins/go.plugin.bats @@ -1,7 +1,7 @@ #!/usr/bin/env bats load ../test_helper -load ../../lib/helpers +load ../test_helper_libs # We test `go version` in each test to account for users with goenv and no system go. diff --git a/test/plugins/ruby.plugin.bats b/test/plugins/ruby.plugin.bats index 6a3d7893..dc8a3e85 100644 --- a/test/plugins/ruby.plugin.bats +++ b/test/plugins/ruby.plugin.bats @@ -1,7 +1,7 @@ #!/usr/bin/env bats load ../test_helper -load ../../lib/helpers +load ../test_helper_libs function local_setup { setup_test_fixture diff --git a/test/plugins/xterm.plugin.bats b/test/plugins/xterm.plugin.bats index 0a4eb859..c175d854 100644 --- a/test/plugins/xterm.plugin.bats +++ b/test/plugins/xterm.plugin.bats @@ -1,8 +1,7 @@ #!/usr/bin/env bats load ../test_helper -load ../../lib/log -load ../../lib/helpers +load ../test_helper_libs load ../../plugins/available/xterm.plugin diff --git a/test/test_helper_libs.bash b/test/test_helper_libs.bash new file mode 100644 index 00000000..57115e7e --- /dev/null +++ b/test/test_helper_libs.bash @@ -0,0 +1,6 @@ +# shellcheck shell=bash + +load "${BASH_IT}/lib/log.bash" +load "${BASH_IT}/lib/utilities.bash" +load "${BASH_IT}/lib/helpers.bash" +load "${BASH_IT}/lib/search.bash" diff --git a/test/themes/base.theme.bats b/test/themes/base.theme.bats index a7067b83..1730f7ad 100644 --- a/test/themes/base.theme.bats +++ b/test/themes/base.theme.bats @@ -1,9 +1,7 @@ #!/usr/bin/env bats load ../test_helper -load ../../lib/log - -load ../../lib/helpers +load ../test_helper_libs load ../../themes/base.theme @test 'themes base: battery_percentage should not exist' { diff --git a/test/themes/base.theme.git.bats b/test/themes/base.theme.git.bats index bc354867..ad2c5a8d 100644 --- a/test/themes/base.theme.git.bats +++ b/test/themes/base.theme.git.bats @@ -1,9 +1,7 @@ #!/usr/bin/env bats load ../test_helper -load ../../lib/log - -load ../../lib/helpers +load ../test_helper_libs load ../../themes/githelpers.theme load ../../themes/base.theme diff --git a/test/themes/base.theme.svn.bats b/test/themes/base.theme.svn.bats index e8b4cb13..789d85e5 100644 --- a/test/themes/base.theme.svn.bats +++ b/test/themes/base.theme.svn.bats @@ -1,9 +1,7 @@ #!/usr/bin/env bats load ../test_helper -load ../../lib/log - -load ../../lib/helpers +load ../test_helper_libs function local_setup { setup_test_fixture