aboutsummaryrefslogtreecommitdiff
path: root/toolchain_utils_githooks
diff options
context:
space:
mode:
authorGeorge Burgess IV <gbiv@google.com>2019-04-01 23:42:29 -0700
committerchrome-bot <chrome-bot@chromium.org>2019-04-05 13:43:53 -0700
commit9d74464d52b2d917e3fcf69aa472cf7cf0d2edb1 (patch)
treed006cdab7b113906a334c5f2f79beb5e0d6700a2 /toolchain_utils_githooks
parent449a4a13b88ceeb439dddae9e0b142f784c8f166 (diff)
downloadtoolchain-utils-9d74464d52b2d917e3fcf69aa472cf7cf0d2edb1.tar.gz
crosperf: make run_tests use our new test runner
This is three small changes in one. The main attraction is no functional change. The benefits we see are: A. less cluttered output B. total wall time of test running is down from 18s to 13s on my machine, since the test runner spawns all tests in parallel The second change is that we now set PYTHONPATH for linting. Otherwise, we'll see errors about bad imports. Finally, this fixes a test. It appears that the parameters of this assertRaises function have been accidentally flipped, though that works without issue outside of the chroot. To understand why, consider that assertRaises has two forms that act completely differently: self.assertRaises(Exception, foo) Which causes self.assertRaises to run foo(), and expect that foo() raises an Exception. Additionally, it can be used like so: with self.assertRaises(Exception): foo() Which causes assertRaises to intercept any Exception that the block under it may throw. The difference between the in-chroot and out-of-chroot Python is simple: outside of the chroot, the default value for the second arg to assertRaises -- not counting `self` -- is None. Inside of the chroot, they have a special, hidden sentinel value that it defaults to. So, *outside* of the chroot, `self.assertRaises(Exception)` is equivalent to `self.assertRaises(Exception, None)`, so the latter returns a context object that tries to catch an exception. Inside of the chroot, `self.assertRaises(Exception, None)` is not equivalent to `self.assertRaises(Exception)`, and `None` is called as though it was a function. Since the removed code was `self.assertRaises(foo, None)`, outside of the chroot, we'd just be returned a context object that we dropped on the floor. Inside of the chroot, `self.assertRaises(foo, None)` would try to call `None()`, fail, then try to say `issubclass(exception_that_calling_none_raised, foo)`, but foo is a function, so `issubclass` would raise on its own. For those keeping score at home, the chroot's behavior was introduced in upstream Python in 7f71e04cb510c24be337a22350324dc8a28e9775, which landed in the 2.7.10 release. It wasn't until 2.7.11 that the revert 049060c249a83b69c4841ed37b7f4303f9ad7dd7 took effect. For more, the bug was https://bugs.python.org/issue24134 BUG=None TEST=./run_tests.sh Change-Id: I58c398caafde03242ed3ca7530bf9a819fae99e2 Reviewed-on: https://chromium-review.googlesource.com/1548399 Commit-Ready: George Burgess <gbiv@chromium.org> Tested-by: George Burgess <gbiv@chromium.org> Reviewed-by: Caroline Tice <cmtice@chromium.org>
Diffstat (limited to 'toolchain_utils_githooks')
-rwxr-xr-xtoolchain_utils_githooks/check-style7
1 files changed, 7 insertions, 0 deletions
diff --git a/toolchain_utils_githooks/check-style b/toolchain_utils_githooks/check-style
index fa06fa3e..c844b1e2 100755
--- a/toolchain_utils_githooks/check-style
+++ b/toolchain_utils_githooks/check-style
@@ -12,6 +12,13 @@ if [[ $# -eq 0 ]]; then
fi
mydir="$(dirname "$(readlink -m "$0")")"
+pydir="${mydir}/.."
+
+if [[ -z "${PYTHONPATH:-}" ]]; then
+ export PYTHONPATH="${pydir}"
+else
+ export PYTHONPATH="${pydir}:${PYTHONPATH}"
+fi
tempfiles=()
rm_tempfiles() {