Skip to content

Commit

Permalink
improve ci/h2spec.sh (macOS compat, /tmp dir and overwrite) (#809)
Browse files Browse the repository at this point in the history
- detect if run on MacOS, so we download h2spec macos build in that case
- support overwriting h2spec detection so we anyway download new file,
  useful in case you switch to new version for example
- move h2spec, archive and log all to /tmp dir as to not polute
  the repo dir
  • Loading branch information
GlenDC authored Nov 4, 2024
1 parent 4d66d5d commit 848885b
Showing 1 changed file with 20 additions and 5 deletions.
25 changes: 20 additions & 5 deletions ci/h2spec.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,25 @@
#!/bin/bash
LOGFILE="h2server.log"
LOGFILE="/tmp/h2server.log"

if ! [ -e "h2spec" ] ; then
override_h2spec=false

# Check for optional flag
while getopts "F" opt; do
case $opt in
F) override_h2spec=true ;;
*) echo "Usage: $0 [-o]"; exit 1 ;;
esac
done

if ! [ -e "/tmp/h2spec" ] || $override_h2spec ; then
# if we don't already have a h2spec executable, wget it from github
wget https://github.com/summerwind/h2spec/releases/download/v2.1.1/h2spec_linux_amd64.tar.gz
tar xf h2spec_linux_amd64.tar.gz
if [[ "$OSTYPE" == "darwin"* ]]; then
curl -L -o /tmp/h2spec_darwin_amd64.tar.gz https://github.com/summerwind/h2spec/releases/download/v2.1.1/h2spec_darwin_amd64.tar.gz \
&& tar xf /tmp/h2spec_darwin_amd64.tar.gz -C /tmp
else
curl -L -o /tmp/h2spec_linux_amd64.tar.gz https://github.com/summerwind/h2spec/releases/download/v2.1.1/h2spec_linux_amd64.tar.gz \
&& tar xf /tmp/h2spec_linux_amd64.tar.gz -C /tmp
fi
fi

cargo build --example server
Expand All @@ -16,7 +31,7 @@ SERVER_PID=$!
sed '/listening on Ok(127.0.0.1:5928)/q' <&3 ; cat <&3 > "${LOGFILE}" &

# run h2spec against the server, printing the server log if h2spec failed
./h2spec -p 5928
/tmp/h2spec -p 5928
H2SPEC_STATUS=$?
if [ "${H2SPEC_STATUS}" -eq 0 ]; then
echo "h2spec passed!"
Expand Down

0 comments on commit 848885b

Please sign in to comment.