Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
014c102
BATS: revamp test `setup()` and `setup_test_fixture()`
gaelicWizard Jan 31, 2022
cb9b999
BATS: de-parallelize
gaelicWizard Jan 12, 2022
fd1771d
test/base: adopt newly revamped `setup()`
gaelicWizard Feb 4, 2022
de31a30
test/bash_it: adopt newly revamped `setup()`
gaelicWizard Feb 4, 2022
c837232
test/bash-it: adopt newly revamped `setup()`
gaelicWizard Feb 4, 2022
2a95e98
test/install: adopt newly revamped `setup()`
gaelicWizard Jan 31, 2022
425ef3e
test/composure: adopt newly revamped `setup()`
gaelicWizard Feb 4, 2022
1ddec65
test/helpers: adopt newly revamped `setup()`
gaelicWizard Jan 31, 2022
e5cd101
test/log: adopt newly revamped `setup()`
gaelicWizard Feb 4, 2022
629a1b0
test/search: adopt newly revamped `setup()`
gaelicWizard Jan 31, 2022
fd91211
test/utilities: adopt newly revamped `setup()`
gaelicWizard Jan 31, 2022
beac9c4
test/aliases: adopt newly revamped `setup()`
gaelicWizard Feb 14, 2022
6e2e0af
test/battery: adopt newly revamped `setup()`
gaelicWizard Jan 31, 2022
4a9df8e
test/cmd-returned-notify: adopt newly revamped `setup()`
gaelicWizard Jan 31, 2022
fbf7efa
test/go: adopt newly revamped `setup()`
gaelicWizard Feb 4, 2022
a36a4c4
test/ruby: adopt newly revamped `setup()`
gaelicWizard Jan 31, 2022
b686515
test/xterm: adopt newly revamped `setup()`
gaelicWizard Jan 31, 2022
f0dfe1a
test/theme: adopt newly revamped `setup()`
gaelicWizard Jan 31, 2022
0d55a24
test/base: adopt newly revamped `setup()`
gaelicWizard Jan 31, 2022
a9dda3d
test/preexec: adopt newly revamped `setup()`
gaelicWizard Jan 31, 2022
6734baf
test/base: lose old TravisCS skip
gaelicWizard Mar 4, 2022
dc380e9
test/battery: fix tests…
gaelicWizard Mar 4, 2022
6d422f1
Revert dc380e9ed6f42967e759e8b66791f796db964843
gaelicWizard Mar 4, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion clean_files.txt
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,6 @@ plugins/available/zoxide.plugin.bash
test/plugins/alias-completion.plugin.bats
test/run
test/test_helper.bash
test/test_helper_libs.bash

# themes
#
Expand Down
18 changes: 5 additions & 13 deletions test/bash_it/bash_it.bats
Original file line number Diff line number Diff line change
@@ -1,19 +1,11 @@
#!/usr/bin/env bats
# shellcheck shell=bats

load ../test_helper

