Commit 8a5bd6f
committed
Set the right JDK version for *_for_testing repos
Removes the `build_file` parameter from `remotejdk*_for_testing`
repositories in `WORKSPACE`. Updates `dist_http_archive` to parse the
correct JDK version from the repo name and then generate a `BUILD` file
from `JDK_BUILD_TEMPLATE` instead.
Fixes several tests broken by incompatible JVM flags by ensuring that
the `remotejdk` repos' `//:jdk` targets set the correct JDK version.
Setting `.bazelci/presubmit.yml` Linux jobs to use Java 11 images
enabled tests to pass on those platforms without this change. This was
because the `--java_runtime_version` happened to match the system JDK
version. Specifing the macOS and Windows build images isn't possible,
necessitating the changes in this commit to fix tests broken on those
platforms.
---
The following series of commits introduced the `remotejdk*_for_testing`
repos and a mechanism to have the "inner" Bazel reuse the "outer"
Bazel's copies:
- Add external repos required by tests and a "fetch all" filegroup.
commit 17506af
- Allow overriding all external repositories used by our integration
tests.
commit 99c0e6d
- Move JDK repo definitions to distdir_deps.bzl
commit b741116
In `.bazelci/presubmit.yml`, every job sets
`--test_env=TEST_REPOSITORY_HOME=$OUTPUT_BASE/external`. This causes
`testenv.sh.tmpl` to override certain repositories with their
`_for_testing` variants:
```sh
if [[ -n ${TEST_REPOSITORY_HOME:-} ]]; then
echo "testenv.sh: Using shared repositories from $TEST_REPOSITORY_HOME."
repos=(
# ...
"remotejdk17_macos_for_testing"
# ...
)
for repo in "${repos[@]}"; do
reponame="${repo%"_for_testing"}"
echo "common --override_repository=$reponame=$TEST_REPOSITORY_HOME/$repo" >> $TEST_TMPDIR/bazelrc
done
fi
```
The `WORKSPACE` file contained entries like the following, created
before `@local_jdk//:BUILD.bazel` contained an explicit JDK version for
its `//:jdk` target:
```py
dist_http_archive(
name = "remotejdk11_macos_for_testing",
build_file = "@local_jdk//:BUILD.bazel",
patch_cmds = EXPORT_WORKSPACE_IN_BUILD_BAZEL_FILE,
patch_cmds_win = EXPORT_WORKSPACE_IN_BUILD_BAZEL_FILE_WIN,
)
```
Later, these commits added the JDK version to `JdkRuntimeInfo`:
- Add version to JavaRuntimeInfo.
commit 7556e11
- [6.2.0] Add version to JavaRuntimeInfo (#17913)
commit 2d04c91
However, they didn't update the `dist_http_archive` entries to adjust
their `build_file` parameters accordingly. As a result, the
`remotejdk` repos used by the "inner" Bazel during tests all specified
the same JDK version as the system JDK.
Bazel resolved the correct toolchain for `--java_runtime_version`, which
would contain the correct Java binaries, but contained the system JDK
`version` parameter. This caused `BazelJavaSemantics` to emit JVM flags
for the _wrong_ JDK version. This, in turn, broke test binaries when
they ran under the _correct_ `java` binary from the JDK that differed
from the system JDK version.1 parent 58a0471 commit 8a5bd6f
2 files changed
Lines changed: 10 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
433 | 433 | | |
434 | 434 | | |
435 | 435 | | |
436 | | - | |
437 | 436 | | |
438 | 437 | | |
439 | 438 | | |
440 | 439 | | |
441 | 440 | | |
442 | 441 | | |
443 | | - | |
444 | 442 | | |
445 | 443 | | |
446 | 444 | | |
447 | 445 | | |
448 | 446 | | |
449 | 447 | | |
450 | | - | |
451 | 448 | | |
452 | 449 | | |
453 | 450 | | |
454 | 451 | | |
455 | 452 | | |
456 | 453 | | |
457 | | - | |
458 | 454 | | |
459 | 455 | | |
460 | 456 | | |
461 | 457 | | |
462 | 458 | | |
463 | 459 | | |
464 | | - | |
465 | 460 | | |
466 | 461 | | |
467 | 462 | | |
468 | 463 | | |
469 | 464 | | |
470 | 465 | | |
471 | | - | |
472 | 466 | | |
473 | 467 | | |
474 | 468 | | |
475 | 469 | | |
476 | 470 | | |
477 | 471 | | |
478 | | - | |
479 | 472 | | |
480 | 473 | | |
481 | 474 | | |
482 | 475 | | |
483 | 476 | | |
484 | 477 | | |
485 | | - | |
486 | 478 | | |
487 | 479 | | |
488 | 480 | | |
489 | 481 | | |
490 | 482 | | |
491 | 483 | | |
492 | 484 | | |
493 | | - | |
494 | 485 | | |
495 | 486 | | |
496 | 487 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| 18 | + | |
18 | 19 | | |
19 | 20 | | |
20 | 21 | | |
| |||
91 | 92 | | |
92 | 93 | | |
93 | 94 | | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
94 | 104 | | |
95 | 105 | | |
96 | 106 | | |
| |||
0 commit comments