Skip to content

Commit

Permalink
Replace ./x.py fmt by kani-fmt script (rust-lang#761)
Browse files Browse the repository at this point in the history
This is part of rust-lang#641
  • Loading branch information
celinval authored and tedinski committed Jan 20, 2022
1 parent 5aa0089 commit c72359c
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 3 deletions.
File renamed without changes.
49 changes: 49 additions & 0 deletions scripts/kani-fmt.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#!/usr/bin/env bash
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# 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.
# TODO: We should be able to use workspace once we unfork from rustc.
# https://github.com/model-checking/rmc/issues/719
CRATES=(
"bookrunner"
"cbmc"
"compiletest"
"kani-compiler"
"kani"
"kani_macros"
"kani_queries"
"kani_restrictions"
"rustc_codegen_kani"
)

error=0
for crate in ${CRATES[@]}; do
# Check all crates. Only fail at the end.
cargo fmt $@ -p ${crate} || error=1
done

# Check test source files.
TESTS=("src/test/kani"
"src/test/prusti"
"src/test/smack"
"src/test/expected"
"src/test/cargo-kani"
"kani-docs/src/tutorial")

for suite in "${TESTS[@]}"; do
files=$(find "${suite}" -name "*.rs")
rustfmt --unstable-features $@ ${files} || error=1
done

exit $error
2 changes: 1 addition & 1 deletion scripts/kani-regression.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ check-cbmc-version.py --major 5 --minor 48
check-cbmc-viewer-version.py --major 2 --minor 5

# Formatting check
./x.py fmt --check
${SCRIPT_DIR}/kani-fmt.sh --check

# Build Kani compiler and Kani library
(cd "${KANI_DIR}/src/kani-compiler"; cargo build)
Expand Down
2 changes: 1 addition & 1 deletion scripts/std-lib-regression.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ cargo new std_lib_test --lib
cd std_lib_test

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

echo "Starting cargo build with Kani"
export RUSTC_LOG=error
Expand Down
1 change: 0 additions & 1 deletion src/tools/compiletest/rust-toolchain.toml

This file was deleted.

0 comments on commit c72359c

Please sign in to comment.