1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125
|
#!/usr/bin/env bash
set -eo pipefail
borderTop() {
echo
echo "========================================================================================================================="
}
borderBottom() {
echo "========================================================================================================================="
echo
}
WINDOWS_VERSION=${WINDOWS_VERSION:-servercore1809}
testOutputDir="./.testoutput"
windowsTestOutputPattern="${testOutputDir}/*/*.windows.${WINDOWS_VERSION}.output.txt"
trackedFailuresFile="./ci/.test-failures.${WINDOWS_VERSION}.txt"
if [[ ! -f "${trackedFailuresFile}" ]]; then
echo "${trackedFailuresFile} not found, creating empty file"
touch "${trackedFailuresFile}"
fi
trackedFailuresCount=$(wc -l < "${trackedFailuresFile}")
existingFailures=()
newFailures=()
for file in ${windowsTestOutputPattern}; do
for failure in $(iconv -f utf-16 -t utf-8 "$file" | grep -Eo "\\--- FAIL: [^ ]+" | awk '{print $3}'); do
if grep "^${failure}$" "${trackedFailuresFile}" >/dev/null 2>&1; then
existingFailures+=("${failure}")
else
newFailures+=("${failure}")
fi
done
done
existingFailuresCount=${#existingFailures[@]}
newFailuresCount=${#newFailures[@]}
fixedFailuresCount=$((trackedFailuresCount - existingFailuresCount))
borderTop
echo " Tracked failures: ${trackedFailuresCount}"
echo " Existing failures: ${existingFailuresCount}"
echo " New failures: ${newFailuresCount}"
echo " Fixed (?) failures: ${fixedFailuresCount}"
borderBottom
if [[ ${fixedFailuresCount} -gt -0 ]]; then
tmpFile="$(mktemp)"
updatedTrackedFailuresFile="${trackedFailuresFile}.updated"
touch "${updatedTrackedFailuresFile}"
cp "${trackedFailuresFile}" "${tmpFile}"
for failure in "${existingFailures[@]}"; do
echo "${failure}" >> "${updatedTrackedFailuresFile}"
grep -v "^${failure}$" "${tmpFile}" > "${tmpFile}.new"
mv "${tmpFile}.new" "${tmpFile}"
done
borderTop
echo " Tests that were probably fixed:"
echo
while read -r file; do
echo " - ${file}"
done < "${tmpFile}"
echo
echo " Please consider updating the tracked failures file"
echo " Updated version saved as artifact: ${updatedTrackedFailuresFile}"
borderBottom
rm "${tmpFile}"
fi
if [[ ${newFailuresCount} -gt 0 ]]; then
borderTop
echo " Windows tests created new failures:"
echo
for failure in "${newFailures[@]}"; do
echo " - ${failure}"
done
echo
echo " Please fix the new failures detected."
echo " This job will not pass until it's done."
borderBottom
exit 1
fi
if [[ ${existingFailuresCount} -eq 0 ]]; then
borderTop
echo " All tests are fixed! Good job!"
echo " You can now update .gitlab-ci.yml file and remove this CI job."
borderBottom
exit 0
fi
if [[ ${fixedFailuresCount} -gt 0 ]]; then
borderTop
echo " It looks like you've fixed some Windows failures (probably)."
echo " KEEP GOING!"
borderBottom
exit 0
fi
borderTop
echo " It's not worse. But it could be better!"
echo " If you want to have some fun, chose one of the Windows"
echo " test failures and try to fix it!"
echo " And remember: Developers! Developers! Developers!"
borderBottom
|