Files
wasmtime/check-rustfmt.sh
Jakob Stoklund Olesen 40488c8e22 Install rustfmt as a separate Travis install step.
- Add a check-rustfmt.sh script which checks if the right version of
  rustfmt is installed.
- Run check-rustfmt.sh --install as an install step under travis_wait.

This is to work around the issue where cargo takes forever to build
rustfmt, causing Travis to terminate the build because it hasn't
produced any output for 10 minutes.
2017-04-27 13:55:13 -07:00

36 lines
1.2 KiB
Bash
Executable File

#!/bin/bash
#
# Usage: check-rustfmt.sh [--install]
#
# Check that the desired version of rustfmt is installed.
#
# Rustfmt is still immature enough that its formatting decisions can change
# between versions. This makes it difficult to enforce a certain style in a
# test script since not all developers will upgrade rustfmt at the same time.
# To work around this, we only verify formatting when a specific version of
# rustfmt is installed.
#
# Exits 0 if the right version of rustfmt is installed, 1 otherwise.
#
# With the --install option, also tries to install the right version.
# This version should always be bumped to the newest version available.
VERS="0.8.3"
if cargo install --list | grep -q "^rustfmt v$VERS"; then
exit 0
fi
if [ "$1" != "--install" ]; then
echo "********************************************************************"
echo "* Please install rustfmt v$VERS to verify formatting. *"
echo "* If a newer version of rustfmt is available, update this script. *"
echo "********************************************************************"
echo "$0 --install"
sleep 1
exit 1
fi
echo "Installing rustfmt v$VERS."
cargo install --force --vers="$VERS" rustfmt