#!/bin/sh set -e ROOTDIR=$(cd "$(dirname "$0")" && pwd) cd "$ROOTDIR" # parse args FIX=0 CHECK=0 while [ "$1" != "" ]; do if [ "$1" = "--fix" ]; then FIX=1 elif [ "$1" = "--check" ]; then CHECK=1 fi shift done # begin check set -x tools/check_readme.sh cargo audit if [ $CHECK -eq 0 ]; then cargo fmt else cargo fmt --check fi # cargo clippy returns exit code 0 even with warnings. # However, I want to return error if exists warnings. # In addition, warnings are printed even when --fix is specified. set +e cargo clippy if [ $FIX -ne 0 ]; then cargo clippy --fix --allow-dirty > /dev/null 2>&1 fi if cargo clippy 2>&1 | grep -cE "^(error:|warning:)" > /dev/null; then exit 1 fi set -e cargo test cargo doc # cargo run --example demo