Workspace: add shared sources case to transition test#8206
Workspace: add shared sources case to transition test#8206LeFrosch wants to merge 2 commits intobazelbuild:masterfrom
Conversation
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request enhances the Highlights
Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request adds a test case for shared sources with transitions, which is a good addition. I've found a logical flaw in one of the new test methods, checkPerFileCompilerSettings, where the assertion isn't strong enough to catch potential issues. My review includes a suggestion to fix this.
| for (final var config : configurations) { | ||
| final var settings = config.getCompilerSettings(CLanguageKind.CPP, file); | ||
| assertThat(settings).isNotNull(); | ||
|
|
||
| final var switches = settings.getCompilerSwitches(); | ||
| assertThat(switches).isNotNull(); | ||
|
|
||
| final var rawSwitches = switches.getList(Format.RAW); | ||
|
|
||
| // each per-file config must contain exactly one of -DFOO or -DBAR | ||
| assertThat(rawSwitches.contains("-DFOO") ^ rawSwitches.contains("-DBAR")).isTrue(); | ||
| } |
There was a problem hiding this comment.
The current logic in the for-loop does not guarantee that one of each configuration (-DFOO and -DBAR) is present. It only checks that each configuration has either -DFOO or -DBAR, but not both. For instance, if both configurations had the -DFOO flag, this test would incorrectly pass. A better approach would be to collect the switches from all configurations and then assert that one has -DFOO and one has -DBAR, similar to how checkResolveConfigurations is implemented.
final var compilerSwitches =
configurations.stream()
.map(config -> config.getCompilerSettings(CLanguageKind.CPP, file).getCompilerSwitches())
.filter(Objects::nonNull)
.map(switches -> switches.getList(Format.RAW))
.toList();
assertThat(compilerSwitches).hasSize(2);
assertThat(compilerSwitches.stream().filter(it -> it.contains("-DFOO"))).hasSize(1);
assertThat(compilerSwitches.stream().filter(it -> it.contains("-DBAR"))).hasSize(1);
Test equivalence class computation as part of the transition test.