Check the output status of gogenerate.sh

This is because it may fail if the codegen tools are not found.

If failed, skip the status compare step because it may as well return a
false positive, i.e. generated code is not up to date but the codegen
tool to bring it up to date was not found so no diff was detected.
pull/520/head
Eugene Kim 6 years ago
parent 413ae2fd1e
commit 1863111998
  1. 23
      scripts/travis_checker.sh

@ -52,16 +52,25 @@ echo "Running go generate..."
gogenerate_status_before="${tmpdir}/gogenerate_status_before.txt"
gogenerate_status_after="${tmpdir}/gogenerate_status_after.txt"
gogenerate_status_diff="${tmpdir}/gogenerate_status.diff"
gogenerate_output="${tmpdir}/gogenerate_output.txt"
git status --porcelain=v2 > "${gogenerate_status_before}"
"${progdir}/gogenerate.sh"
git status --porcelain=v2 > "${gogenerate_status_after}"
if diff -u "${gogenerate_status_before}" "${gogenerate_status_after}" \
> "${gogenerate_status_diff}"
if "${progdir}/gogenerate.sh" > "${gogenerate_output}" 2>&1
then
echo "go generate succeeded; all generated files seem up to date."
echo "go generate succeeded."
echo "Checking if go generate changed any files..."
git status --porcelain=v2 > "${gogenerate_status_after}"
if diff -u "${gogenerate_status_before}" "${gogenerate_status_after}" \
> "${gogenerate_status_diff}"
then
echo "All generated files seem up to date."
else
echo "go generate changed working tree contents!"
"${progdir}/print_file.sh" "${gogenerate_status_diff}" "git status diff"
ok=false
fi
else
echo "go generate changed working tree contents!"
"${progdir}/print_file.sh" "${gogenerate_status_diff}" "git status diff"
echo "go generate FAILED!"
"${progdir}/print_file.sh" "${gogenerate_output}" "go generate"
ok=false
fi

Loading…
Cancel
Save