SED=$(command -v gsed || command -v sed)
if [ -z "$SED" ]; then
echo "This program requires sed"
exit 1
fi
usage() {
echo "Usage: $0 [enable|disable|test|run <cmd>]"
echo ""
echo " enable: Enable property tests by removing comments in Cargo.toml & build.rs"
echo " disable: Restore property-tests comments in Cargo.toml & build.rs"
echo " test: Runs 'cargo test' between enabling & disabling property tests"
echo "run <cmd>: Run user supplied command <cmd> between enabling & disabling property tests"
}
enable_property_tests() {
${SED} -i.bak -e 's|# PROPERTY-TESTS: ||' Cargo.toml
${SED} -i.bak -e 's|// ::PROPERTY-TESTS:: ||' build.rs
}
restore_disabled_property_tests() {
mv Cargo.toml.bak Cargo.toml
mv build.rs.bak build.rs
touch build.rs
}
DEFAULT_CMD=help
CMD=${1:-$DEFAULT_CMD}
shift
case "${CMD}" in
run)
enable_property_tests
"$@"
restore_disabled_property_tests
;;
test)
enable_property_tests
cargo test "$@"
restore_disabled_property_tests
;;
enable)
enable_property_tests
;;
disable)
restore_disabled_property_tests
;;
*)
usage
;;
esac