Skip to content

Don't assume that there's exactly a semicolon and a newline after the package name. - #6072

Merged
copybara-service[bot] merged 1 commit into
masterfrom
test_968728702
Aug 27, 2026
Merged

Don't assume that there's exactly a semicolon and a newline after the package name.#6072
copybara-service[bot] merged 1 commit into
masterfrom
test_968728702

Conversation

@copybara-service

Copy link
Copy Markdown
Contributor

Don't assume that there's exactly a semicolon and a newline after the package name.

And, as part of testing that, make our tests stop appending a newline to the given file content. (More on that later.)

In the depot, there are a number of package-info files that have no newline at the end. (I saw a bunch when running AddNullMarkedToPackageInfoTest over the depot as part of a test of unknown commit.) This causes fix application to fail.

(It might be nice to fail immediately when the bad fix is generated, as in unknown commit. But I worry a bit about the performance of that particular implementation, and I'm not even sure whether it's the right place for the specific Error Prone integration I was using. Given that, I'm not planning to push on it now.)

As for no longer appending a newline in tests:

Most tests nowadays already have a trailing newline (especially after 5902c72), since text blocks have one unless the final line ends with a backslash. In such a case, we actively don't want to add an additional newline. Similarly, in the new test in this CL, we actively don't want to add the "missing" newline because it would unmake the scenario that we want to test.

This CL does mean that we also stop appending a newline to expected outputs. I worried that that might have caused trouble in TEXT_MATCH-mode tests, especially after that mode became the default in ccfc176. However, it should be safe because we've long formatted the expected and actual outputs: unknown commit.

… package name.

And, as part of testing that, make our tests stop appending a newline to the given file content. (More on that later.)

In the depot, there are a number of `package-info` files that have _no_ newline at the end. (I saw a bunch when running AddNullMarkedToPackageInfoTest over the depot as part of a test of unknown commit.) This causes fix application to fail.

(It might be nice to fail immediately when the bad fix is generated, as in unknown commit. But I worry a bit about the performance of that particular implementation, and I'm not even sure whether it's the right place for the specific Error Prone integration I was using. Given that, I'm not planning to push on it now.)

As for no longer appending a newline in tests:

Most tests nowadays already have a trailing newline (especially after 5902c72), since text blocks have one unless the final line ends with a backslash. In such a case, we actively don't want to add an additional newline. Similarly, in the new test in this CL, we actively don't want to add the "missing" newline because it would unmake the scenario that we want to test.

This CL does mean that [we also stop appending a newline to expected _outputs_](https://github.com/google/error-prone/blob/3cf3c69711690b15acf8f720c85e3f50e45c0bdf/test_helpers/src/main/java/com/google/errorprone/BugCheckerRefactoringTestHelper.java#L472). I worried that that might have caused trouble in `TEXT_MATCH`-mode tests, especially after that mode became the default in ccfc176. However, it should be safe because we've long formatted the expected and actual outputs: unknown commit.

PiperOrigin-RevId: 972130097
@copybara-service
copybara-service Bot merged commit 85479ad into master Aug 27, 2026
8 checks passed
@copybara-service
copybara-service Bot deleted the test_968728702 branch August 27, 2026 20:38
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.

1 participant