                  (noerror nil)
                  (t (signal 'file-error (list "Cannot open load file" file)))))
             load-source-file-function)))
+    ;; TEST_SRCDIR and TEST_TMPDIR are required,
+    ;; cf. https://docs.bazel.build/versions/3.1.0/test-encyclopedia.html#initial-conditions.
+    (and (member source-dir '(nil "")) (error "TEST_SRCDIR not set"))
+    (and (member temp-dir '(nil "")) (error "TEST_TMPDIR not set"))
+    ;; Emacs 26 suffers from
+    ;; https://debbugs.gnu.org/cgi/bugreport.cgi?bug=29579, so don’t quote in
+    ;; that case.
+    (and (> emacs-major-version 26) (cl-callf2 concat "/:" source-dir))
     (and coverage-enabled (member coverage-dir '(nil ""))
          (error "Coverage requested but COVERAGE_DIR not set"))
     (unless (and (natnump shard-count) (natnump shard-index)

         (print-level 8)
         (print-length 50)
         (edebug-initial-mode 'Go-nonstop)  ; ‘step’ doesn’t work in batch mode
         (report-file (getenv "XML_OUTPUT_FILE"))
         (test-filter (getenv "TESTBRIDGE_TEST_ONLY"))
         (random-seed (or (getenv "TEST_RANDOM_SEED") ""))

         (coverage-enabled (equal (getenv "COVERAGE") "1"))
         (coverage-dir (getenv "COVERAGE_DIR"))
         (selector (if (member test-filter '(nil "")) t (read test-filter)))
         (original-load-suffixes load-suffixes)
         (load-suffixes
          ;; Prefer source files when coverage is requested, as only those can
          ;; be instrumented.
