githooks: make the test runner run on presubmits

Also renames a few things for clarity.

BUG=None
TEST=repo upload

Change-Id: I7fec9cc90be7cea7dac69aae61942ebdd8868247
Reviewed-on: https://chromium-review.googlesource.com/1544903
Commit-Ready: George Burgess <gbiv@chromium.org>
Tested-by: George Burgess <gbiv@chromium.org>
Reviewed-by: George Burgess <gbiv@chromium.org>
diff --git a/PRESUBMIT.cfg b/PRESUBMIT.cfg
index 81f5561..d69d375 100644
--- a/PRESUBMIT.cfg
+++ b/PRESUBMIT.cfg
@@ -1,2 +1,2 @@
 [Hook Scripts]
-check_tc_patch_style = ./toolchain_utils_githooks/check-style ${PRESUBMIT_FILES}
+toolchain_utils_presubmits = ./toolchain_utils_githooks/check-presubmit ${PRESUBMIT_FILES}
diff --git a/toolchain_utils_githooks/check-style b/toolchain_utils_githooks/check-presubmit
similarity index 95%
rename from toolchain_utils_githooks/check-style
rename to toolchain_utils_githooks/check-presubmit
index c844b1e..e67611f 100755
--- a/toolchain_utils_githooks/check-style
+++ b/toolchain_utils_githooks/check-presubmit
@@ -41,6 +41,7 @@
 
 spawn_child "${mydir}/check-lint" "$@"
 spawn_child "${mydir}/check-format" "$@"
+spawn_child "${mydir}/../run_tests_for.py" "$@"
 
 success=true
 for i in "${!child_pids[@]}"; do
diff --git a/toolchain_utils_githooks/pre-push.real b/toolchain_utils_githooks/pre-push.real
index c05a35b..06aa621 100755
--- a/toolchain_utils_githooks/pre-push.real
+++ b/toolchain_utils_githooks/pre-push.real
@@ -9,29 +9,6 @@
 
 mydir="$(dirname "$(readlink -m "$0")")"
 
-# This redirects stdin. Make sure to run after stdin has been read.
-run_UnitTests() {
-  save_dir=$(pwd)
-  status=0
-  valid=0
-
-  # Make sure we can read the stdin from terminal
-  exec < /dev/tty
-
-  while [[ $valid -eq 0 ]] ; do
-    read -p "Run unit tests? [y/n] " choice
-    case "$choice" in
-      n|N ) valid=1 ;;
-      y|Y ) valid=1; cd crosperf; ./run_tests.sh; status=$? ;
-        cd $save_dir;;
-      * ) echo "Must choose y or n."
-    esac
-  done
-  if [[ $status -ne 0 ]]; then
-    exit $status
-  fi
-}
-
 z40=0000000000000000000000000000000000000000
 
 while IFS=' ' read local_ref local_sha remote_ref remote_sha; do
@@ -46,10 +23,8 @@
     all_files="$(git show --pretty="format:" --name-only "${range}")"
     # Note that ${all_files} may include files that were deleted. Hence, we
     # ignore any complaints about missing files.
-    IGNORE_MISSING=1 "${mydir}/check-style" ${all_files} || exit 1
+    IGNORE_MISSING=1 "${mydir}/check-presubmit" ${all_files} || exit 1
   fi
 done
 
-run_UnitTests
-
 exit 0