Skip to content

Commit 0949089

Browse files
committed
improve ci/h2spec.sh (macOS compat, /tmp dir and overwrite)
- 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
1 parent 4d66d5d commit 0949089

File tree

1 file changed

+20
-5
lines changed

1 file changed

+20
-5
lines changed

ci/h2spec.sh

+20-5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,25 @@
11
#!/bin/bash
2-
LOGFILE="h2server.log"
2+
LOGFILE="/tmp/h2server.log"
33

4-
if ! [ -e "h2spec" ] ; then
4+
override_h2spec=false
5+
6+
# Check for optional flag
7+
while getopts "F" opt; do
8+
case $opt in
9+
F) override_h2spec=true ;;
10+
*) echo "Usage: $0 [-o]"; exit 1 ;;
11+
esac
12+
done
13+
14+
if ! [ -e "/tmp/h2spec" ] || $override_h2spec ; then
515
# if we don't already have a h2spec executable, wget it from github
6-
wget https://github.com/summerwind/h2spec/releases/download/v2.1.1/h2spec_linux_amd64.tar.gz
7-
tar xf h2spec_linux_amd64.tar.gz
16+
if [[ "$OSTYPE" == "darwin"* ]]; then
17+
curl -L -o /tmp/h2spec_darwin_amd64.tar.gz https://github.com/summerwind/h2spec/releases/download/v2.1.1/h2spec_darwin_amd64.tar.gz \
18+
&& tar xf /tmp/h2spec_darwin_amd64.tar.gz -C /tmp
19+
else
20+
curl -L -o /tmp/h2spec_linux_amd64.tar.gz https://github.com/summerwind/h2spec/releases/download/v2.1.1/h2spec_linux_amd64.tar.gz \
21+
&& tar xf /tmp/h2spec_linux_amd64.tar.gz -C /tmp
22+
fi
823
fi
924

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

1833
# run h2spec against the server, printing the server log if h2spec failed
19-
./h2spec -p 5928
34+
/tmp/h2spec -p 5928
2035
H2SPEC_STATUS=$?
2136
if [ "${H2SPEC_STATUS}" -eq 0 ]; then
2237
echo "h2spec passed!"

0 commit comments

Comments
 (0)