Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add bashcov report #2102

Draft
wants to merge 6 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
17 changes: 17 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,23 @@ jobs:
- name: Test code
run: test/run

code-coverage:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: ruby/[email protected]
with:
ruby-version: '2.7'
- name: Install Ruby dependencies
run: bundle update --bundler && bundle install
- name: Run tests
run: bashcov test/run
- name: Upload reports to Codecov
run: |
curl -Os https://uploader.codecov.io/latest/linux/codecov
chmod +x codecov
./codecov -f coverage/codecov-result.json -Z

build-docs:
runs-on: ubuntu-latest

Expand Down
6 changes: 6 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# frozen_string_literal: true

source 'https://rubygems.org'

gem 'bashcov'
gem 'codecov'
24 changes: 24 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
GEM
remote: https://rubygems.org/
specs:
bashcov (1.8.1)
simplecov (~> 0.15)
codecov (0.4.2)
simplecov (>= 0.15, < 0.22)
docile (1.3.5)
simplecov (0.21.2)
docile (~> 1.1)
simplecov-html (~> 0.11)
simplecov_json_formatter (~> 0.1)
simplecov-html (0.12.3)
simplecov_json_formatter (0.1.2)

PLATFORMS
ruby

DEPENDENCIES
bashcov
codecov

BUNDLED WITH
1.17.3
20 changes: 10 additions & 10 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ function _bash-it_check_for_backup() {
fi
echo -e "\033[0;33mBackup file already exists. Make sure to backup your .bashrc before running this installation.\033[0m" >&2

if [[ -z "${overwrite_backup}" ]]; then
while [[ -z "${silent}" ]]; do
if [[ -z "${overwrite_backup:-}" ]]; then
while [[ -z "${silent:-}" ]]; do
read -e -n 1 -r -p "Would you like to overwrite the existing backup? This will delete your existing backup file ($HOME/$BACKUP_FILE) [y/N] " RESP
case $RESP in
[yY])
Expand All @@ -100,9 +100,9 @@ function _bash-it_check_for_backup() {
esac
done
fi
if [[ -z "${overwrite_backup}" ]]; then
if [[ -z "${overwrite_backup:-}" ]]; then
echo -e "\033[91mInstallation aborted. Please come back soon!\033[m"
if [[ -n "${silent}" ]]; then
if [[ -n "${silent:-}" ]]; then
echo -e "\033[91mUse \"-f\" flag to force overwrite of backup.\033[m"
fi
exit 1
Expand All @@ -114,8 +114,8 @@ function _bash-it_check_for_backup() {
function _bash-it_modify_config_files() {
_bash-it_check_for_backup

if [[ -z "${silent}" ]]; then
while [[ -z "${append_to_config}" ]]; do
if [[ -z "${silent:-}" ]]; then
while [[ -z "${append_to_config:-}" ]]; do
read -e -n 1 -r -p "Would you like to keep your $CONFIG_FILE and append bash-it templates at the end? [y/N] " choice
case $choice in
[yY])
Expand All @@ -131,7 +131,7 @@ function _bash-it_modify_config_files() {
esac
done
fi
if [[ -n "${append_to_config}" ]]; then
if [[ -n "${append_to_config:-}" ]]; then
# backup/append
_bash-it_backup_append
else
Expand Down Expand Up @@ -174,12 +174,12 @@ done

shift $((OPTIND - 1))

if [[ -n "${silent}" && -n "${interactive}" ]]; then
if [[ -n "${silent:-}" && -n "${interactive:-}" ]]; then
echo -e "\033[91mOptions --silent and --interactive are mutually exclusive. Please choose one or the other.\033[m"
exit 1
fi

if [[ -n "${no_modify_config}" && -n "${append_to_config}" ]]; then
if [[ -n "${no_modify_config:-}" && -n "${append_to_config:-}" ]]; then
echo -e "\033[91mOptions --no-modify-config and --append-to-config are mutually exclusive. Please choose one or the other.\033[m"
exit 1
fi
Expand Down Expand Up @@ -214,7 +214,7 @@ cite _about _param _example _group _author _version
# shellcheck source=./lib/helpers.bash
source "$BASH_IT/lib/helpers.bash"

if [[ -n $interactive && -z "${silent}" ]]; then
if [[ -n ${interactive:-} && -z "${silent:-}" ]]; then
for type in "aliases" "plugins" "completion"; do
echo -e "\033[0;32mEnabling ${type}\033[0m"
_bash-it_load_some "$type"
Expand Down
8 changes: 4 additions & 4 deletions test/completion/bash-it.completion.bats
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ function local_setup {
}

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

Expand Down Expand Up @@ -71,12 +71,12 @@ function __check_completion () {

@test "completion bash-it: search - show no options" {
run __check_completion 'bash-it search '
assert_line -n 0 ""
assert_output ""
}

@test "completion bash-it: migrate - show no options" {
run __check_completion 'bash-it migrate '
assert_line -n 0 ""
assert_output ""
}

@test "completion bash-it: show options" {
Expand Down Expand Up @@ -146,7 +146,7 @@ function __check_completion () {

@test "completion bash-it: disable - provide nothing when atom is not enabled" {
run __check_completion 'bash-it disable alias ato'
assert_line -n 0 ""
assert_output ""
}

@test "completion bash-it: disable - provide all when atom is not enabled" {
Expand Down
4 changes: 2 additions & 2 deletions test/install/uninstall.bats
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ function local_setup {
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
run ./uninstall.sh

assert_success

Expand All @@ -46,7 +46,7 @@ function local_setup {
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
run ./uninstall.sh

assert_success

Expand Down
4 changes: 2 additions & 2 deletions test/lib/helpers.bats
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ function local_setup {

@test "helpers: bash-it help aliases without any aliases enabled" {
run bash-it help aliases
assert_line -n 0 ""
assert_output ""
}

@test "helpers: bash-it help plugins" {
Expand Down Expand Up @@ -521,7 +521,7 @@ function local_setup {
function __migrate_all_components() {
subdirectory="$1"
one_type="$2"
priority="$3"
priority="${3:-}"

for f in "${BASH_IT}/$subdirectory/available/"*.bash
do
Expand Down
8 changes: 0 additions & 8 deletions test/lib/preexec.bats
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ function local_setup {
export PROMPT_COMMAND="$test_prompt_string"

load ../../vendor/github.com/rcaloras/bash-preexec/bash-preexec.sh
assert_success

assert_equal "${PROMPT_COMMAND}" $'__bp_trap_string="$(trap -p DEBUG)"\ntrap - DEBUG\n__bp_install'
}

Expand All @@ -22,8 +20,6 @@ function local_setup {
export PROMPT_COMMAND="$test_prompt_string"

load ../../vendor/github.com/rcaloras/bash-preexec/bash-preexec.sh
assert_success

assert_equal "${PROMPT_COMMAND}" "$test_prompt_string"$'\n__bp_trap_string="$(trap -p DEBUG)"\ntrap - DEBUG\n__bp_install'
}

Expand All @@ -33,8 +29,6 @@ function local_setup {
export __bp_delay_install="blarg"

load ../../vendor/github.com/rcaloras/bash-preexec/bash-preexec.sh
assert_success

assert_equal "${PROMPT_COMMAND}" "$test_prompt_string"

run __bp_install_after_session_init
Expand All @@ -49,7 +43,6 @@ function local_setup {
export PROMPT_COMMAND="$test_prompt_string"

load ../../vendor/github.com/rcaloras/bash-preexec/bash-preexec.sh
assert_success

run __bp_install
assert_success
Expand All @@ -63,7 +56,6 @@ function local_setup {
export PROMPT_COMMAND="$test_prompt_string"

load ../../vendor/github.com/rcaloras/bash-preexec/bash-preexec.sh
assert_success

run __bp_install
assert_success
Expand Down
4 changes: 2 additions & 2 deletions test/plugins/base.plugin.bats
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ load ../test_helper_libs
load ../../plugins/available/base.plugin

@test 'plugins base: ips()' {
if [[ $CI ]]; then
if [[ -n "${CI:-}" ]]; then
skip 'ifconfig probably requires sudo on TravisCI'
fi

Expand Down Expand Up @@ -38,7 +38,7 @@ load ../../plugins/available/base.plugin
rm -rf "${BASH_IT_ROOT}/${dir_name}"

mkcd "${dir_name}"
assert_success

assert_dir_exist "${BASH_IT_ROOT}/${dir_name}"
assert_equal "${PWD}" "${BASH_IT_ROOT//\/\///}/${dir_name}"
}
Expand Down
4 changes: 2 additions & 2 deletions test/themes/base.theme.bats
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ load ../../themes/base.theme
assert_line "function"

run battery_char
assert_line -n 0 ""
assert_output ""
}

@test 'themes base: battery_char should exist if battery plugin loaded' {
Expand Down Expand Up @@ -51,7 +51,7 @@ load ../../themes/base.theme

run battery_charge
assert_success
assert_line -n 0 ""
assert_output ""
}

@test 'themes base: battery_charge should exist if battery plugin loaded' {
Expand Down
2 changes: 1 addition & 1 deletion test_lib/bats-file