Commit Graph

88 Commits (bf2034d13d23e51a16a874264a24013585d3ec4f)

Author SHA1 Message Date
John D Pell 866e5be86b lib/command_duration: tests & whitespace 2022-03-04 12:58:07 -08:00
John D Pell 4e0e59230b lib/command_duration: rename `theme/command_duration.theme`
Rename the `theme/command_duration.theme` file as it's not really got anything to do with theming or SCM.
2022-03-04 12:58:07 -08:00
John D Pell 6ca10cf84c plugin/cmd-returned-notify: Rewrite to match/use `lib/command_duration`
Use `$EPOCHREALTIME` (or `$SECONDS`) built-in variable provided by Bash instead of `date +%s`. We're only measuing the difference in seconds, so avoid both the binary invocation as well as the subshell.

Alsö, Reduce environmental pollution by not exporting every variable, and unsetting when done.

Change variable names to match lib/command-duration

Remove `preexec_return_notification()` in favor of `lib/command-duration`'s `_command_duration_pre_exec()`.

This should now use the same preexec hook and variables as the theme library `command_duration`.

tests: handle nanoseconds
2022-03-04 12:58:07 -08:00
John D Pell 6d422f17e4 Revert dc380e9ed6 2022-03-03 23:33:05 -08:00
John D Pell dc380e9ed6 test/battery: fix tests… 2022-03-03 23:14:33 -08:00
John D Pell 6734baf950 test/base: lose old TravisCS skip 2022-03-03 23:02:29 -08:00
John D Pell 0d55a2406c test/base: adopt newly revamped `setup()` 2022-03-03 22:43:17 -08:00
John D Pell b686515877 test/xterm: adopt newly revamped `setup()` 2022-03-03 22:43:17 -08:00
John D Pell a36a4c4038 test/ruby: adopt newly revamped `setup()` 2022-03-03 22:43:17 -08:00
John D Pell fbf7efa1b8 test/go: adopt newly revamped `setup()` 2022-03-03 22:43:17 -08:00
John D Pell 4a9df8ec88 test/cmd-returned-notify: adopt newly revamped `setup()` 2022-03-03 22:43:17 -08:00
John D Pell 6e2e0af7f9 test/battery: adopt newly revamped `setup()` 2022-03-03 22:43:17 -08:00
John D Pell fd1771d45c test/base: adopt newly revamped `setup()` 2022-03-03 22:43:17 -08:00
John D Pell 789ede9ef3 plugin/battery: fix tests 2022-02-24 12:52:26 -08:00
Noah Gorny 0619c19f65
Merge pull request #2074 from NariyasuHeseri/master
plugin/battery: bug fix
2022-02-14 08:22:33 +02:00
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 7fcad6ed0d completion/alias: rename
There is no reason for this to be in the `plugins` directory, it just needs to have a load priority sufficiently high that it runs after any aliases are defined.
2022-01-30 16:13:54 -08:00
John D Pell 2a8d8ba540 lib/colors: rename `theme/colors` 2022-01-28 13:08:50 -08:00
John D Pell 7a0b353cea lib/preexec: rename `vendor/init.d/preexec.bash` 2022-01-25 13:00:04 -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 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
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 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
cornfeedhobo b7feb14404
skip go tests when go is not available 2021-09-29 18:16:52 -05: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
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 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
Nils Winkler 03e9124edb
Fixed test execution 2020-08-05 10:36:29 +02:00
Noah Gorny 0053f27820 test: Add alias-completion plugin test 2020-06-28 11:37:08 +03: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 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
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
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
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