Skip to content

Fix silently broken test_version.sh tests #1716

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 11, 2025

Conversation

mbland
Copy link
Contributor

@mbland mbland commented Mar 10, 2025

Description

Fixes silently broken tests depending on test_version/test_reporter and adds an assertion to avoid future silent breakages. Part of #1482 and #1652.

  • Moves test_version/version_specific_tests_dir/scala_repositories.bzl to test_version.

  • Updates test_version.sh to copy this file into test repos generated from both version_specific_tests_dir and test_reporter.

  • Updates compilation_should_fail to break if the bazel build output doesn't contain the expected ErrorFile.scala error.

Motivation

The affected test cases expect their underlying builds to fail because of errors in test_version/test_reporter/ErrorFile.scala. Failing Scala 2.x build output should contain:

ErrorFile.scala:6: ')' expected but '}' found

Failing Scala 3.x build output should contain:

-- [E040] Syntax Error: ErrorFile.scala:6:2 ------------------------------------
6 |  }
  |  ^
  |  ')' expected, but '}' found

Using RULES_SCALA_TEST_ONLY to select an affected test case revealed that the underlying build actually failed because Bazel couldn't find //:scrooge_repositories.bzl:

$ RULES_SCALA_TEST_ONLY="test_reporter 2.12.20 //:diagnostics_reporter_toolchain" \
  ./test_version.sh

running test test_reporter 2.12.20 //:diagnostics_reporter_toolchain
Starting local Bazel server and connecting to it...
Computing main repo mapping:
ERROR: Error computing the main repository mapping:
  cannot load '//:scrooge_repositories.bzl': no such file

$ echo $?

0

Fixes silently broken tests depending on `test_version/test_reporter`
and adds an assertion to avoid future silent breakages. Part of bazelbuild#1482
and bazelbuild#1652.

- Moves `test_version/version_specific_tests_dir/scala_repositories.bzl`
  to `test_version`.

- Updates `test_version.sh` to copy this file into test repos generated
  from both `version_specific_tests_dir` and `test_reporter`.

- Updates `compilation_should_fail` to break if the `bazel build` output
  doesn't contain the expected `ErrorFile.scala` error.

The affected test cases expect their underlying builds to fail because
of errors in `test_version/test_reporter/ErrorFile.scala`. Failing Scala
2.x build output should contain:

```txt
ErrorFile.scala:6: ')' expected but '}' found
```

Failing Scala 3.x build output should contain:

```txt
-- [E040] Syntax Error: ErrorFile.scala:6:2 ------------------------------------
6 |  }
  |  ^
  |  ')' expected, but '}' found
```

Using `RULES_SCALA_TEST_ONLY` to select an affected test case revealed
that the underlying build actually failed because Bazel couldn't find
`//:scrooge_repositories.bzl`:

```txt
$ RULES_SCALA_TEST_ONLY="test_reporter 2.12.20 //:diagnostics_reporter_toolchain" \
  ./test_version.sh

running test test_reporter 2.12.20 //:diagnostics_reporter_toolchain
Starting local Bazel server and connecting to it...
Computing main repo mapping:
ERROR: Error computing the main repository mapping:
  cannot load '//:scrooge_repositories.bzl': no such file

$ echo $?

0
```
@simuons simuons merged commit 11d3b32 into bazelbuild:master Mar 11, 2025
2 checks passed
@mbland mbland deleted the fix-diagnostics-reporter-tests branch March 11, 2025 10:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants