SWTBot test case: Clangd / Clang-Format Files Test
Description
Please include a summary of the change and which issue is fixed.
Fixes # (IEP-XXX)
Type of change
Please delete options that are not relevant.
- Bug fix (non-breaking change which fixes an issue)
- New feature (non-breaking change which adds functionality)
- Breaking change (fix or feature that would cause existing functionality to not work as expected)
- This change requires a documentation update
How has this been tested?
Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration
- Test A
- Test B
Test Configuration:
- ESP-IDF Version:
- OS (Windows,Linux and macOS):
Dependent components impacted by this PR:
- Component 1
- Component 2
Checklist
- [ ] PR Self Reviewed
- [ ] Applied Code formatting
- [ ] Added Documentation
- [ ] Added Unit Test
- [ ] Verified on all platforms - Windows,Linux and macOS
Summary by CodeRabbit
- Tests
- Improved UI verification by enabling dynamic checks for active configuration tabs.
- Introduced new tests to validate the functionality of Clangd and Clang-Format files within Espressif IDF projects.
- Enhanced text validation within the editor to ensure accurate matching of file content, including whitespace handling.
- Added methods for opening files from the project explorer with retry mechanisms to improve reliability.
- Implemented synchronization improvements with delays in test execution for better UI stability.
- Added functionality to refresh project state via context menu during tests.
Walkthrough
This update introduces a comprehensive JUnit UI test class for Clangd and Clang-Format file workflows in Espressif IDF projects, generalizes a tab-waiting utility, adds new project operation methods, updates test logic for SDKconfig and file associations, raises the Java version for tests to 17, and disables a specific project rename/build test.
Changes
| File(s) | Change Summary |
|---|---|
| .../TestWidgetWaitUtility.java | Renamed and generalized tab-waiting method; updated signature and error messaging. |
| .../NewEspressifIDFProjectClangFilesTest.java | Added new JUnit UI test class for Clangd and Clang-Format file workflows in Espressif IDF projects. |
| .../NewEspressifIDFProjectSDKconfigTest.java | Updated test build steps, added refresh, switched to generalized tab-waiting, and inserted sleeps for synchronization. |
| .../ProjectTestOperations.java | Added methods for opening main files, exact text matching in editors, whitespace normalization, and updated project setup logic. |
| .../EnvSetupOperations.java | Changed default editor selection in preferences from "Text Editor" to "Plain Text Editor". |
| .../META-INF/MANIFEST.MF | Updated required Java execution environment from JavaSE-11 to JavaSE-17. |
| .../NewEspressifIDFProjectTest.java | Commented out (disabled) the test for project creation, renaming, and build verification. |
Sequence Diagram(s)
sequenceDiagram
participant Tester as Test Class
participant SWTBot as SWTWorkbenchBot
participant UI as Eclipse UI
participant Project as Espressif IDF Project
Tester->>SWTBot: Initialize environment/setup
SWTBot->>UI: Open project wizard
UI->>Project: Create new project
Tester->>SWTBot: Open/verify .clangd and .clang-format files
SWTBot->>UI: Open files in editor
Tester->>SWTBot: Edit/verify content, trigger formatting
SWTBot->>UI: Apply changes, trigger build
UI->>Project: Build and update project state
Tester->>SWTBot: Open preferences, verify Clangd arguments
SWTBot->>UI: Display and check preferences
Possibly related PRs
- espressif/idf-eclipse-plugin#1123: Both PRs involve enhancements to the tab-waiting utility method in
TestWidgetWaitUtility.javafor SDKconfig and dialog handling. - espressif/idf-eclipse-plugin#1022: Related to
.clang-formatfile creation and management in Espressif IDF projects, complementing the new Clangd and Clang-Format UI tests.
Suggested reviewers
- alirana01
- kolipakakondal
Poem
In the warren of tests, the rabbits delight,
With Clangd and configs, their code is just right.
Tabs now appear with a name on demand,
Editors match text, as the bunnies had planned.
Java hops to seventeen,
And the garden of tests grows bright and green!
🐇✨
✨ Finishing Touches
- [ ] 📝 Generate Docstrings
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
🪧 Tips
Chat
There are 3 ways to chat with CodeRabbit:
- Review comments: Directly reply to a review comment made by CodeRabbit. Example:
I pushed a fix in commit <commit_id>, please review it.Explain this complex logic.Open a follow-up GitHub issue for this discussion.
- Files and specific lines of code (under the "Files changed" tab): Tag
@coderabbitaiin a new review comment at the desired location with your query. Examples:@coderabbitai explain this code block.@coderabbitai modularize this function.
- PR comments: Tag
@coderabbitaiin a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:@coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.@coderabbitai read src/utils.ts and explain its main purpose.@coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.@coderabbitai help me debug CodeRabbit configuration file.
Support
Need help? Create a ticket on our support page for assistance with any issues or questions.
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.
CodeRabbit Commands (Invoked using PR comments)
@coderabbitai pauseto pause the reviews on a PR.@coderabbitai resumeto resume the paused reviews.@coderabbitai reviewto trigger an incremental review. This is useful when automatic reviews are disabled for the repository.@coderabbitai full reviewto do a full review from scratch and review all the files again.@coderabbitai summaryto regenerate the summary of the PR.@coderabbitai generate docstringsto generate docstrings for this PR.@coderabbitai generate sequence diagramto generate a sequence diagram of the changes in this PR.@coderabbitai resolveresolve all the CodeRabbit review comments.@coderabbitai configurationto show the current CodeRabbit configuration for the repository.@coderabbitai helpto get help.
Other keywords and placeholders
- Add
@coderabbitai ignoreanywhere in the PR description to prevent this PR from being reviewed. - Add
@coderabbitai summaryto generate the high-level summary at a specific location in the PR description. - Add
@coderabbitaianywhere in the PR title to generate the title automatically.
CodeRabbit Configuration File (.coderabbit.yaml)
- You can programmatically configure CodeRabbit by adding a
.coderabbit.yamlfile to the root of your repository. - Please see the configuration documentation for more information.
- If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation:
# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json
Documentation and Community
- Visit our Documentation for detailed information on how to use CodeRabbit.
- Join our Discord Community to get help, request features, and share feedback.
- Follow us on X/Twitter for updates and announcements.
Hi @AndriiFilippov @alirana01 Can these test cases cover the following?
- Do we validate the content in .clangd or .clang-format files? For example, if you have used invalid setting in .clangd or .clang-format our tests should be able to capture this.
- Do our tests validate the interaction between Clangd and actual C/C++ code?
- Do our tests validate the impact of .clang-format settings on actual code formatting?
These are the real issues we have faced earlier by our users.
Can you think of addressing them
Hi @AndriiFilippov @alirana01 Can these test cases cover the following?
- Do we validate the content in .clangd or .clang-format files? For example, if you have used invalid setting in .clangd or .clang-format our tests should be able to capture this.
@kolipakakondal I think we also need to investigate if the clangd or llvm project itself handling these in their tests in terms of SWTBot I am not very confident with these. Until and unless the existing lsp editor is throwing back these errors there is no way to verify this for the positive case we can verify this with a constant formatted file in our tests against the formatted code in the tests.
- Do our tests validate the interaction between Clangd and actual C/C++ code?
In terms of complete end to end testing with SWTBot tests I believe we can only check for the progress of indexer and see if it is working and also verify that there are no errors reported for a project and navigation is working on the code. @AndriiFilippov
- Do our tests validate the impact of .clang-format settings on actual code formatting?
@AndriiFilippov @kolipakakondal I think the answer to first question should address this as well.
@kolipakakondal @alirana01 hi !
Hi @AndriiFilippov @alirana01 Can these test cases cover the following?
- Do we validate the content in .clangd or .clang-format files? For example, if you have used invalid setting in .clangd or .clang-format our tests should be able to capture this.
I have checked this repo llvm-project/tree/main/clang-tools-extra/clangd/test , different tests and could tell that clang-format itself does not have strict validation for the configuration file in terms of catching every possible invalid key in the file during runtime(at least I don't see it there) . If user provide invalid keys or malformed entries, clang-format typically ignores them without throwing a detailed error, but it might issue some warnings or warnings for unrecognized options.
- Do our tests validate the interaction between Clangd and actual C/C++ code?
- Do our tests validate the impact of .clang-format settings on actual code formatting?
Yes, test number 3 does it. I was not able to simulate pressing the shortcut "Ctrl+Shift+F" using the SWTBot framework or run the "contextMenu" method inside the editor. So, the only way to format the main.c file and check if the clang-format settings are applied is by activating "Window -> Preferences -> C/C++ -> Editor (LSP) -> Save Actions -> Format source code" which allows us to format the code every time changes are saved to the main.c file.
These are the real issues we have faced earlier by our users.
Can you think of addressing them
@kolipakakondal @alirana01 @sigmaaa hi guys !
Please, review