Skip to content
Snippets Groups Projects
Commit 2f1a8824 authored by Nikolaos Kakouros's avatar Nikolaos Kakouros
Browse files

wip

parent d676107e
No related branches found
No related tags found
No related merge requests found
......@@ -21,7 +21,7 @@ distro_packages+=(
pip_packages+=(
# 'python-gilt'
'git+git://github.com/nkakouros-forks/gilt@all'
'git+https://github.com/nkakouros-forks/gilt.git@all'
)
info "checking required tools and libraries..."
......
......@@ -20,60 +20,35 @@
# you may need to include it in quotes so it isn't expanded by the shell
# _before_ executing the {{cmd}} command.
# Taken from custom/vendor/go-script-bash/scripts/test
test_dir="${_HEADSTART_SCRIPT_NAME~~}_TESTS_DIR"
test_dir="${!test_dir}"
# Passes all arguments through to `@go.bats_main` from
# `scripts/vendor/go-script-bash/lib/bats-main`.
_test_main() {
declare -x TMPDIR="$_HEADSTART_TMP_DIR"
# This environment variable is read by Bats in order to set its own temp
# folder (BATS_TMPDIR variable). The BATS_TMPDIR variable is used then to set
# the variables BATS_TEST_ROOTDIR=TEST_GO_ROOTDIR='BATS_TMPDIR/test rootdir'
# which are used throughout go-script's test libraries. In the end, both Bats
# and go-script-bash's test operation use this as their temp folder.
function __completions() {
# Where to find the tests to run
local test_dir="${_HEADSTART_SCRIPT_NAME~~}_TEST_DIR"
declare -x HEADSTART_TEST_FIXTURES="${!test_dir}/unit/fixtures"
# drive the @go.bats_main script
declare -x _GO_COVERALLS_URL=''
declare -x _GO_BATS_DIR="$_HEADSTART_VENDOR_DIR/bats-core"
declare -x _GO_BATS_GLOB_ARGS=("tests/unit" '.bats')
# The first argument is the path to search into, the second is the file
# extension to look for. The path has to not include spaces due to a bug in
# go-script-bash, in lib/bats-main. So, we declare it as relative here,
# knowing that it will not contain spaces this way.
export GLOBIGNORE="$test_dir/unit/fixtures/*"
for test_file in "$test_dir/unit"/**/*.bats; do
test_file="${test_file#"$test_dir/unit/"}"
echo "${test_file%.bats}"
done
}
__() {
bats="$_HEADSTART_CORE_DIR/vendor/bats-core/bin/bats"
declare -x _GO_KCOV_DIR="$_HEADSTART_TMP_DIR/kcov"
declare -x _GO_BATS_COVERAGE_DIR="$_HEADSTART_TMP_DIR/coverage"
declare -x _GO_COLLECT_BATS_COVERAGE=''
# TODO see if these paths actually work
declare -x _GO_BATS_COVERAGE_INCLUDE=('headstart' 'commands' 'lib')
if [[ "$list" == 'true' ]]; then
__completions
return
fi
declare -x FIVEG_TEST_COMMON_ENV="$FIVEG_TEST_DIR/unit/common/environment.bash"
# This is meant to be used by test files to load the common environment.
if [[ "${glob[*]}" == '' ]]; then
read -ar glob <<< "$(__completions)"
fi
. "$_GO_USE_MODULES" 'bats-main'
# Tab completions
read -a glob <<< "${glob[*]/%/.bats}"
trap '' ERR
# TODO add note about lib/system not being enough
# <<-CODE-NOTE: The error trap should be set to Bash Infinity's exception
# handler that print the stack trace on unexpected error. The
# next line will call Bats. If a test fails, then Bats will
# exit with code 1. This will trigger the stack trace, which is
# sth we do not want as the "error" is not sth we should be
# worried about, it is not actually an error, just a status
# code. We unset therefore the ERR trap here before calling
# Bats.
cd "$test_dir/unit" || exit 1
# TODO this should not be needed, I install bats and libraries as git
# submodules. This is needed to override go-script stuff that our outdated.
# Use the standard bats
_GO_BATS_URL="https://github.com/bats-core/bats-core/"
_GO_BATS_VERSION="master"
@go.bats_main "$@"
set +eu
"$bats" "${glob[@]}"
}
_test_main "$@"
__ "$@"
......@@ -569,6 +569,7 @@ function bash_string_join() {
function bash_array_search() {
local __array1="${1-}"
local needle="${2-}"
local return_index="${3-false}"
__array1="$__array1[@]"
......@@ -583,5 +584,6 @@ function bash_array_search() {
i=i+1
done
echo "$key"
[[ "$return_index" == true ]] && echo "$key"
[[ "$key" -eq -1 ]] && return 1 || return 0
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment