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,64 @@ 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
69
+ # shellcheck is complaining that `$test_args` can be interpreted as multiple arguments
70
+ # in case it contains whitespace characters... which is exactly what we want.
71
+ # shellcheck disable=SC2086
73
72
cargo test $test_args
74
- if [[ $? != 0 ]]; then
75
- return $?
73
+ cargo_ret=$?
74
+ if [[ $cargo_ret != 0 ]]; then
75
+ return $cargo_ret
76
76
fi
77
77
}
78
78
79
79
function show_head {
80
- local head=$( git rev-parse HEAD)
80
+ local head
81
+ head=$( git rev-parse HEAD)
81
82
echo " Head commit of ${INTEGRATION} : $head "
82
83
}
83
84
84
85
case ${INTEGRATION} in
85
86
cargo)
86
- git clone --depth=1 https://github.com/rust-lang/${INTEGRATION} .git
87
- cd ${INTEGRATION}
87
+ git clone --depth=1 " https://github.com/rust-lang/${INTEGRATION} .git"
88
+ cd " ${INTEGRATION} "
88
89
show_head
89
90
export CFG_DISABLE_CROSS_TESTS=1
90
91
check_fmt_with_all_tests
91
92
cd -
92
93
;;
93
94
crater)
94
- git clone --depth=1 https://github.com/rust-lang/${INTEGRATION} .git
95
- cd ${INTEGRATION}
95
+ git clone --depth=1 " https://github.com/rust-lang/${INTEGRATION} .git"
96
+ cd " ${INTEGRATION} "
96
97
show_head
97
98
check_fmt_with_lib_tests
98
99
cd -
99
100
;;
100
101
bitflags)
101
- git clone --depth=1 https://github.com/bitflags/${INTEGRATION} .git
102
- cd ${INTEGRATION}
102
+ git clone --depth=1 " https://github.com/bitflags/${INTEGRATION} .git"
103
+ cd " ${INTEGRATION} "
103
104
show_head
104
105
check_fmt_with_all_tests
105
106
cd -
106
107
;;
107
108
tempdir)
108
- git clone --depth=1 https://github.com/rust-lang-deprecated/${INTEGRATION} .git
109
- cd ${INTEGRATION}
109
+ git clone --depth=1 " https://github.com/rust-lang-deprecated/${INTEGRATION} .git"
110
+ cd " ${INTEGRATION} "
110
111
show_head
111
112
check_fmt_with_all_tests
112
113
cd -
113
114
;;
114
115
* )
115
- git clone --depth=1 https://github.com/rust-lang/${INTEGRATION} .git
116
- cd ${INTEGRATION}
116
+ git clone --depth=1 " https://github.com/rust-lang/${INTEGRATION} .git"
117
+ cd " ${INTEGRATION} "
117
118
show_head
118
119
check_fmt_with_all_tests
119
120
cd -
0 commit comments