@@ -28,10 +28,11 @@ NEW_WORKSPACE="${TEMP_DIR}/rules_rust_test_clippy"
28
28
function check_build_result() {
29
29
local ret=0
30
30
echo -n " Testing ${2} ... "
31
+
31
32
(bazel build ${@: 3} //test/clippy:" ${2} " & > /dev/null) || ret=" $? " && true
32
33
if [[ " ${ret} " -ne " ${1} " ]]; then
33
34
>&2 echo " FAIL: Unexpected return code [saw: ${ret} , want: ${1} ] building target //test/clippy:${2} "
34
- >&2 echo " Run \" bazel build //test/clippy:${2} \" to see the output"
35
+ >&2 echo " Run \" bazel build //test/clippy:${2} ${ @: 3} \" to see the output"
35
36
exit 1
36
37
elif [[ $# -ge 3 ]] && [[ " ${@: 3} " == * " capture_clippy_output" * ]]; then
37
38
# Make sure that content was written to the output file
@@ -40,10 +41,26 @@ function check_build_result() {
40
41
else
41
42
STATOPTS=(-c%s)
42
43
fi
43
- if [[ $( stat ${STATOPTS[@]} " ${NEW_WORKSPACE} /bazel-bin/test/clippy/${2% _clippy} .clippy.out" ) == 0 ]]; then
44
+ # Because bad_dep_clippy itself produces an empty report, we must check its dependencies.
45
+ if [[ " ${2} " == " bad_dep_clippy" ]]; then
46
+ # If we are traversing deps, check that the output for the dependency has been created
47
+ if [[ " ${@: 3} " == * " clippy_aspect_traverse_deps" * ]] && [[ $( stat ${STATOPTS[@]} " ${NEW_WORKSPACE} /bazel-bin/test/clippy/bad_library.clippy.out" ) == 0 ]]; then
48
+ >&2 echo " FAIL: Output of dependency bad_library wasn't written to out file building target //test/clippy:${2} "
49
+ >&2 echo " Output file: ${NEW_WORKSPACE} /bazel-bin/test/clippy/bad_library.clippy.out"
50
+ >&2 echo " Run \" bazel build //test/clippy:${2} ${@: 3} \" to see the output"
51
+ fi
52
+ if [[ -f " ${NEW_WORKSPACE} /bazel-bin/test/clippy/${2% _clippy} .clippy.out" ]]; then
53
+ >&2 echo " FAIL: Output wasn't written to out file building target //test/clippy:${2} "
54
+ >&2 echo " Output file: ${NEW_WORKSPACE} /bazel-bin/test/clippy/${2% _clippy} .clippy.out"
55
+ >&2 echo " Run \" bazel build //test/clippy:${2} ${@: 3} \" to see the output"
56
+ fi
57
+ elif [[ $( stat ${STATOPTS[@]} " ${NEW_WORKSPACE} /bazel-bin/test/clippy/${2% _clippy} .clippy.out" ) == 0 ]]; then
44
58
>&2 echo " FAIL: Output wasn't written to out file building target //test/clippy:${2} "
45
59
>&2 echo " Output file: ${NEW_WORKSPACE} /bazel-bin/test/clippy/${2% _clippy} .clippy.out"
46
- >&2 echo " Run \" bazel build //test/clippy:${2} \" to see the output"
60
+ >&2 echo " Run \" bazel build //test/clippy:${2} ${@: 3} \" to see the output"
61
+ find -L . -name " ${2% _clippy} .clippy.out"
62
+ stat ${STATOPTS[@]} " ${NEW_WORKSPACE} /bazel-bin/test/clippy/${2% _clippy} .clippy.out"
63
+
47
64
exit 1
48
65
else
49
66
echo " OK"
@@ -58,6 +75,7 @@ function test_all() {
58
75
local -r BUILD_FAILED=1
59
76
local -r CAPTURE_OUTPUT=" --@rules_rust//rust/settings:capture_clippy_output=True --@rules_rust//rust/settings:error_format=json"
60
77
local -r BAD_CLIPPY_TOML=" --@rules_rust//rust/settings:clippy.toml=//too_many_args:clippy.toml"
78
+ local -r TRAVERSE_DEPS=" --@rules_rust//rust/settings:experimental_clippy_aspect_traverse_deps=True"
61
79
62
80
mkdir -p " ${NEW_WORKSPACE} /test/clippy" && \
63
81
cp -r test/clippy/* " ${NEW_WORKSPACE} /test/clippy/" && \
105
123
check_build_result $BUILD_OK ok_proc_macro_clippy
106
124
check_build_result $BUILD_FAILED bad_binary_clippy
107
125
check_build_result $BUILD_FAILED bad_library_clippy
126
+ check_build_result $BUILD_OK bad_dep_clippy
127
+ check_build_result $BUILD_FAILED bad_dep_clippy $TRAVERSE_DEPS
108
128
check_build_result $BUILD_FAILED bad_shared_library_clippy
109
129
check_build_result $BUILD_FAILED bad_static_library_clippy
110
130
check_build_result $BUILD_FAILED bad_test_clippy
114
134
# should succeed.
115
135
check_build_result $BUILD_OK bad_binary_clippy $CAPTURE_OUTPUT
116
136
check_build_result $BUILD_OK bad_library_clippy $CAPTURE_OUTPUT
137
+ check_build_result $BUILD_OK bad_dep_clippy $CAPTURE_OUTPUT
138
+ check_build_result $BUILD_OK bad_dep_clippy $CAPTURE_OUTPUT $TRAVERSE_DEPS
117
139
check_build_result $BUILD_OK bad_shared_library_clippy $CAPTURE_OUTPUT
118
140
check_build_result $BUILD_OK bad_static_library_clippy $CAPTURE_OUTPUT
119
141
check_build_result $BUILD_OK bad_test_clippy $CAPTURE_OUTPUT
0 commit comments