function local_setup {
setup_test_fixture
load "${MAIN_BASH_IT_DIR?}/test/test_helper.bash"

function local_setup_file() {
# Copy the test fixture to the Bash-it folder
if command -v rsync &> /dev/null
then
rsync -a "$BASH_IT/test/fixtures/bash_it/" "$BASH_IT/"
else
find "$BASH_IT/test/fixtures/bash_it" \
-mindepth 1 -maxdepth 1 \
-exec cp -r {} "$BASH_IT/" \;
fi
cp -fRP "${BASH_IT?}/test/fixtures/bash_it"/* "${BASH_IT?}/" || true
# don't load any libraries as the tests here test the *whole* kit
}

@test "bash-it: verify that the test fixture is available" {
Expand Down
18 changes: 10 additions & 8 deletions test/completion/aliases.completion.bats
Original file line number Diff line number Diff line change
@@ -1,28 +1,30 @@
#!/usr/bin/env bats
# shellcheck shell=bats

load ../test_helper
load ../test_helper_libs
load "${MAIN_BASH_IT_DIR?}/test/test_helper.bash"

# Load something, anything...
load ../../completion/available/capistrano.completion
function local_setup_file() {
setup_libs "helpers"
# Load something, anything...
load ../../completion/available/capistrano.completion
}

@test "alias-completion: See that aliases with double quotes and brackets do not break the plugin" {
alias gtest="git log --graph --pretty=format:'%C(bold)%h%Creset%C(magenta)%d%Creset %s %C(yellow)<%an> %C(cyan)(%cr)%Creset' --abbrev-commit --date=relative"
run load ../../completion/available/aliases.completion
run load "${BASH_IT?}/completion/available/aliases.completion.bash"

assert_success
}

@test "alias-completion: See that aliases with single quotes and brackets do not break the plugin" {
alias gtest='git log --graph --pretty=format:"%C(bold)%h%Creset%C(magenta)%d%Creset %s %C(yellow)<%an> %C(cyan)(%cr)%Creset" --abbrev-commit --date=relative'
run load ../../completion/available/aliases.completion
run load "${BASH_IT?}/completion/available/aliases.completion.bash"

assert_success
}

@test "alias-completion: See that having aliased rm command does not output unnecessary output" {
alias rm='rm -v'
run load ../../completion/available/aliases.completion
run load "${BASH_IT?}/completion/available/aliases.completion.bash"

refute_output
}
15 changes: 7 additions & 8 deletions test/completion/bash-it.completion.bats
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
#!/usr/bin/env bats
# shellcheck shell=bats

load ../test_helper
load ../../lib/utilities
load ../../lib/helpers
load ../../completion/available/bash-it.completion
load "${MAIN_BASH_IT_DIR?}/test/test_helper.bash"

function local_setup {
setup_test_fixture
function local_setup_file() {
setup_libs "helpers"
load "${BASH_IT?}/completion/available/bash-it.completion.bash"
}

@test "completion bash-it: ensure that the _bash-it function is available" {
type -a _bash-it &> /dev/null
run type -t _bash-it
assert_success
assert_output "function"
}

function __check_completion () {
Expand Down
59 changes: 31 additions & 28 deletions test/install/install.bats
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
#!/usr/bin/env bats

load ../test_helper

# Determine which config file to use based on OS.
case $OSTYPE in
darwin*)
export BASH_IT_CONFIG_FILE=.bash_profile
;;
*)
export BASH_IT_CONFIG_FILE=.bashrc
;;
esac

function local_setup {
setup_test_fixture
# shellcheck shell=bats

load "${MAIN_BASH_IT_DIR?}/test/test_helper.bash"

function local_setup() {
export HOME="$BATS_TEST_TMPDIR"
}

function local_setup_file() {
# Determine which config file to use based on OS.
case $OSTYPE in
darwin*)
export BASH_IT_CONFIG_FILE=.bash_profile
;;
*)
export BASH_IT_CONFIG_FILE=.bashrc
;;
esac
# don't load any libraries as the tests here test the *whole* kit
}

@test "install: verify that the install script exists" {
Expand All @@ -25,7 +28,7 @@ function local_setup {

./install.sh --silent

assert_file_exist "$BASH_IT_TEST_HOME/$BASH_IT_CONFIG_FILE"
assert_file_exist "$HOME/$BASH_IT_CONFIG_FILE"

assert_link_exist "$BASH_IT/enabled/150---general.aliases.bash"
assert_link_exist "$BASH_IT/enabled/250---base.plugin.bash"
Expand All @@ -37,16 +40,16 @@ function local_setup {
@test "install: verify that a backup file is created" {
cd "$BASH_IT"

touch "$BASH_IT_TEST_HOME/$BASH_IT_CONFIG_FILE"
echo "test file content" > "$BASH_IT_TEST_HOME/$BASH_IT_CONFIG_FILE"
local md5_orig=$(md5sum "$BASH_IT_TEST_HOME/$BASH_IT_CONFIG_FILE" | awk '{print $1}')
touch "$HOME/$BASH_IT_CONFIG_FILE"
echo "test file content" > "$HOME/$BASH_IT_CONFIG_FILE"
local md5_orig=$(md5sum "$HOME/$BASH_IT_CONFIG_FILE" | awk '{print $1}')

./install.sh --silent

assert_file_exist "$BASH_IT_TEST_HOME/$BASH_IT_CONFIG_FILE"
assert_file_exist "$BASH_IT_TEST_HOME/$BASH_IT_CONFIG_FILE.bak"
assert_file_exist "$HOME/$BASH_IT_CONFIG_FILE"
assert_file_exist "$HOME/$BASH_IT_CONFIG_FILE.bak"

local md5_bak=$(md5sum "$BASH_IT_TEST_HOME/$BASH_IT_CONFIG_FILE.bak" | awk '{print $1}')
local md5_bak=$(md5sum "$HOME/$BASH_IT_CONFIG_FILE.bak" | awk '{print $1}')

assert_equal "$md5_orig" "$md5_bak"
}
Expand All @@ -70,15 +73,15 @@ function local_setup {
@test "install: verify that the template is appended" {
cd "$BASH_IT"

touch "$BASH_IT_TEST_HOME/$BASH_IT_CONFIG_FILE"
echo "test file content" > "$BASH_IT_TEST_HOME/$BASH_IT_CONFIG_FILE"
touch "$HOME/$BASH_IT_CONFIG_FILE"
echo "test file content" > "$HOME/$BASH_IT_CONFIG_FILE"

./install.sh --silent --append-to-config

assert_file_exist "$BASH_IT_TEST_HOME/$BASH_IT_CONFIG_FILE"
assert_file_exist "$BASH_IT_TEST_HOME/$BASH_IT_CONFIG_FILE.bak"
assert_file_exist "$HOME/$BASH_IT_CONFIG_FILE"
assert_file_exist "$HOME/$BASH_IT_CONFIG_FILE.bak"

run cat $BASH_IT_TEST_HOME/$BASH_IT_CONFIG_FILE
run cat "$HOME/$BASH_IT_CONFIG_FILE"

assert_line "test file content"
assert_line "source \"\$BASH_IT\"/bash_it.sh"
Expand Down
67 changes: 34 additions & 33 deletions test/install/uninstall.bats
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
#!/usr/bin/env bats

load ../test_helper

# Determine which config file to use based on OS.
case $OSTYPE in
darwin*)
export BASH_IT_CONFIG_FILE=.bash_profile
;;
*)
export BASH_IT_CONFIG_FILE=.bashrc
;;
esac

function local_setup {
setup_test_fixture
# shellcheck shell=bats

load "${MAIN_BASH_IT_DIR?}/test/test_helper.bash"

function local_setup() {
export HOME="$BATS_TEST_TMPDIR"
}

function local_setup_file() {
# Determine which config file to use based on OS.
case $OSTYPE in
darwin*)
export BASH_IT_CONFIG_FILE=.bash_profile
;;
*)
export BASH_IT_CONFIG_FILE=.bashrc
;;
esac
# don't load any libraries as the tests here test the *whole* kit
}

@test "uninstall: verify that the uninstall script exists" {
Expand All @@ -23,38 +26,36 @@ function local_setup {
@test "uninstall: run the uninstall script with an existing backup file" {
cd "$BASH_IT"

echo "test file content for backup" > "$BASH_IT_TEST_HOME/$BASH_IT_CONFIG_FILE.bak"
echo "test file content for original file" > "$BASH_IT_TEST_HOME/$BASH_IT_CONFIG_FILE"
local md5_bak=$(md5sum "$BASH_IT_TEST_HOME/$BASH_IT_CONFIG_FILE.bak" | awk '{print $1}')

./uninstall.sh
echo "test file content for backup" > "$HOME/$BASH_IT_CONFIG_FILE.bak"
echo "test file content for original file" > "$HOME/$BASH_IT_CONFIG_FILE"
local md5_bak=$(md5sum "$HOME/$BASH_IT_CONFIG_FILE.bak" | awk '{print $1}')

run ./uninstall.sh
assert_success

assert_file_not_exist "$BASH_IT_TEST_HOME/$BASH_IT_CONFIG_FILE.uninstall"
assert_file_not_exist "$BASH_IT_TEST_HOME/$BASH_IT_CONFIG_FILE.bak"
assert_file_exist "$BASH_IT_TEST_HOME/$BASH_IT_CONFIG_FILE"
assert_file_not_exist "$HOME/$BASH_IT_CONFIG_FILE.uninstall"
assert_file_not_exist "$HOME/$BASH_IT_CONFIG_FILE.bak"
assert_file_exist "$HOME/$BASH_IT_CONFIG_FILE"

local md5_conf=$(md5sum "$BASH_IT_TEST_HOME/$BASH_IT_CONFIG_FILE" | awk '{print $1}')
local md5_conf=$(md5sum "$HOME/$BASH_IT_CONFIG_FILE" | awk '{print $1}')

assert_equal "$md5_bak" "$md5_conf"
}

@test "uninstall: run the uninstall script without an existing backup file" {
cd "$BASH_IT"

echo "test file content for original file" > "$BASH_IT_TEST_HOME/$BASH_IT_CONFIG_FILE"
local md5_orig=$(md5sum "$BASH_IT_TEST_HOME/$BASH_IT_CONFIG_FILE" | awk '{print $1}')

./uninstall.sh
echo "test file content for original file" > "$HOME/$BASH_IT_CONFIG_FILE"
local md5_orig=$(md5sum "$HOME/$BASH_IT_CONFIG_FILE" | awk '{print $1}')

run ./uninstall.sh
assert_success

assert_file_exist "$BASH_IT_TEST_HOME/$BASH_IT_CONFIG_FILE.uninstall"
assert_file_not_exist "$BASH_IT_TEST_HOME/$BASH_IT_CONFIG_FILE.bak"
assert_file_not_exist "$BASH_IT_TEST_HOME/$BASH_IT_CONFIG_FILE"
assert_file_exist "$HOME/$BASH_IT_CONFIG_FILE.uninstall"
assert_file_not_exist "$HOME/$BASH_IT_CONFIG_FILE.bak"
assert_file_not_exist "$HOME/$BASH_IT_CONFIG_FILE"

local md5_uninstall=$(md5sum "$BASH_IT_TEST_HOME/$BASH_IT_CONFIG_FILE.uninstall" | awk '{print $1}')
local md5_uninstall=$(md5sum "$HOME/$BASH_IT_CONFIG_FILE.uninstall" | awk '{print $1}')

assert_equal "$md5_orig" "$md5_uninstall"
}
9 changes: 7 additions & 2 deletions test/lib/composure.bats
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
#!/usr/bin/env bats
# shellcheck shell=bats

load ../test_helper
load "${MAIN_BASH_IT_DIR?}/test/test_helper.bash"

function local_setup_file() {
true
# don't load any libraries as the tests here test the *whole* kit
}

@test "lib composure: _composure_keywords()" {
run _composure_keywords
Expand Down
22 changes: 8 additions & 14 deletions test/lib/helpers.bats
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,21 +1,15 @@
#!/usr/bin/env bats
# shellcheck shell=bats

load ../test_helper
load ../test_helper_libs
load ../../plugins/available/base.plugin
load ../../lib/colors
load "${MAIN_BASH_IT_DIR?}/test/test_helper.bash"

function local_setup {
setup_test_fixture
function local_setup_file() {
setup_libs "colors"
load "${BASH_IT?}/plugins/available/base.plugin.bash"
}

function local_setup() {
# Copy the test fixture to the Bash-it folder
if command -v rsync &> /dev/null; then
rsync -a "$BASH_IT/test/fixtures/bash_it/" "$BASH_IT/"
else
find "$BASH_IT/test/fixtures/bash_it" \
-mindepth 1 -maxdepth 1 \
-exec cp -r {} "$BASH_IT/" \;
fi
cp -RP "$BASH_IT/test/fixtures/bash_it"/* "$BASH_IT/"
}

# TODO Create global __is_enabled function
Expand Down
11 changes: 5 additions & 6 deletions test/lib/log.bats
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
#!/usr/bin/env bats
# shellcheck shell=bats

load ../test_helper
load ../../lib/colors
load "${MAIN_BASH_IT_DIR?}/test/test_helper.bash"

load ../../lib/log
load ../../lib/helpers
load ../../plugins/available/base.plugin
function local_setup_file() {
setup_libs "log"
}

@test "lib log: basic debug logging with BASH_IT_LOG_LEVEL_ALL" {
BASH_IT_LOG_LEVEL=$BASH_IT_LOG_LEVEL_ALL
Expand Down
8 changes: 4 additions & 4 deletions test/lib/preexec.bats
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ function local_setup {

@test "lib preexec: __check_precmd_conflict()" {
test_precmd_function_name="test"
load ../test_helper_libs
setup_libs "preexec"

run __check_precmd_conflict "$test_precmd_function_name"
assert_failure
Expand All @@ -124,7 +124,7 @@ function local_setup {

@test "lib preexec: __check_preexec_conflict()" {
test_preexec_function_name="test"
load ../test_helper_libs
setup_libs "preexec"

run __check_preexec_conflict "$test_preexec_function_name"
assert_failure
Expand All @@ -137,7 +137,7 @@ function local_setup {

@test "lib preexec: safe_append_prompt_command()" {
test_precmd_function_name="test"
load ../test_helper_libs
setup_libs "preexec"

export precmd_functions=()
assert_equal "${precmd_functions[*]}" ""
Expand All @@ -151,7 +151,7 @@ function local_setup {

@test "lib preexec: safe_append_preexec()" {
test_preexec_function_name="test"
load ../test_helper_libs
setup_libs "preexec"

export preexec_functions=()
assert_equal "${preexec_functions[*]}" ""
Expand Down
Loading