mirror of
https://github.com/super-linter/super-linter.git
synced 2024-12-22 20:52:12 -05:00
Fix Tap report spacing (#1240)
* cleaner * fix go * fix go * going ham * fix typo * fix typo * fix typo * fix mapfile * fix mapfile * fixed spacing
This commit is contained in:
parent
45ee4f07a9
commit
9bfc6158b9
61 changed files with 125 additions and 84 deletions
7
.automation/test/go/reports/expected-GO-1.tap
Normal file
7
.automation/test/go/reports/expected-GO-1.tap
Normal file
|
@ -0,0 +1,7 @@
|
|||
TAP version 13
|
||||
1..2
|
||||
not ok 1 - golang_bad_01.go
|
||||
---
|
||||
message: level=warningg="[runner] Can't run linter goanalysis_metalinter failed prerequisites [buildir@command-line-arguments analysis skipped errors in package [go/golang_bad_01.go 1 1 expected 'package', found 'if' /tmp/lint/.automation/test/go/golang_bad_01.go 1 1 expected 'package', found 'if']]"\nlevel=warningg="[runner] Can't run linter unused buildir analysis skipped errors in package [go/golang_bad_01.go 1 1 expected 'package', found 'if' /tmp/lint/.automation/test/go/golang_bad_01.go 1 1 expected 'package', found 'if' /tmp/lint/.automation/test/go/golang_bad_01.go 1 1 expected 'package', found 'if']"\nlevel=errorg="Running error buildir analysis skipped errors in package [go/golang_bad_01.go 1 1 expected 'package', found 'if' /tmp/lint/.automation/test/go/golang_bad_01.go 1 1 expected 'package', found 'if' /tmp/lint/.automation/test/go/golang_bad_01.go 1 1 expected 'package', found 'if']"\n
|
||||
...
|
||||
ok 2 - golang_good_01.go
|
|
@ -104,6 +104,14 @@ function AddDetailedMessageIfEnabled() {
|
|||
|
||||
# Need to update the temp file and remove any non ascii characters
|
||||
cp "${TEMP_FILE}" "${TEMP_FILE}.tmp" && LC_ALL=C tr -dc '\0-\177' <"${TEMP_FILE}.tmp" >"${TEMP_FILE}" && rm "${TEMP_FILE}.tmp"
|
||||
|
||||
# Need to change all multi spaces to single space to prevent spacing inconsistancies
|
||||
sed -i 's/ \{1,\}/ /g' "${TEMP_FILE}"
|
||||
|
||||
# Need to fix the spacing on the file to meet editor config specs
|
||||
sed -i 's/^\ ---/\ \ ---/g' "${TEMP_FILE}"
|
||||
sed -i 's/^\ \.\.\./\ \ \.\.\./g' "${TEMP_FILE}"
|
||||
sed -i 's/^\ message/\ \ message/g' "${TEMP_FILE}"
|
||||
fi
|
||||
}
|
||||
################################################################################
|
||||
|
|
|
@ -333,7 +333,19 @@ function LintCodebase() {
|
|||
########################################################################
|
||||
# If expected TAP report exists then compare with the generated report #
|
||||
########################################################################
|
||||
EXPECTED_FILE="${WORKSPACE_PATH}/${INDIVIDUAL_TEST_FOLDER}/reports/expected-${FILE_TYPE}.tap"
|
||||
TAP_SUCCESS=0
|
||||
TAP_ERROR_ARRAY=()
|
||||
mapfile -t EXPECTED_FILES_ARRAY < <(
|
||||
cd "${WORKSPACE_PATH}/${INDIVIDUAL_TEST_FOLDER}/reports" || exit 1
|
||||
find . -name '*.tap' 2>&1
|
||||
)
|
||||
for EXPECTED_FILE in "${EXPECTED_FILES_ARRAY[@]}"; do
|
||||
# Remove the pathing to file name
|
||||
EXPECTED_FILE_NAME="${EXPECTED_FILE:2}"
|
||||
# Create full path
|
||||
EXPECTED_FILE="${WORKSPACE_PATH}/${INDIVIDUAL_TEST_FOLDER}/reports/${EXPECTED_FILE_NAME}"
|
||||
|
||||
# Check that file exists
|
||||
if [ -e "${EXPECTED_FILE}" ]; then
|
||||
TMPFILE=$(mktemp -q "/tmp/diff-${FILE_TYPE}.XXXXXX")
|
||||
## Ignore white spaces, case sensitive
|
||||
|
@ -341,14 +353,28 @@ function LintCodebase() {
|
|||
#############################################
|
||||
# We failed to compare the reporting output #
|
||||
#############################################
|
||||
cat "${TMPFILE}"
|
||||
fatal "Failed to assert TAP output for ${LINTER_NAME} linter"
|
||||
STRING=$(cat "${TMPFILE}")
|
||||
TAP_ERROR_ARRAY+=("${STRING}")
|
||||
TAP_ERROR_ARRAY+=("Failed to assert TAP output for ${LINTER_NAME} linter")
|
||||
else
|
||||
info "TAP output validated successfully for ${LINTER_NAME}"
|
||||
# Set flag for success
|
||||
TAP_SUCCESS=1
|
||||
fi
|
||||
else
|
||||
fatal "No TAP expected file found at:[${EXPECTED_FILE}]"
|
||||
fi
|
||||
done
|
||||
|
||||
# Need to check if the TAP_SUCCESS was set to 1
|
||||
if [ "${TAP_SUCCESS}" -ne 1 ]; then
|
||||
# We failed on all tap outputs
|
||||
error "Failed to assert TAP output!"
|
||||
for LINE in "${TAP_ERROR_ARRAY[@]}"; do
|
||||
error "${LINE}"
|
||||
done
|
||||
fatal "Failed to assert TAP output!"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
@ -360,7 +386,7 @@ function LintCodebase() {
|
|||
#################################################
|
||||
# We failed to find files and no tests were ran #
|
||||
#################################################
|
||||
error "Failed to find any tests ran for the Linter:[${LINTER_NAME}]"!
|
||||
error "Failed to find any tests ran for the Linter:[${LINTER_NAME}]!"
|
||||
fatal "Please validate logic or that tests exist!"
|
||||
fi
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue