Skip to content

Commit cc045ab

Browse files
wing328stephenfin
andauthored
Fix output of bin/generate-samples.sh in tmux (#22772)
* bin/generate-samples: Remove warning about sleep The sleep itself has been commented out for a long time (commit 04fa53b from September 2023, to be specific). Signed-off-by: Stephen Finucane <stephen@that.guru> * bin/generate-samples: Fix output on tmux Commit 23dae2b reworked this script to start capturing exceptions but the mechanism used was crude and broke output on tmux, since `/dev/pts/0` is hardcoded to a specific pseudo-terminal but each tmux pane gets its own pts. Rework this to use files instead. Signed-off-by: Stephen Finucane <stephen@that.guru> * update error message, trigger build failur * trigger build failure * Revert "trigger build failure" This reverts commit 29536fa. * add back null check --------- Signed-off-by: Stephen Finucane <stephen@that.guru> Co-authored-by: Stephen Finucane <stephen@that.guru>
1 parent 29befb9 commit cc045ab

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

bin/generate-samples.sh

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -47,26 +47,26 @@ For example:
4747

4848
echo "$header"
4949

50+
tmpfile=$(mktemp)
51+
trap "rm -f $tmpfile" EXIT
52+
5053
if [[ ${#files[@]} -eq 1 && "${files[0]}" != *'*'* ]]; then
51-
# shellcheck disable=SC2086
52-
# shellcheck disable=SC2068
53-
java ${JAVA_OPTS} -jar "$executable" generate -c ${files[0]} ${args[@]}
54+
# shellcheck disable=SC2086
55+
# shellcheck disable=SC2068
56+
java ${JAVA_OPTS} -jar "$executable" generate -c ${files[0]} ${args[@]} 2>&1 | tee "$tmpfile"
57+
retcode=${PIPESTATUS[0]}
5458
else
55-
echo "Please press CTRL+C to stop or the script will continue in 5 seconds."
56-
#sleep 5
57-
if [ ${#files[@]} -eq 0 ]; then
58-
files=("${root}"/bin/configs/*.yaml)
59-
fi
59+
if [ ${#files[@]} -eq 0 ]; then
60+
files=("${root}"/bin/configs/*.yaml)
61+
fi
6062

61-
# shellcheck disable=SC2086
62-
# shellcheck disable=SC2068
63-
if java ${JAVA_OPTS} -jar "$executable" batch ${BATCH_OPTS} --includes-base-dir "${root}" --fail-fast -- ${files[@]} 2>&1 | tee /dev/pts/0 | grep -q -i "exception"; then
64-
echo "Found exception(s) when running the generator(s) to update the samples."
65-
export GENERATE_ERROR=1
66-
fi
63+
# shellcheck disable=SC2086
64+
# shellcheck disable=SC2068
65+
java ${JAVA_OPTS} -jar "$executable" batch ${BATCH_OPTS} --includes-base-dir "${root}" --fail-fast -- ${files[@]} 2>&1 | tee "$tmpfile"
66+
retcode=${PIPESTATUS[0]}
6767
fi
6868

69-
if [[ -n "$GENERATE_ERROR" ]]; then
69+
if [[ $retcode -ne 0 ]] || grep -q -i "at org.openapitools" "$tmpfile"; then
7070
echo "Found exception(s) when running the generator(s) to update the samples."
7171
exit 1
7272
fi

0 commit comments

Comments
 (0)