jsinterop-base
jsinterop-base copied to clipboard
Add test target to run all tests in gwt2, including generated dependencies
This patch uses the guide at https://docs.bazel.build/versions/master/generate-workspace.html and the linked project there to generate all dependencies required to run tests. The generate-workspace.bzl
file is left entirely generated (to ease re-generating it later), though is not perfect, so several dependencies had to be listed manually. These fell into three categories: those which the generate-workspace project failed to correctly fetch from maven central due to some error while running, those like checker-compat-qual
which didn't seem to get noticed at all (compile-time dep that gwt needs to see?), and those with classifiers which were ignored (sources for jsinterop-annotations, and truth's gwt classifier).
The build_defs/repo:maven_rules.bzl is used to replace the native.maven_jar in WORKSPACE as the native rule seems to not understand classifiers anyway.
I do have an alternative patch weighing in at just under half the size of this one, but instead of being 95% generated code, that one is entirely handwritten and may require more manual effort to maintain.
It seems likely that the actual test rule (and gwt-user/gwt-dev dependencies) could be factored out into a reusable rule for gwt2 test cases, but I'm not yet aware of any other bazel-based projects using gwt2.
Thanks Colin. Couple of comments: We already have test targets, we didn't publish them because there is no macro to run tests (i.e. gwt_test). So we actually need the macro. The macro should be defined in a more central location. For example GWT itself or https://github.com/ekuefler/bazel-gwt/blob/master/gwt/gwt.bzl so we can just refer to it.
Oh that's a great starting point, thanks! Somehow this has entirely eluded me through all of my attempts to learn bazel and plug other projects in to it...
I'll see about incorporating my work into there (though chances are it already has the dependencies worked out). Can either close this (as "the wrong way to do it"), or leave it open so if others want to consider changes to jsinterop-base, they can at least check their work and run their tests.
(a note for future developers looking to try running tests)
After a quick look at https://github.com/bazelbuild/rules_gwt (the new repo for that project), it appears that this is still a bit of a work in progress - doesn't work on windows, may be following out-of-date conventions for referencing maven artifacts, missing many of gwt's dependencies (that work automatically in maven/gradle/ivy).