Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
Bash Headstart
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
cybersecurity
Bash Headstart
Commits
2f1a8824
Commit
2f1a8824
authored
2 years ago
by
Nikolaos Kakouros
Browse files
Options
Downloads
Patches
Plain Diff
wip
parent
d676107e
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
commands/core.d/bootstrap.d/arch.sh
+1
-1
1 addition, 1 deletion
commands/core.d/bootstrap.d/arch.sh
commands/devel.d/test
+23
-48
23 additions, 48 deletions
commands/devel.d/test
lib/bash
+3
-1
3 additions, 1 deletion
lib/bash
with
27 additions
and
50 deletions
commands/core.d/bootstrap.d/arch.sh
+
1
−
1
View file @
2f1a8824
...
...
@@ -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..."
...
...
This diff is collapsed.
Click to expand it.
commands/devel.d/test
+
23
−
48
View file @
2f1a8824
...
...
@@ -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
"
$@
"
_
_
"
$@
"
This diff is collapsed.
Click to expand it.
lib/bash
+
3
−
1
View file @
2f1a8824
...
...
@@ -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
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment