Commit Graph

275 Commits (076afcd3295900555da5d12385fb8cde7a595936)

Author SHA1 Message Date
John D Pell 9291b46b15 test_lib: update BATS to latest tag(s)
And fix any failing tests.
2022-01-10 00:27:39 -08:00
Noah Gorny f2bff34493
Merge pull request #2013 from gaelicWizard/completion/system
completion/system: load earlier than others
2022-01-09 01:13:23 +02:00
John D Pell 04c7424de5 completion/system: fix tests for `profile` command 2022-01-08 08:33:16 -08:00
John D Pell e7c3263f12 completion/system: load earlier than other completions
I chose `325` so that it's still possible to deliberately place something *before* this component, if needed somehow.
2022-01-08 08:33:16 -08:00
John D Pell 8a226a73f1 test/test-helper: support 'plumbing' metadata 2022-01-08 08:29:13 -08:00
John D Pell 30ca1bfba2 test/test_helper: exclude bad symlink
Symlink `/test_lib/bats-core/test/fixtures/parallel/suite/helper.bash` references a not-existing file, but it's in a submodule so I can't just fix it. Exclude it from `rsync` in `setup_test_fixture()`.
2022-01-08 08:29:13 -08:00
John D Pell 97ef5a8087 test/run: lint 2022-01-08 08:29:13 -08:00
John D Pell 61e1d6aec2 lib/utilities: simplify test flow
This subshell is...wut
2022-01-08 08:29:13 -08:00
John D Pell c35ed44cbf plugins/ruby: tests on Mac OS X
Test was failing only on Mac OS X for some reason, so refactor a little. It turned out to be due to explicitly setting `$HOME` *after* loading the plugin.
2022-01-08 08:29:13 -08:00
John D Pell 21a2198a12 test/theme: make fewer assumptions
Literally copying a line from the source to be tested is perhaps not the best way to test that code. 😉

That said, we do want to verify that the function was actually loaded.

