Commit Graph

236 Commits

Author SHA1 Message Date
John D Pell
302bae9c5f test/battery: require matching battery identifier 2022-02-03 16:47:17 -08:00
John D Pell
23f7916a4d test/battery: add multiple-battery edge case 2022-02-03 10:45:27 -08:00
John D Pell
2343e2dd35 lib/preexec: tests! 2022-01-27 12:40:38 -08:00
John D Pell
7a0b353cea lib/preexec: rename vendor/init.d/preexec.bash 2022-01-25 13:00:04 -08:00
John D Pell
5f9a3f143f completion/bash-it: rename _bash-it-comp()
...to `_bash-it()`.

The norm is for the completion function for, e.g., `teh_cmd`. to be named with the same name and a prepended underscore, i.e. `_teh_cmd`. This alsö reduces namespace confusion, which will be relevant in a future patch.
2022-01-24 21:41:23 -08:00
John D Pell
e1e971c0ea completion/bash-it: use read -a to populate $COMPREPLY
This allows for spaces and special characters in file names, i.e. internaltional/unicode words.
2022-01-24 21:41:13 -08:00
John D Pell
3874ad85c2 completion/bash-it: use existing functions 2022-01-24 21:41:13 -08:00
Noah Gorny
edc36795b5 Merge pull request #2030 from gaelicWizard/bats
Update BATS
2022-01-24 23:29:00 +02:00
John D Pell
805eab804c lib/helpers: fix profile subcommand tests 2022-01-18 11:02:37 -08:00
John D Pell
550f808884 lib/helpers: fix _bash-it-describe()
Use `_bash-it-component-item-is-enabled()`

Fix SC2295
2022-01-18 11:02:37 -08:00
John D Pell
5eab3bd288 lib/helpers: first shellcheck pass
Quote things, SC2268, SC2143, SC2181, SC2162, SC2016, SC2013, &c.

Rewrite globbing per `shellcheck`’s SC2013, and alsö s/typeset/local/g. Eliminate `compgen` where possible.

Alsö: use the existing utility functions `_bash-it-get-component-type-from-path` and `_bash-it-get-component-name-from-path`, which just use parameter substitution anyway. Why was `sed` here?

Alsö, don't add not-existing directories to `$PATH` in `pathmunge()`.

Finally, merge PR #1865 from NoahGorny...and clean it a bit...
2022-01-18 11:02:21 -08:00
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