forked from dfinity/ic
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfind_missing_bazel_tests.sh
executable file
·42 lines (38 loc) · 1.31 KB
/
find_missing_bazel_tests.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/bin/bash
if [ $# -ne 1 ]; then
echo "USAGE: $0 [subfolder of ic/rs/]"
exit 1
fi
print_purple() {
echo -e "\033[1;35m$*\033[0m"
}
WORKSPACE_DIR=$(bazel info workspace 2>/dev/null)
SCRIPT=$(realpath "$0")
COMPARE_COVERED_TESTS="$(dirname "$SCRIPT")/compare_covered_tests.sh"
echo "**** Checking BUILD.bazel files in $WORKSPACE_DIR/rs/$1/..."
echo " using $COMPARE_COVERED_TESTS to compare covered tests."
for f in $(find $WORKSPACE_DIR/rs/$1 -name BUILD.bazel); do
CRATE_DIR="$(dirname "${f}")"
print_purple "==== checking crate $CRATE_DIR"
has_unit_tests="false"
has_integration_tests="false"
if grep -q -r -s '#[[]test[]]' $CRATE_DIR/src; then
has_unit_tests="true"
fi
if grep -q -r -s '#[[]tokio::test[]]' $CRATE_DIR/src; then
has_unit_tests="true"
fi
if grep -q -r -s '#[[]test[]]' $CRATE_DIR/tests; then
has_integration_tests="true"
fi
if grep -q -r -s '#[[]tokio::test[]]' $CRATE_DIR/tests; then
has_integration_tests="true"
fi
if [[ ($has_unit_tests == "true") || ($has_integration_tests == "true") ]]; then
echo " FOUND tests in the crate, comparing cargo and bazel coverage..."
cd $CRATE_DIR
$COMPARE_COVERED_TESTS 2>/dev/null
else
echo " no tests in the crate, skipping."
fi
done