Skip to content

Commit d9ec642

Browse files
authored
Add missing test folders to fmt script (#1459)
1 parent b0aeb2b commit d9ec642

File tree

19 files changed

+32
-45
lines changed

19 files changed

+32
-45
lines changed

rustfmt.toml

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,12 @@ use_small_heuristics = "Max"
88
merge_derives = false
99

1010
ignore = [
11-
"/build/",
12-
"/*-build/",
13-
"/build-*/",
14-
"/vendor/",
15-
"/target/",
11+
"**/build/",
12+
"**/target/",
1613

17-
# do not format submodules
18-
"firecracker",
19-
"tests/perf/s2n-quic",
20-
"tools/bookrunner/rust-doc/nomicon",
21-
"tools/bookrunner/rust-doc/reference",
22-
"tools/bookrunner/rust-doc/rust-by-example"
14+
# Do not format submodules
15+
# For some reason, this is not working without the directory wildcard.
16+
"**/firecracker",
17+
"**/tests/perf/s2n-quic/",
18+
"**/tools/bookrunner/rust-doc/",
2319
]

scripts/kani-fmt.sh

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,19 @@ error=0
1919
cargo fmt "$@" || error=1
2020

2121
# Check test source files.
22-
TESTS=("tests/kani"
23-
"tests/prusti"
24-
"tests/smack"
25-
"tests/expected"
26-
"tests/cargo-kani"
27-
"docs/src/tutorial")
22+
# Note that this will respect the ignore section of rustfmt.toml. If you need to
23+
# skip any file / directory, add it there.
24+
TESTS=("tests" "docs/src/tutorial")
2825

2926
for suite in "${TESTS[@]}"; do
3027
# Find uses breakline to split between files. This ensures that we can
3128
# handle files with space in their path.
3229
set -f; IFS=$'\n'
3330
files=($(find "${suite}" -name "*.rs"))
3431
set +f; unset IFS
35-
rustfmt --unstable-features "$@" "${files[@]}" || error=1
32+
# Note: We set the configuration file here because some submodules have
33+
# their own configuration file.
34+
rustfmt --unstable-features "$@" --config-path rustfmt.toml "${files[@]}" || error=1
3635
done
3736

3837
exit $error

tests/cargo-ui/dry-run/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@
77
88
#[kani::proof]
99
pub fn broken_harness() {
10-
let invalid: Nope = Nope{};
10+
let invalid: Nope = Nope {};
1111
}

tests/firecracker/micro-http-parsed-request/ignore-main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
// Should return a nondet string of up to n characters
77
// Currently Kani does not support strings
8-
fn kani::any_string(n: u32) -> String {
8+
fn any_string(n: u32) -> String {
99
unimplemented!()
1010
}
1111

tests/kani-dependency-test/dependency3/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ pub struct Foo {
55
x: i32,
66
}
77

8-
// Export a function that takes a struct type which differs between this crate
8+
// Export a function that takes a struct type which differs between this crate
99
// and the other vesion
1010
pub fn take_foo(foo: &Foo) -> i32 {
1111
foo.x
@@ -18,8 +18,8 @@ pub fn give_foo() -> Foo {
1818
pub fn get_int() -> i32 {
1919
// Use a constant to force an MIR GlobalAllocation::Memory.
2020
// Use a non-i32 so there will be a conflict between this
21-
// version and the other version. The constant is also a
21+
// version and the other version. The constant is also a
2222
// different value than the other version of this dependency.
2323
let one = &(1 as i8);
24-
return *one as i32
24+
return *one as i32;
2525
}

tests/kani-dependency-test/diamond-dependency/dependency3/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ pub struct Foo {
77
y: i32,
88
}
99

10-
// Export a function that takes a struct type which differs between this crate
10+
// Export a function that takes a struct type which differs between this crate
1111
// and the other vesion.
1212
pub fn take_foo(foo: &Foo) -> i32 {
1313
foo.x + foo.y
@@ -20,5 +20,5 @@ pub fn give_foo() -> Foo {
2020
pub fn get_int() -> i32 {
2121
// Use a constant to force an MIR GlobalAllocation::Memory
2222
let zero = &0;
23-
return *zero
23+
return *zero;
2424
}

tests/perf/kani-lib/arbitrary/src/check_arbitrary.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ fn check_any_char() {
2222
#[kani::proof]
2323
#[kani::unwind(101)]
2424
fn check_any_char_array() {
25-
let arr : [char; 100] = kani::any();
25+
let arr: [char; 100] = kani::any();
2626
for i in 0..100 {
2727
let c = arr[i];
2828
let n = c as u32;
@@ -33,7 +33,7 @@ fn check_any_char_array() {
3333
#[kani::proof]
3434
#[kani::unwind(101)]
3535
fn check_any_usize_array() {
36-
let arr : [usize; 100] = kani::any();
36+
let arr: [usize; 100] = kani::any();
3737
for i in 0..100 {
3838
let us = arr[i];
3939
kani::assume(us < 100);
@@ -46,7 +46,7 @@ fn check_any_usize_option() {
4646
let mut all_none = true;
4747
let mut all_some = true;
4848
for _ in 0..100 {
49-
let us : Option::<usize> = kani::any();
49+
let us: Option<usize> = kani::any();
5050
all_none &= us.is_none();
5151
all_some &= us.is_some();
5252
}
@@ -59,7 +59,7 @@ fn check_any_usize_result() {
5959
let mut all_ok = true;
6060
let mut all_err = true;
6161
for _ in 0..100 {
62-
let us : Result::<usize, isize> = kani::any();
62+
let us: Result<usize, isize> = kani::any();
6363
all_ok &= us.is_ok();
6464
all_err &= us.is_err();
6565
}
@@ -72,7 +72,7 @@ fn check_any_bool() {
7272
let mut all_true = true;
7373
let mut all_false = true;
7474
for _ in 0..100 {
75-
let val : bool = kani::any();
75+
let val: bool = kani::any();
7676
all_true &= val;
7777
all_false &= !val;
7878
}

tests/stub-tests/Vec/append.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ fn main() {
66
let mut vec = kani_vec![1, 2, 3];
77
let mut vec2 = kani_vec![4, 5, 6];
88
vec.append(&mut vec2);
9-
assert!(vec == [1, 2, 3, 4, 5, 6]);
9+
assert!(vec == [1, 2, 3, 4, 5, 6]);
1010
assert!(vec2 == []);
1111
}
1212

tests/stub-tests/Vec/drop.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
static mut GLOB: i32 = 1;
66

77
struct Test {
8-
_marker: u32
8+
_marker: u32,
99
}
1010

1111
impl Drop for Test {

tests/stub-tests/Vec/into_iter.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ fn main() {
1010
assert!(iter.next() == Some(4));
1111
assert!(iter.next() == Some(5));
1212
assert!(iter.next() == None);
13-
1413
}
1514

1615
into_iter_test();

0 commit comments

Comments
 (0)