Commit Graph

61 Commits (9c4f7773b9a5614fc209fda48751f0d554da4eca)

Author SHA1 Message Date
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
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
Nils Winkler 486c9e1382 Consolidated cases for acpi 2017-11-02 06:46:01 +01:00
Nils Winkler 3aed38c79f Updated acpi tests
Trying to cover the currently implemented tests, but I don't have a
system with acpi available for testing. Relying on assumptions so far.
2017-11-02 06:46:01 +01:00
Nils Winkler 812f49e457 Started first tests for acpi command 2017-11-02 06:46:01 +01:00
Nils Winkler a4824cc8c8 Changed pmset test to use printf 2017-11-02 06:46:01 +01:00
Nils Winkler b7b8a0afe0 Completed tests for upower command 2017-11-02 06:46:01 +01:00
Nils Winkler 5ab23e3ca0 Added test cases for acpi, upower and ioreg, need to fill in data
The one for ioreg works fine, the others currently fail.
2017-11-02 06:46:01 +01:00
Nils Winkler b4c6029706 Made setup function for _command_exists generic 2017-11-02 06:46:01 +01:00
Nils Winkler 28c41efcbc Simplified setup fixture for pmset/_command_exists 2017-11-02 06:46:01 +01:00
Nils Winkler c221648a7f Refactored setup function for pmset 2017-11-02 06:46:01 +01:00
Nils Winkler c8d86858fd Added setup function for _command_exists that works for pmset 2017-11-02 06:46:01 +01:00
Nils Winkler d0b3205de0 Added an additional test case and a fix for using the pmset command
The other commands still need to be mocked and tested/fixed, too.
2017-11-02 06:46:01 +01:00
Nils Winkler ef28b2788b Added test cases for battery_percentage with pmset
Need to figure out way to ensure that pmset is used every time...
2017-11-02 06:46:01 +01:00
Nils Winkler 395e9eff3c Added a couple more tests for mkcd
Also fixed the order of expected/actual for lsgrep test.
2017-10-17 08:18:58 +02:00
Nils Winkler da77e9506d Fixed buf test case that failed from time to time
Taking two timestamps (one before the function-under-test, and one
after), we minimize the chance of failure.
2017-10-17 08:18:58 +02:00
Nils Winkler e574de8f47 Moved testing for files to bats-file library functions 2017-10-14 18:02:04 +02:00
Nils Winkler 2691a5b138 Moved to bats-assert for assert functions 2017-10-14 18:00:43 +02:00
Nils Winkler 8319545b0a Switched to Bats-core as a submodule
Can't use the official v0.4.0 release, since our tests rely on a change
that was made after the release of v0.4.0.

This code currently uses an unversioned commit of the bats-core repo, we
will switch to a supported version once it has been released, e.g.
v0.4.1.
2017-10-14 18:00:43 +02:00
Nils Winkler 3f6f1326dc Fixed ruby test for good (hopefully) 2017-09-17 21:05:59 +02:00
Nils Winkler 3103609640 Reverted Ruby path fix 2017-09-17 21:05:59 +02:00
Nils Winkler 548563e7aa Trying to fix path issue 2017-09-17 21:05:59 +02:00
Nils Winkler f4fa9def14 Fixed the ruby path test in cases where someone already has the ruby bin path on their path variable 2017-09-17 21:05:59 +02:00
Yushin Washio a4472fedaa skip ruby PATH test if ruby not installed 2017-08-17 17:33:56 +05:00
Nils Winkler 0aad8b4ab0 Fixed assert syntax 2017-06-24 17:31:31 +02:00