Add a JavaScript test lane

Gitiles ships JavaScript to the browser and has no way to test any of
it. This adds a way, with as little machinery as the problem allows.

The rule
--------

rules_nodejs is already a declared dependency, and its module registers
hermetic Node toolchains for every supported platform, so
tools/js_test.bzl needs no new dependency and no change to MODULE.bazel.
The rule takes Node from the runtime toolchain type, which Bazel selects
for the platform the test runs on, not from the toolchain type it
selects for the platform build actions run on. A rule is needed at all
because rules_nodejs 6.x ships toolchains only -- nodejs_test moved to
aspect_rules_js -- and because Bazel 9 removed the native sh_test that
could otherwise have wrapped a runner. What is left is small: a launcher
that invokes `node --test`, passes the `args` attribute and --test_arg
through, and writes a JUnit report when Bazel asks for one.

Tests are written against node:test and node:assert, which are part of
the runtime. There is no package manager, no lockfile, no node_modules
and no configuration file to drift.

They live in jstests/ at the root. javatests/ mirrors java/ package
for package, and the code under test is not Java and does not live
under java/ -- it is served out of resources/. Putting JavaScript
tests inside that mirror would make the mirror mean two things. A
sibling directory named for the language does not, and it reads the
same as javatests/ to anyone already used to the tree.

The smoke test
--------------

Build glue that nothing exercises is build glue nobody knows is broken,
so the rule arrives with a test of its own two promises: that the Node
running the tests is the toolchain's and not one found on PATH, and that
a file listed in `data` is readable at its workspace-relative path even
when it comes from another package. Both are environment-dependent, and
neither is visible in the source of a test that merely passes.

Coverage of the JavaScript itself follows in the changes that introduce
the code worth covering.

Verification
------------

  bazel test //...

passes and picks the new target up with no further configuration.

The lane also runs in CI rather than only locally. The gitiles-build job
runs `bazelisk test //...` and fails on a non-zero, non-four exit, so a
failing JavaScript test fails the job. That was confirmed by observing
Verified-1 on Change 646024, a throwaway change stacked on this one
whose only difference is one deliberately inverted assertion.

Bug: 564987520
TAG=agy
CONV=0b3e4b30-d902-4587-8bb2-ce23109d6955
CONV=60d1bfdf-34a4-460e-85ab-0f251e052543
Change-Id: I11c6bbcf18c548f7507861be2fe71727796ca155
3 files changed
tree: 3c0880f5ae1c0a83ed2f6f09c779457c0d04c505
  1. .settings/
  2. Documentation/
  3. java/
  4. javatests/
  5. jstests/
  6. lib/
  7. modules/
  8. resources/
  9. tools/
  10. .bazelignore
  11. .bazelrc
  12. .bazelversion
  13. .gitignore
  14. .gitmodules
  15. .mailmap
  16. .zuul.yaml
  17. BUILD
  18. COPYING
  19. external_deps.lock.json
  20. fake_pom_deploy.xml
  21. MODULE.bazel
  22. MODULE.bazel.lock
  23. navbar.md
  24. README.md
  25. version.bzl
README.md

Gitiles - A simple JGit repository browser

Gitiles is a simple repository browser for Git repositories, built on JGit. Its guiding principle is simplicity: it has no formal access controls, no write access, no fancy Javascript, etc.

Gitiles automatically renders *.md Markdown files into HTML for simplified documentation. Refer to the Markdown documentation for details.

Configuration

Gitiles is configurable in a git-style configuration file named gitiles.config. Refer to the configuration documentation for details.

Bugs

Use gerrit's issue tracker to file bugs.

Contributing to Gitiles

Please refer to the Developer Guide.