forked from model-checking/kani
-
Notifications
You must be signed in to change notification settings - Fork 0
/
kani-fmt.sh
executable file
·37 lines (31 loc) · 1.07 KB
/
kani-fmt.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/usr/bin/env bash
# Copyright Kani Contributors
# SPDX-License-Identifier: Apache-2.0 OR MIT
#
# Runs `rustfmt` in our source crates and tests.
# The arguments given to this script are passed to rustfmt.
set -o errexit
set -o pipefail
set -o nounset
# Run from the repository root folder
ROOT_FOLDER=$(git rev-parse --show-toplevel)
cd ${ROOT_FOLDER}
# Verify crates.
error=0
# Check all crates. Only fail at the end.
cargo fmt "$@" || error=1
# Check test source files.
# Note that this will respect the ignore section of rustfmt.toml. If you need to
# skip any file / directory, add it there.
TESTS=("tests" "docs/src/tutorial")
for suite in "${TESTS[@]}"; do
# Find uses breakline to split between files. This ensures that we can
# handle files with space in their path.
set -f; IFS=$'\n'
files=($(find "${suite}" -name "*.rs"))
set +f; unset IFS
# Note: We set the configuration file here because some submodules have
# their own configuration file.
rustfmt --unstable-features "$@" --config-path rustfmt.toml "${files[@]}" || error=1
done
exit $error