-
Notifications
You must be signed in to change notification settings - Fork 57
incorrect docs on how to use rules_webtesting in Bzlmod #506
Description
Three problems have cropped up trying to use rules_webtesting from bzlmod. I suspect the migration to bzlmod isn't quite complete.
This is with bazel 7.6.1 on macOS 15.6.1.
The first problem
The readme says to add
bazel_dep(name = "rules_webtesting_${language}", version = "0.4.0")
to our MODULE.bazel. But when you search for rules_webtesting you only see modules for specific languages like rules_web_testing_go. (Notice the "_" in "web_testing" in them.
The second problem
Okay, so you decide that you were supposed to write "rules_web_testing_go" and so on.
However, when you add
bazel_dep(name = "rules_webtesting", version = "0.4.0") # Version is per the README
bazel_dep(name = "rules_web_testing_go", version = "0.4.0")
to MODULE.bazel (or even just the rules_web_testing_go line) and
load("@rules_web_testing_go//web:go.bzl", "go_web_test_suite")
go_web_test_suite(...)
to your BUILD.bazel, you get the error:
$ bazel test --enable_bzlmod --noenable_workspace //...
ERROR: Error computing the main repository mapping: bad bazel_dep on module 'rules_webtesting' with no version. Did you forget to specify a version, or a non-registry override?
Computing main repo mapping:
The third problem
You do see there's a newer version of rules_webtesting, a 0.4.1 version.
However, if you change 0.4.0 to the 0.4.1 (whose GitHub release is titled "test for 0.4.1"), you get the error:
$ bazel test --enable_bzlmod --noenable_workspace //...
ERROR: error loading package under directory '': error loading package 'go/svc/howsmyssl-billing': cannot load '@@rules_web_testing_go~//web:go.bzl': no such file
This last error implies that the symlinking being done in web_testing_go is insufficient to make the documented load command work, and you're instead supposed to load fromrules_webtesting.
That is, instead of
load("@rules_web_testing_go//web:go.bzl", "go_web_test_suite")
you're meant to write
load("@rules_webtesting//go/web:go.bzl", "go_web_test_suite")
This line is what actually works while the README leads you astray.
The seeming solution
So, the README docs should probably say to
a) Only include bazel_dep(name = "rules_webtesting", version = "0.4.0") in MODULE.bazel
b) Use the rules_webtesting dep in BUILD.bazel and have the file paths be relative to the top-level dir of it (e.g. load("@rules_webtesting//go/web:go.bzl", "go_web_test_suite"))
Or the modules should get more releases to conform to the README (and the versions in the README should be bumped)
Not sure which is desired!