TODO: actually test the function.
2022-01-08 08:29:13 -08:00
John D Pell 6030767b4e test/theme: load colors 2022-01-08 08:29:13 -08:00
John D Pell da6b27166f 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.
2022-01-08 08:29:13 -08:00
John D Pell 9dcbeec7ad tests: test_helper already loads `composure.sh`
...and `cite()`s metadata
2022-01-08 08:29:13 -08:00
John D Pell b2279b7237 tests: quote paths 2022-01-08 08:29:13 -08:00
Noah Gorny 5d68fca7e5
Merge pull request #2008 from gaelicWizard/plugin-osx
Plugin/OSX: cleanup
2022-01-07 08:41:17 +02:00
Noah Gorny c81c9dcc8c
Merge pull request #1865 from NoahGorny/add-profile-subcommand
add profile subcommand
2022-01-03 14:00:39 +02:00
John D Pell 4abafc55ef tests: quote paths 2022-01-01 17:46:11 -08:00
cornfeedhobo b7feb14404
skip go tests when go is not available 2021-09-29 18:16:52 -05:00
Noah Gorny cd38f32d95 test: Fix completion tests and add profile completion ones 2021-09-29 00:30:24 +03:00
Noah Gorny 4c4b138671 tests: Add more bash-it profile tests 2021-09-29 00:30:24 +03:00
Noah Gorny b2ee5f96a5 test: helpers: Add profile command tests 2021-09-29 00:30:24 +03:00
John D Pell c2c76a380a
plugin/base: improvements (#1930)
* plugins/base: code style improvements

Quote variables, use $@ and $array[@] instead of $*, typeset some integers, remove unneccesasary binary invocation, use shell features when possible, remove `eval`, &c.

* plugins/base: conditional function definitions

Instead of functions failing when required tools aren't installed, just don't define the function.
Alsö, don't redefine del() if it already exists.

* plugins/base: rewrite `usage()`

Reimplement disk usage function using Bash syntax and simpler layout, without having to invoke an external binary.

* plugins/base: revamp `quiet()`

New implementation that is even quieter.

* plugins/base: `myip()`

* plugins/base: `pickfrom()`

* plugins/base: `passgen()`

Fix `passgen()` to not need `tr`, remove one subshell, and eliminate a useless `echo`.

* plugins/base: `mkcd()`

* plugins/base: `mkiso()`

* plugins/base: remove `banish-cookies()`

Adobe Flash is gone with the wind. Alsö, this would be something someone would do *once* and shouldn't be a function...

* plugins/base: `lsgrep` is SC2010

The `lsgrep()` function is *itself* explicitly forbidden by `shellcheck` rule SC2010.

Alsö, s/`$*`/`$@`

* plugins/base: `mkiso()`

Expressly handle unbound parameters.

* plugins/base: remove `command_exists`

* plugin/base: lint SC2154 && SC2144

Newly undisabled `shellcheck` rules

* plugin/base: import libs for tests

* plugin/base: `shfmt`

Apply `shfmt` using current project settings. My apologies to future `git blame` hunters. ♥
2021-09-28 15:13:27 +03:00
John D Pell 8d1e802565 test: Use `${PWD}` instead of `$(pwd)` 2021-09-18 13:15:13 -07:00
John D Pell 476fcb4325 lib/theme: new `_bash_it_appearance_scm_init()`
Wrap init code in a function and call the function immediately. Several plugins do this, and it allows us to more easily implement a hooks-based system in the future.

Alsö, avoid external binary `which`. Use built-in `type -P` instead. Uppercase `-P` forces a path search to avoid hashed matches and functions/aliases and whatnot.
2021-09-11 10:22:17 -07:00
John D Pell 8c0860588d themes/base: don't invoke svn if possible
If we are specifically in the situation #1612, then check for a working `svn` command. If we're not in that situation, then don't waste time on it.
2021-09-11 00:02:27 -07:00
John D Pell 3654198deb Tests for 'default' prefix 2021-08-26 14:11:41 -07:00
Noah Gorny 02f6654841 test: Add bash-it help plugins test 2021-03-21 22:07:24 +02:00
Noah Gorny 1fbd91ebf9
Merge pull request #1824 from cornfeedhobo/goenv-go
Ensure goenv and go play together well
2021-02-06 00:14:07 +02:00
cornfeedhobo e690f21e4e
Ensure goenv and go play together well
This PR seeks to address several issues surrounding the go and goenv plugins.
The nature of goenv allows for a situation where the initial shell does not
point to a working go binary, and instead at the included shim script. The
result is that one must run reload after moving to a project directory with a
version file, however in doing so, PATH is updated, requiring they exit the
shell or risk lookup collisions and unexpected behavior.

This is solved by using preexec to check the version before changing
directories and restarting the shell if the version has changed. The exec
pattern is copied from _bash-it-restart, but is edited to support this specific
use case.

Additionally, tests have been uploaded and these are now being linted.
2021-02-04 23:51:17 -06:00
buhl 49d7d2e8c4 Getting Bash-it to use the vendored composure
Fixed tests
Fixed install.sh and bash_it.sh
Added gitattributes to the vendor folder
Changed documentation
2021-02-02 16:34:04 +01:00
Noah Gorny 0d0fde9904
Merge pull request #1813 from NoahGorny/improve-test-helper
test: helper: cite plumbing metadata
2021-01-28 16:08:03 +02:00
Noah Gorny 49cf84c4fe test: helper: cite plumbing metadata 2021-01-23 23:04:29 +02:00
Noah Gorny 6b3788051f test: plugin: xterm: Use correct _command_exists invocation 2021-01-23 23:03:41 +02:00
buhl 29855ed1e6 Adding preexec as a vendored library
Added a vendored lib loading routine in bash-it.sh
Added documentation on how to vendor libs in bash-it
Added and fixed plugins using preexec
Added tests for two plugins
Removed the old preexec lib
2021-01-23 18:31:18 +01:00
Noah Gorny b19c2b969f test: Change alias-completion completion file to capistrano 2020-12-27 17:12:22 +02:00
Noah Gorny f5753e4416 test: Add test for aliases rm for alias_completion 2020-12-14 01:21:00 +02:00
egvimo 3019dc331d
Add option to append template to existing config (#1723)
* Add option to append template to existing config

* Add test for append-to-config option

Co-authored-by: Egor Moor <egor.moor@edag-ps.com>
2020-12-11 16:32:23 +02:00
Noah Gorny 864970bcd2 docs: Transition md files to support new rtd format 2020-11-06 19:16:56 +02:00
Noah Gorny b14a38fec9 ci: Add pre-commit run and remove trailling spaces 2020-10-28 11:51:04 +02:00
Noah Gorny 3838f12498 Add tests for _binary_exists 2020-10-21 11:02:55 +03:00
Noah Gorny c387517122
Merge pull request #1626 from NoahGorny/update-to-stable-or-unstable
bash-it update to stable or dev
2020-10-16 14:16:06 +03:00
Noah Gorny fc17169b1c test: Add completion test for -s --silent flag 2020-10-13 14:42:02 +03:00
Noah Gorny 1bdcacf242 completion: Update completion for new bash-it update
Also fix the update completion test
2020-10-13 14:42:02 +03:00
Noah Gorny f4279e63c1 Add bash-it restart command
Also add completion and completion tests
2020-10-12 15:29:36 +03:00
Travis Swicegood ac3957393e Update tests so github-cli is expected 2020-10-10 02:39:02 +03:00
Ahmad Assaf 95b60098cd
Update helpers.bats
Fix the `assert_success` by adding the required `run`
2020-09-24 05:20:04 -07:00
cornfeedhobo f40bfa80f1
system completion nitpicks
- General cleanup of system completion
- Use homebrew's completion loading script instead
- Deprecate completions covered by system
- Adjust load priority of brew to happen after system
2020-09-21 09:07:09 -05:00
Nils Winkler 03e9124edb
Fixed test execution 2020-08-05 10:36:29 +02:00
Nils Winkler 2f91e95af6
Adding log library to search tests
This might help with #1635.
2020-08-04 10:58:25 +02:00
Nils Winkler 43ef48544d
Merge pull request #1627 from NoahGorny/fix-alias-completion-plugin
plugins: Fix quotes around prec_word agruments
2020-07-15 08:54:56 +02:00
Noah Gorny 72dbfd2480 lib: log: Insert log level before message prefix
Also fix tests accordinly
2020-07-02 21:11:40 +03:00
Noah Gorny 3069af37e0 tests: Include lib log 2020-07-02 21:11:40 +03:00
Noah Gorny e6ebcda608 log: Fix logging to comply with the tests 2020-07-02 21:11:40 +03:00
Noah Gorny 0053f27820 test: Add alias-completion plugin test 2020-06-28 11:37:08 +03:00
Noah Gorny 9a23725ce0 log: Add BASH_IT_LOG_PREFIX option
Also add a new test to check it
2020-06-25 00:16:16 +03:00
Noah Gorny 5263f5ac59 test: Add lib log basic testing 2020-06-23 15:59:14 +03:00
Noah Gorny 1e674643b3 completion: Add bash-it doctor completion
Also fix the tests and add a new one
2020-06-23 15:12:43 +03:00
Noah Gorny 3eac73f613 plugins: Rename gitstatusd plugin to gitstatus 2020-06-22 14:57:05 +03:00
Noah Gorny 4f4bae95e4 tests: Fix search git test 2020-06-22 14:56:13 +03:00
Nils Winkler 107cfe5daf
Fixed comparison for SVN info parameter
Based on @arturmartins comment in #1615 - thanks!
2020-06-17 10:26:47 +02:00
Nils Winkler 3cffa35092
Fixed some more comments 2020-06-16 16:59:29 +02:00
Nils Winkler c02638e946
Fixed comment 2020-06-16 16:58:29 +02:00
Nils Winkler 5aa525caae
Refactored setup/teardown 2020-06-16 09:25:07 +02:00
Nils Winkler f933a86ff0
Added tests for additional SVN scenarios 2020-06-16 09:24:24 +02:00
Nils Winkler 47f6682292
Added test case for base theme SVN functionality
Unit tests for #1612, #1613.
2020-06-15 17:09:44 +02:00
Alex Thiessen 9f3889c284
test: Make `rsync` optional
For bulk copying, `rsync` is used in test code, which is rather fast and
capable of saving needless write operations. The downside is that tests
fail when the tool is missing, which is the case with most minimal Linux
setups (e.g. containers or even Gnome installations of Debian).

Provide an alternative way for sufficiently fast copying by means of
`find -exec cp`. Measured total test time penalty is less than 0.5%.
Downside of needless write operations remains in case of fallback.
2020-05-11 02:30:10 +02:00
Nils Winkler 62bf3bf097
Fix search plugin tests
Had to move the `cite` definition up a couple of lines, since `_about`
is used in some of the tested plugins

Fixes #1582
2020-05-02 14:19:15 +02:00
Nils Winkler cbe2986210
Updated test readme 2020-04-22 11:19:18 +02:00
Nils Winkler e9467825ec
Removed assert_link_exist function
This is now provided by the used version of bats-file.
2020-04-22 11:16:10 +02:00
Nils Winkler 543e49b759
Updated GNU parallel detection
Thanks to @rico-chet for the detection code!
2020-04-21 08:25:40 +02:00
Nils Winkler 9269c4445d
Went back to the bats-file temp_make function
Switching to tralston/bats-file allowed to use temp_make on macOS.
2020-04-21 08:25:40 +02:00
Nils Winkler eb6469096a
Added the parallel test execution code from @rico-chet
See here: cd4a039215/test/run (L22)
2020-04-21 08:25:40 +02:00
Nils Winkler bc433cd999
Fixing the mktemp function on Linux 2020-04-21 08:25:40 +02:00
Nils Winkler 818a95d79c
Refactored test setup code
Removed the copy/paste code, moved it into a reusable function that can
be called from the `local_setup` function as needed. Also simplified the
handling of the $HOME variable since @rico-chet provided a better way of
doing this.
2020-04-21 08:25:40 +02:00
Nils Winkler 34993f5da3
Excluding enabled directory when setting up test fixtures 2020-04-21 08:25:40 +02:00
Nils Winkler 3093273425
Updated rsync command to work with latest version of bats-core 2020-04-21 08:25:39 +02:00
Nils Winkler f698261487
Updated to https://github.com/tralston/bats-file v0.3.0 2020-04-20 09:00:52 +02:00
Alex Thiessen c003f0f342
test/plugins/go: Skip tests in absence of `go`
In case `go` is not installed, tests of the according plugin fail. It's
better to just skip them since `golang` isn't commonly installed on
`bash-it` developers' machines.

In CI environment, no tests should be skipped, so run them anyway.
2020-04-10 00:03:39 +00:00
Alex Thiessen 3d45f01728
test/test_helper: Don't use system/user `git` config
Git uses system-wide and user-wide configurations per default and these
can interfere with our tests. Keep `git` from using them by setting the
according environment variables.

This might also help with other tools which access user's home
directory.
2020-04-08 14:31:33 +02:00
Alex Thiessen 668306cae7
test/plugins/base: Run `myip` test
Test of `myip` was skipped, allegedly for it being slow. It's fast for
me (~400 ms), so enable it unconditionally.
2020-04-08 12:56:04 +02:00
John McBride 036c26dbed Update jump plugin
- remove z plugin
- remove fasd plugin
- update test that referenced fsad

Signed-off-by: John McBride <jpmmcbride@gmail.com>
2020-02-03 11:43:24 -07:00
cornfeedhobo 377f02714d Simplify multiple path support in go plugin (#1284)
* simplify wrapped pathmunge logic. update tests to account for cases with spaces in $PATH.
2019-11-20 08:49:34 +01:00
Nils Winkler 721412aa4c
Merge pull request #1395 from zhao-li/toggle-able_commit_count
Toggle able commit count
2019-09-02 08:45:19 +02:00
Zhao Li 83be21ebb3 update tests to set flag appropriately 2019-07-08 13:33:14 -10:00
Zhao Li 49d8c8750a fix broken tests 2019-07-08 13:28:32 -10:00
Nils Winkler 792593c995
Merge pull request #1273 from kigster/kig/search/improved
Speed up bash-it Search & support exact matches
2019-01-14 09:05:02 +01:00
cornfeedhobo 1030c0e9e1
one more test ... why not 2018-12-06 17:11:13 -05:00
cornfeedhobo 3645305644
add go plugin tests and update list reversal logic 2018-12-06 17:07:03 -05:00
Konstantin Gredeskoul 09c2be9d6b Refactor (extract utilities + add tests) & more…
* Extracting common utilities into utilities.bash
 * Adding new tests for utilities
 * Relocating the cache file to be under $BASH_IT
 * Removing cache cleanup deferral code for now
 * Wiping the cache in local_setup in tests.
2018-11-23 16:40:35 -08:00
Konstantin Gredeskoul baae0305b6 Speed up bash-it Search & support exact matches
This commit improves Bash-It search functionality in a couple of ways:

 * bash-it search (with no arguments) will print detailed help.
 * bash-it search now accepts terms prefixed with '@' sign, indicating an exact match.
 * bash-it search now performs smarter caching of the component listings/status

New search syntax is as follows:

   bash-it search [-|@]term1 [-|@]term2 [ --enable | --disable | --help ]
2018-11-19 11:55:36 -08:00
Piotr Rogoża 48e6888a38 Removed reload keyword from composure_keywords(), it is not needed 2018-04-21 19:15:50 +02:00
Piotr Rogoża 89d1661d23 Replaced reload section with proper function.
Added completion for reload.
Fixed order in completion
Added unit tests for completion
The variable BASH_IT_AUTOMATIC_RELOAD_AFTER_CONFIG_CHANGE has to be unset.
2018-04-18 21:51:20 +02:00
Dan Wendorf c5f2c408e7 SCM_CURRENT_USER supports accented characters
`tr 'A-Z' 'a-z'` will only convert non-accented characters. Switching to
`[:upper:]` and `[:lower:]` adds support for accents.
See https://github.com/koalaman/shellcheck/wiki/SC2018

Additionally, printf's character splitting does not support accented
characters, so output isn't as expected. Using bash's variable expansion
syntax instead will correctly get the full accented character.
2017-12-18 09:05:33 -08:00
Dan Wendorf 150e82b221 Refactor git functionality into githelpers.theme.bash
- Add unit tests around git functionality
2017-12-18 09:05:33 -08:00
Nils Winkler 31990490fa Added test for the "no" energy tool case 2017-11-02 06:46:01 +01:00
Nils Winkler 5ab0cc5388 Fixed ioreg - no battery test case 2017-11-02 06:46:01 +01:00
Nils Winkler 7ea1a58216 Added comments on the test functions 2017-11-02 06:46:01 +01:00
Nils Winkler 629b8522e5 Ensuring that output is always two digits at least
Show "04" instead of just "4".
2017-11-02 06:46:01 +01:00
Nils Winkler 7602b1da32 Added tests for WMIC 2017-11-02 06:46:01 +01:00
Nils Winkler 601202e816 Simplified ioreg, added tests for no status 2017-11-02 06:46:01 +01:00