Skip to content

Commit d6a29ea

Browse files
author
Jeremy Goldman
committed
Precommit hook added to Settings, preventing the creation of new Robolectric tests.
Test: repo upload . Change-Id: If31d79a7bf6a18f4c52692ffab4981056c14eaba
1 parent 836df5e commit d6a29ea

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

PREUPLOAD.cfg

+2
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,5 @@ checkcolor_hook = ${REPO_ROOT}/prebuilts/checkcolor/checkcolor.py -p .
44
strings_lint_hook = ${REPO_ROOT}/frameworks/base/tools/stringslint/stringslint_sha.sh ${PREUPLOAD_COMMIT}
55

66
checkstyle_hook = ${REPO_ROOT}/prebuilts/checkstyle/checkstyle.py --sha ${PREUPLOAD_COMMIT}
7+
8+
robolectric_hook = ${REPO_ROOT}/packages/apps/Settings/tests/robotests/new_tests_hook.sh ${REPO_PROJECT}

tests/robotests/new_tests_hook.sh

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/bin/bash
2+
3+
# This script detects the presence of new robolectric java tests within
4+
# commits to be uploaded. If a new file is detected the script will print an
5+
# error message and return an error code. Intended to be used as a repo hook.
6+
7+
new_robolectric_tests=$(
8+
git diff --name-status $REPO_LREV | grep "^A.*tests/robotests.*\.java")
9+
if [ $new_robolectric_tests != "" ]
10+
then
11+
echo "New Robolectric unit tests detected. Please submit junit tests" \
12+
"instead, in the tests/junit directory." \
13+
"See go/android-platform-robolectric-cleanup."
14+
echo $new_robolectric_tests
15+
exit 1
16+
fi

0 commit comments

Comments
 (0)