Commit f7107223 authored by Tomasz Maczukin's avatar Tomasz Maczukin

Merge branch 'shellcheck_2155' into 'master'

Fix SC2155 where shellcheck warns about errors

Closes #3663

See merge request gitlab-org/gitlab-runner!1063
parents 610dff39 34a630e4
......@@ -39,11 +39,15 @@ prepareTestCommands() {
echo "Listing tests for ${pkg} package"
local tempFile=$(mktemp)
local tempFile
tempFile=$(mktemp)
local exitCode=0
go test -list "Test.*" "${pkg}" > "${tempFile}" || exitCode=1
local tests=$(grep "^Test" "${tempFile}")
local tests
tests=$(grep "^Test" "${tempFile}" || true)
rm "${tempFile}"
if [[ ${exitCode} -ne 0 ]]; then
......@@ -86,7 +90,8 @@ executeTestCommand() {
local options=""
local pkgSlug=$(echo "${pkg}" | tr "/" "-")
local pkgSlug
pkgSlug=$(echo "${pkg}" | tr "/" "-")
if [[ ${TESTFLAGS} = *"-cover"* ]]; then
mkdir -p ".cover"
......@@ -113,9 +118,12 @@ executeTestPart() {
rm -rf ".cover/"
rm -rf ".testoutput/"
local numberOfDefinitions=$(< "${testsDefinitions}" wc -l)
local executionSize=$((numberOfDefinitions/SUITE_TOTAL+1))
local executionOffset=$((SUITE_INDEX*executionSize+1))
local numberOfDefinitions
numberOfDefinitions=$(< "${testsDefinitions}" wc -l)
local executionSize
executionSize=$((numberOfDefinitions/SUITE_TOTAL+1))
local executionOffset
executionOffset=$((SUITE_INDEX*executionSize+1))
printMessage "Number of definitions: ${numberOfDefinitions}"
printMessage "Suite size: ${SUITE_TOTAL}"
......@@ -149,7 +157,8 @@ computeCoverageReport() {
go tool cover -o ${textReportFile} -func=${sourceFile}
printMessage "General coverage percentage:"
local total=$(grep "total" "${textReportFile}" || echo "")
local total
total=$(grep "total" "${textReportFile}" || echo "")
if [[ -n "${total}" ]]; then
echo "${output} ${total}"
......@@ -180,4 +189,4 @@ case "$1" in
junit)
computeJUnitReport
;;
esac
\ No newline at end of file
esac
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment