2
2
3
3
set -ex
4
4
5
- : ${INTEGRATION?" The INTEGRATION environment variable must be set." }
5
+ : " ${INTEGRATION?' The INTEGRATION environment variable must be set.' } "
6
6
7
7
# FIXME: this means we can get a stale cargo-fmt from a previous run.
8
8
#
@@ -42,8 +42,12 @@ function check_fmt_with_lib_tests {
42
42
43
43
function check_fmt_base {
44
44
local test_args=" $1 "
45
- local build=$( cargo test $test_args 2>&1 )
46
- if [[ " $build " =~ " build failed" ]] || [[ " $build " =~ " test result: FAILED." ]]; then
45
+ local build
46
+ # shellcheck is complaining that `$test_args` can be interpreted as multiple arguments
47
+ # in case it contains whitespace characters... which is exactly what we want.
48
+ # shellcheck disable=SC2086
49
+ build=$( cargo test $test_args 2>&1 )
50
+ if [[ " $build " =~ " build failed" ]] || [[ " $build " =~ test\ result\:\ FAILED\. ]]; then
47
51
return 0
48
52
fi
49
53
touch rustfmt.toml
@@ -53,67 +57,61 @@ function check_fmt_base {
53
57
return 1
54
58
fi
55
59
cat rustfmt_output
56
- ! cat rustfmt_output | grep -q " internal error"
57
- if [[ $? != 0 ]]; then
58
- return 1
59
- fi
60
- ! cat rustfmt_output | grep -q " warning"
61
- if [[ $? != 0 ]]; then
62
- return 1
63
- fi
64
- ! cat rustfmt_output | grep -q " Warning"
65
- if [[ $? != 0 ]]; then
66
- return 1
67
- fi
60
+ grep -q " internal error" < rustfmt_output && return 1
61
+ grep -q " warning" < rustfmt_output && return 1
62
+ grep -q " Warning" < rustfmt_output && return 1
63
+
68
64
cargo fmt --all -- --check | & tee rustfmt_check_output
69
65
if [[ ${PIPESTATUS[0]} != 0 ]]; then
70
66
cat rustfmt_check_output
71
67
return 1
72
68
fi
73
- cargo test $test_args
74
- if [[ $? != 0 ]]; then
75
- return $?
69
+ cargo test " $test_args "
70
+ cargo_ret=$?
71
+ if [[ $cargo_ret != 0 ]]; then
72
+ return $cargo_ret
76
73
fi
77
74
}
78
75
79
76
function show_head {
80
- local head=$( git rev-parse HEAD)
77
+ local head
78
+ head=$( git rev-parse HEAD)
81
79
echo " Head commit of ${INTEGRATION} : $head "
82
80
}
83
81
84
82
case ${INTEGRATION} in
85
83
cargo)
86
- git clone --depth=1 https://github.com/rust-lang/${INTEGRATION} .git
87
- cd ${INTEGRATION}
84
+ git clone --depth=1 " https://github.com/rust-lang/${INTEGRATION} .git"
85
+ cd " ${INTEGRATION} "
88
86
show_head
89
87
export CFG_DISABLE_CROSS_TESTS=1
90
88
check_fmt_with_all_tests
91
89
cd -
92
90
;;
93
91
crater)
94
- git clone --depth=1 https://github.com/rust-lang/${INTEGRATION} .git
95
- cd ${INTEGRATION}
92
+ git clone --depth=1 " https://github.com/rust-lang/${INTEGRATION} .git"
93
+ cd " ${INTEGRATION} "
96
94
show_head
97
95
check_fmt_with_lib_tests
98
96
cd -
99
97
;;
100
98
bitflags)
101
- git clone --depth=1 https://github.com/bitflags/${INTEGRATION} .git
102
- cd ${INTEGRATION}
99
+ git clone --depth=1 " https://github.com/bitflags/${INTEGRATION} .git"
100
+ cd " ${INTEGRATION} "
103
101
show_head
104
102
check_fmt_with_all_tests
105
103
cd -
106
104
;;
107
105
tempdir)
108
- git clone --depth=1 https://github.com/rust-lang-deprecated/${INTEGRATION} .git
109
- cd ${INTEGRATION}
106
+ git clone --depth=1 " https://github.com/rust-lang-deprecated/${INTEGRATION} .git"
107
+ cd " ${INTEGRATION} "
110
108
show_head
111
109
check_fmt_with_all_tests
112
110
cd -
113
111
;;
114
112
* )
115
- git clone --depth=1 https://github.com/rust-lang/${INTEGRATION} .git
116
- cd ${INTEGRATION}
113
+ git clone --depth=1 " https://github.com/rust-lang/${INTEGRATION} .git"
114
+ cd " ${INTEGRATION} "
117
115
show_head
118
116
check_fmt_with_all_tests
119
117
cd -
0 commit comments