Skip to content

Commit c72359c

Browse files
celinvaltedinski
authored andcommitted
Replace ./x.py fmt by kani-fmt script (rust-lang#761)
This is part of rust-lang#641
1 parent 5aa0089 commit c72359c

File tree

5 files changed

+51
-3
lines changed

5 files changed

+51
-3
lines changed
File renamed without changes.

scripts/kani-fmt.sh

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#!/usr/bin/env bash
2+
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
# SPDX-License-Identifier: Apache-2.0 OR MIT
4+
#
5+
# Runs `rustfmt` in our source crates and tests.
6+
# The arguments given to this script are passed to rustfmt.
7+
set -o errexit
8+
set -o pipefail
9+
set -o nounset
10+
11+
# Run from the repository root folder
12+
ROOT_FOLDER=$(git rev-parse --show-toplevel)
13+
cd ${ROOT_FOLDER}
14+
15+
# Verify crates.
16+
# TODO: We should be able to use workspace once we unfork from rustc.
17+
# https://github.com/model-checking/rmc/issues/719
18+
CRATES=(
19+
"bookrunner"
20+
"cbmc"
21+
"compiletest"
22+
"kani-compiler"
23+
"kani"
24+
"kani_macros"
25+
"kani_queries"
26+
"kani_restrictions"
27+
"rustc_codegen_kani"
28+
)
29+
30+
error=0
31+
for crate in ${CRATES[@]}; do
32+
# Check all crates. Only fail at the end.
33+
cargo fmt $@ -p ${crate} || error=1
34+
done
35+
36+
# Check test source files.
37+
TESTS=("src/test/kani"
38+
"src/test/prusti"
39+
"src/test/smack"
40+
"src/test/expected"
41+
"src/test/cargo-kani"
42+
"kani-docs/src/tutorial")
43+
44+
for suite in "${TESTS[@]}"; do
45+
files=$(find "${suite}" -name "*.rs")
46+
rustfmt --unstable-features $@ ${files} || error=1
47+
done
48+
49+
exit $error

scripts/kani-regression.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ check-cbmc-version.py --major 5 --minor 48
2828
check-cbmc-viewer-version.py --major 2 --minor 5
2929

3030
# Formatting check
31-
./x.py fmt --check
31+
${SCRIPT_DIR}/kani-fmt.sh --check
3232

3333
# Build Kani compiler and Kani library
3434
(cd "${KANI_DIR}/src/kani-compiler"; cargo build)

scripts/std-lib-regression.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ cargo new std_lib_test --lib
4040
cd std_lib_test
4141

4242
# Use same nightly toolchain used to build Kani
43-
cp ${KANI_DIR}/src/kani-compiler/rust-toolchain.toml .
43+
cp ${KANI_DIR}/rust-toolchain.toml .
4444

4545
echo "Starting cargo build with Kani"
4646
export RUSTC_LOG=error

src/tools/compiletest/rust-toolchain.toml

-1
This file was deleted.

0 commit comments

Comments
 (0)