          ;; (cf. https://docs.bazel.build/versions/4.2.2/test-encyclopedia.html#initial-conditions).
          (workspace-name (file-name-nondirectory
                           (directory-file-name default-directory)))
+         (runfiles-handler-installed
+          (rassq #'elisp/runfiles/file-handler file-name-handler-alist))
+         ;; If the runfiles filename handler is installed, use that.  It’s more
+         ;; correct and should also work on Windows.
+         (resource-root (file-name-as-directory
+                         (if runfiles-handler-installed
+                             (concat "/bazel-runfile:" workspace-name)
+                           default-directory)))
          ;; Best-effort support for ‘ert-resource-directory’ and
          ;; ‘ert-resource-file’.  The directory returned by
          ;; ‘ert-resource-directory’ will typically be in the execution root and

(defalias 'elisp/ert/edebug--get-spec
  (if (fboundp 'edebug-get-spec) 'edebug-get-spec 'get-edebug-spec))

(provide 'elisp/ert/runner)
;;; runner.el ends here

         (ert-resource-directory-trim-left-regexp
          (rx-to-string `(seq (* nonl) ?/ ,workspace-name ?/) :no-group))
         (ert-resource-directory-format
          (concat (replace-regexp-in-string (rx ?%) "%%" resource-root
                                            :fixedcase :literal)
                  "%s-resources/"))
         (report-file (getenv "XML_OUTPUT_FILE"))
         (fail-fast (equal (getenv "TESTBRIDGE_TEST_RUNNER_FAIL_FAST") "1"))
         (random-seed (or (getenv "TEST_RANDOM_SEED") ""))
