Fix test failures when running directly instead of via script (#106)

Fixes #105 by 1) enabling toolchains in the workspace .bazelrc, and 2) making the test harness filter out runfiles added by the autodetecting toolchain.

Previously, the tests worked when run from run_tests.sh but failed in `bazel test //...`. This caused travis to pass but buildkite to fail.

Also fixed a typo that caused run_test.sh to fail on some versions of bash.
diff --git a/.bazelrc b/.bazelrc
new file mode 100644
index 0000000..04615fa
--- /dev/null
+++ b/.bazelrc
@@ -0,0 +1,3 @@
+# //tests:version_test asserts on the Python interpreter version, so enable
+# toolchains to ensure we get the right one (avoid bazelbuild/bazel#4815).
+build --incompatible_use_python_toolchains
diff --git a/run_tests.sh b/run_tests.sh
index 21a259f..acc5410 100755
--- a/run_tests.sh
+++ b/run_tests.sh
@@ -38,7 +38,7 @@
 # that we are compiling uses PY3.
 function set_toolchain_hook {
   pyver=$1
-  if [ $pyver == "PY3"]; then
+  if [ $pyver == "PY3" ]; then
     py2_path="$PYTHON2"
     py3_path="$2"
   else
diff --git a/tests/test_harness.sh b/tests/test_harness.sh
index 59ef338..7c4b380 100755
--- a/tests/test_harness.sh
+++ b/tests/test_harness.sh
@@ -40,8 +40,12 @@
 
 # Compare list of files in zipfile with expected list
 if [ "$PAR" -eq 1 ]; then
+  # Exclude runfiles of the autodetecting toolchain. The test is still brittle
+  # with respect to runfiles introduced by any other toolchain. When tests are
+  # invoked by run_tests.sh, a custom toolchain with no runfiles is used.
   diff \
-    <(unzip -l -q -q "$EXECUTABLE" | awk '{print $NF}') \
+    <(unzip -l -q -q "$EXECUTABLE" | awk '{print $NF}' \
+        | grep -v 'bazel_tools/tools/python/py.wrapper\.sh') \
     "$FILELIST" \
     || die 'FATAL: zipfile contents do not match expected'
 fi