-
Notifications
You must be signed in to change notification settings - Fork 133
WIP: SWTBot test case: Debug flow Test #795
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
base: master
Are you sure you want to change the base?
Conversation
66d2f25 to
70b7206
Compare
WalkthroughAdds a new SWTBot JUnit4 UI test class that sets up the environment, creates an ESP‑IDF project, toggles launch settings, builds, selects serial/target, flashes and verifies success, and prepares a debug launch on Linux; non‑Linux runs a trivial short‑circuit assertion. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant T as Test (IDFProjectDebugProcessTest)
participant F as Fixture
participant Env as EnvSetupOperations
participant Proj as ProjectTestOperations
participant LCfg as LaunchBarConfigSelector
participant LTgt as LaunchBarTargetSelector
participant IDE as Eclipse UI
rect rgba(230,240,255,0.5)
Note over T: Linux-only test path
T->>F: beforeTestClass()
F->>Env: initializeEnvironment()
Env-->>F: ready
end
T->>F: createNewProject()
F->>Proj: createIDFProject()
Proj-->>F: project created
T->>LCfg: openLaunchConfig()
LCfg->>IDE: uncheck "Open Serial Monitor After Flashing"
IDE-->>LCfg: setting saved
T->>Proj: buildProject()
Proj-->>T: build success
T->>Proj: selectSerialPort()
Proj-->>T: port selected
T->>Proj: flashProject()
Proj-->>T: flash success verified
T->>LCfg: selectDebugConfiguration()
LCfg-->>T: debug config selected
T->>LTgt: selectTargetBoard()
LTgt-->>T: target selected
alt Debug steps (commented out)
Note over T,IDE: Debug launch interactions prepared but not executed
end
T->>F: afterEachTest()
F->>Env: cleanup()
Env-->>F: cleaned
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests
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. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
🧹 Nitpick comments (4)
tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/IDFProjectDebugProcessTest.java (4)
66-84: Platform-specific test execution needs documentation.The Linux-only execution with a fallback
assertTrue(true)for non-Linux platforms is a reasonable temporary approach, but it should be documented more clearly in the code and potentially in the test method name.Consider adding a more informative comment and potentially using JUnit's
Assumefor cleaner platform filtering:+import org.junit.Assume; @Test public void givenNewProjectCreatedWhenFlashedAndDebuggedThenDebuggingWorks() throws Exception { - if (SystemUtils.IS_OS_LINUX) //temporary solution until new ESP boards arrive for Windows + // Skip test on non-Linux platforms until ESP boards are available for Windows/macOS + Assume.assumeTrue("Test requires Linux platform with ESP hardware", SystemUtils.IS_OS_LINUX); + { Fixture.givenNewEspressifIDFProjectIsSelected("EspressIf", "Espressif IDF Project"); // ... rest of test logic - } - else - { - assertTrue(true); - } + } }
168-170: Inconsistent code formatting.The indentation inside the if statement is inconsistent with the rest of the codebase.
Apply this diff to fix the formatting:
if (checkBox.isChecked()) { -checkBox.click(); -} + checkBox.click(); +}
148-148: Hardcoded board selection may cause test brittleness.The hardcoded board selection
"ESP32-ETHERNET-KIT [usb://1-10]"assumes a specific USB port and board availability, which could make the test brittle in different environments.Consider making the board selection more flexible or add error handling for cases where the expected board is not available:
-bot.comboBoxWithLabel("Board:").setSelection("ESP32-ETHERNET-KIT [usb://1-10]"); +// Try to select ESP32-ETHERNET-KIT, fallback to first available board if not found +SWTBotComboBox boardCombo = bot.comboBoxWithLabel("Board:"); +String[] items = boardCombo.items(); +String targetBoard = "ESP32-ETHERNET-KIT [usb://1-10]"; +boolean boardFound = false; +for (String item : items) { + if (item.contains("ESP32-ETHERNET-KIT")) { + boardCombo.setSelection(item); + boardFound = true; + break; + } +} +if (!boardFound && items.length > 0) { + boardCombo.setSelection(0); // Select first available board +}
180-180: Hardcoded serial port selection needs flexibility.Similar to the board selection, the hardcoded serial port
"/dev/ttyUSB1 Dual RS232-HS"assumes a specific hardware configuration that may not be available in all test environments.Consider adding logic to select the first available serial port if the hardcoded one is not found:
-bot.comboBoxWithLabel("Serial Port:").setSelection("/dev/ttyUSB1 Dual RS232-HS"); +// Try to select preferred serial port, fallback to first available if not found +SWTBotComboBox portCombo = bot.comboBoxWithLabel("Serial Port:"); +String[] items = portCombo.items(); +String preferredPort = "/dev/ttyUSB1 Dual RS232-HS"; +boolean portFound = false; +for (String item : items) { + if (item.equals(preferredPort)) { + portCombo.setSelection(item); + portFound = true; + break; + } +} +if (!portFound && items.length > 0) { + portCombo.setSelection(0); // Select first available port +}
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/IDFProjectDebugProcessTest.java(1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/IDFProjectDebugProcessTest.java (3)
tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/common/WorkBenchSWTBot.java (1)
WorkBenchSWTBot(14-28)tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/operations/EnvSetupOperations.java (1)
EnvSetupOperations(12-85)tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/operations/ProjectTestOperations.java (1)
ProjectTestOperations(51-785)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
- GitHub Check: build_macos
- GitHub Check: build_windows
- GitHub Check: build
🔇 Additional comments (2)
tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/IDFProjectDebugProcessTest.java (2)
125-134: Commented debug method provides valuable implementation guidance.The commented
whenDebugProject()method shows the intended debugging workflow and provides a good reference for future implementation. The logic appears sound for launching debug configurations.
87-208: Well-structured Fixture pattern implementation.The private static
Fixtureclass provides a clean separation of concerns and follows good test organization practices. The use of static fields to maintain state between fixture methods and the clear naming of Given/When/Then methods align well with BDD-style testing approaches.
| if (SystemUtils.IS_OS_LINUX) //temporary solution until new ESP boards arrive for Windows | ||
| { | ||
| Fixture.givenNewEspressifIDFProjectIsSelected("EspressIf", "Espressif IDF Project"); | ||
| Fixture.givenProjectNameIs("NewProjecDebugTest"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo in project name.
There's a spelling error in the project name: "NewProjecDebugTest" should be "NewProjectDebugTest".
Apply this diff to fix the typo:
-Fixture.givenProjectNameIs("NewProjecDebugTest");
+Fixture.givenProjectNameIs("NewProjectDebugTest");📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| Fixture.givenProjectNameIs("NewProjecDebugTest"); | |
| Fixture.givenProjectNameIs("NewProjectDebugTest"); |
🤖 Prompt for AI Agents
In
tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/IDFProjectDebugProcessTest.java
around line 69, the project name string has a typo "NewProjecDebugTest"; update
the string literal to "NewProjectDebugTest" so the fixture uses the correctly
spelled project name.
| // Fixture.whenDebugProject(); | ||
| // Fixture.whenSwitchPerspective(); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Verification agent
🧩 Analysis chain
Incomplete test implementation with commented debug steps.
The core debugging functionality is commented out, which means this test doesn't fully validate the debugging workflow as described in the PR objectives. The test stops at configuration selection rather than actual debugging verification.
The PR description mentions verifying "the match of the project name, Actual Executable, and SVD Path in the New ESP-IDF GDB OpenOCD Debugging Launch Configuration", but the actual debugging verification steps are commented out. Can you confirm whether this is intentional for this iteration, or if the debugging steps should be implemented to meet the PR objectives?
🏁 Script executed:
#!/bin/bash
# Search for any other debug-related test implementations that might provide guidance
rg -n "Debug.*Configuration" --type=java -C 3Length of output: 45763
Test selects the debug config but does not verify or launch it — implement verification or clarify intent
- The commented calls (Fixture.whenDebugProject / Fixture.whenSwitchPerspective at tests/.../IDFProjectDebugProcessTest.java) appear to be replaced by helper code: whenDebugProject() in tests/com.espressif.idf.ui.test/.../IDFProjectDebugProcessTest.java (≈lines 124–131) and ProjectTestOperations.createDebugConfiguration(...) in tests/com.espressif.idf.ui.test/.../ProjectTestOperations.java (≈lines 124–135); both only open/select the "ESP‑IDF GDB OpenOCD Debugging" node.
- There is no evidence these helpers click "Debug" or assert the PR-required fields ("project name", "Actual Executable", "SVD Path"). Implement assertions (or start the debug and inspect the launch configuration) to meet the PR objective, or update the PR to state that full debug verification is intentionally omitted.
🤖 Prompt for AI Agents
In
tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/IDFProjectDebugProcessTest.java
around lines 78–80, the test selects the "ESP‑IDF GDB OpenOCD Debugging" node
but never verifies or launches the debug configuration; update the test to
either (A) assert the selected launch configuration's required fields (validate
the launch config name/project name, Actual Executable path, and SVD Path) by
retrieving the ILaunchConfiguration (or equivalent helper) and asserting those
properties, or (B) actually start the debug launch and assert the expected
debugger/launch behavior; alternatively, if full verification is intentionally
omitted, update the PR description and test comments to state that deliberate
omission. Ensure new assertions fail on missing/incorrect values and keep helper
usage in ProjectTestOperations or whenDebugProject() to obtain the selected
configuration.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 4
♻️ Duplicate comments (2)
tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/IDFProjectDebugProcessTest.java (2)
82-86: Core debug flow is commented out — implement or explicitly scope the test
The test currently stops after selecting the debug config/target. Either enable the debug launch and add assertions (e.g., debugger attaches, expected nodes appear in Debug view), or update the PR to clarify this test only covers configuration/flash. Otherwise it doesn’t meet the stated objective.
73-73: Project name typoRepeated from a prior review: fix “NewProjecDebugTest” → “NewProjectDebugTest”.
- Fixture.givenProjectNameIs("NewProjecDebugTest"); + Fixture.givenProjectNameIs("NewProjectDebugTest");
🧹 Nitpick comments (5)
tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/IDFProjectDebugProcessTest.java (5)
8-10: Use JUnit Assume to skip on non‑Linux instead of passing triviallyAdd an import for Assume.
import static org.eclipse.swtbot.swt.finder.waits.Conditions.widgetIsEnabled; +import static org.junit.Assume.assumeTrue; import static org.junit.Assert.assertTrue;
67-91: Replace if/else OS gate with an assumptionAvoid a vacuous pass on non‑Linux; skip the test instead.
- if (SystemUtils.IS_OS_LINUX) // temporary solution until new ESP boards arrive for Windows - { + assumeTrue("Linux-only test path until Windows boards are available", SystemUtils.IS_OS_LINUX); Fixture.givenNewEspressifIDFProjectIsSelected("EspressIf", "Espressif IDF Project"); Fixture.givenProjectNameIs("NewProjecDebugTest"); Fixture.whenNewProjectIsSelected(); Fixture.whenTurnOffOpenSerialMonitorAfterFlashingInLaunchConfig(); Fixture.whenSelectLaunchTargetSerialPort(); Fixture.whenProjectIsBuiltUsingContextMenu(); Fixture.whenFlashProject(); Fixture.thenVerifyFlashDoneSuccessfully(); Fixture.whenSelectDebugConfig(); Fixture.whenSelectLaunchTargetBoard(); // Fixture.whenDebugProject(); // Fixture.whenSwitchPerspective(); // Fixture.checkIfOpenOCDandGDBprocessesArePresent(); // Fixture.whenDebugStoppedUsingContextMenu(); - - } - else - { - assertTrue(true); - }Note: Keep the typo fixes from the other comments when applying this change.
148-158: Hard‑coded board label — parameterize via properties with fallbackUsing a fixed “ESP32-ETHERNET-KIT [usb://1-10]” is brittle across labs. Read from DefaultPropertyFetcher with a safe default.
- bot.comboBoxWithLabel("Board:").setSelection("ESP32-ETHERNET-KIT [usb://1-10]"); + String desiredBoard = DefaultPropertyFetcher.getStringPropertyValue("test.launch.board.label", ""); + if (desiredBoard != null && !desiredBoard.isBlank()) { + bot.comboBoxWithLabel("Board:").setSelection(desiredBoard); + } else { + // fallback to first available item + String[] items = bot.comboBoxWithLabel("Board:").items(); + bot.comboBoxWithLabel("Board:").setSelection(items.length > 0 ? items[0] : ""); + }Consider documenting the new property key (e.g., in test README). Based on learnings.
182-192: Hard‑coded serial port — parameterize via properties with fallbackMake the serial port configurable to avoid machine‑specific failures.
- bot.comboBoxWithLabel("Serial Port:").setSelection("/dev/ttyUSB1 Dual RS232-HS"); + String desiredPort = DefaultPropertyFetcher.getStringPropertyValue("test.launch.serial.port.label", ""); + if (desiredPort != null && !desiredPort.isBlank()) { + bot.comboBoxWithLabel("Serial Port:").setSelection(desiredPort); + } else { + String[] ports = bot.comboBoxWithLabel("Serial Port:").items(); + bot.comboBoxWithLabel("Serial Port:").setSelection(ports.length > 0 ? ports[0] : ""); + }
54-65: Surface cleanup failures for diagnosticsPrint the stack trace to aid triage instead of only the message.
- System.err.println("Error during cleanup: " + e.getMessage()); + System.err.println("Error during cleanup: " + e.getMessage()); + e.printStackTrace(System.err);
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/IDFProjectDebugProcessTest.java(1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/IDFProjectDebugProcessTest.java (3)
tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/common/WorkBenchSWTBot.java (1)
WorkBenchSWTBot(14-28)tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/operations/EnvSetupOperations.java (1)
EnvSetupOperations(12-85)tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/operations/ProjectTestOperations.java (1)
ProjectTestOperations(51-785)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
- GitHub Check: build_windows
- GitHub Check: build
- GitHub Check: build_macos
| { | ||
| if (SystemUtils.IS_OS_LINUX) // temporary solution until new ESP boards arrive for Windows | ||
| { | ||
| Fixture.givenNewEspressifIDFProjectIsSelected("EspressIf", "Espressif IDF Project"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Category label typo will break the wizard selection
"EspressIf" should be "Espressif" to match the UI category and avoid widget lookup failures.
- Fixture.givenNewEspressifIDFProjectIsSelected("EspressIf", "Espressif IDF Project");
+ Fixture.givenNewEspressifIDFProjectIsSelected("Espressif", "Espressif IDF Project");📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| Fixture.givenNewEspressifIDFProjectIsSelected("EspressIf", "Espressif IDF Project"); | |
| Fixture.givenNewEspressifIDFProjectIsSelected("Espressif", "Espressif IDF Project"); |
🤖 Prompt for AI Agents
In
tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/IDFProjectDebugProcessTest.java
around line 72, the category label string passed to
Fixture.givenNewEspressifIDFProjectIsSelected is misspelled as "EspressIf";
replace it with the correct UI category "Espressif" so the wizard/widget lookup
matches the UI and selection succeeds.
| Optional<SWTBotTreeItem> project = Arrays.asList(items).stream() | ||
| .filter(i -> i.getText().equals(projectName + "Debug [ESP-IDF GDB OpenOCD Debugging]")).findFirst(); | ||
| if (project.isPresent()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Debug view item match is wrong (missing space before “Debug”)
The code looks for “NameDebug [...]” but the configuration is named “Name Debug”. This will never match.
- .filter(i -> i.getText().equals(projectName + "Debug [ESP-IDF GDB OpenOCD Debugging]")).findFirst();
+ .filter(i -> i.getText().contains(projectName + " Debug")
+ && i.getText().contains("[ESP-IDF GDB OpenOCD Debugging]"))
+ .findFirst();📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| Optional<SWTBotTreeItem> project = Arrays.asList(items).stream() | |
| .filter(i -> i.getText().equals(projectName + "Debug [ESP-IDF GDB OpenOCD Debugging]")).findFirst(); | |
| if (project.isPresent()) | |
| Optional<SWTBotTreeItem> project = Arrays.asList(items).stream() | |
| .filter(i -> i.getText().contains(projectName + " Debug") | |
| && i.getText().contains("[ESP-IDF GDB OpenOCD Debugging]")) | |
| .findFirst(); | |
| if (project.isPresent()) |
🤖 Prompt for AI Agents
In
tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/IDFProjectDebugProcessTest.java
around lines 216-218, the filter checks for projectName + "Debug [ESP-IDF GDB
OpenOCD Debugging]" which is missing a space and will never match the actual
item label; update the match to include the space (projectName + " Debug
[ESP-IDF GDB OpenOCD Debugging]") or alternatively use a more robust check such
as contains or startsWith with the projectName and "Debug" to avoid exact
spacing issues.
| private static boolean checkifOpenOCDandGDBprocessesArePresent() | ||
| { | ||
| SWTBotTreeItem projectItem = fetchProjectFromDebugView(); | ||
| if (projectItem != null) | ||
| { | ||
| projectItem.select(); | ||
|
|
||
| boolean openOCDexe = ProjectTestOperations.isFileAbsent(projectItem, "openocd.exe"); | ||
| boolean GDBexe = ProjectTestOperations.isFileAbsent(projectItem, "riscv32-esp-elf-gdb.exe"); | ||
| if (openOCDexe || GDBexe) | ||
| { | ||
| return false; | ||
| } | ||
| return true; | ||
| } | ||
| return false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Process presence check uses Windows “.exe” on a Linux‑only path and inverted logic
On Linux there’s no “.exe”. Also, using isFileAbsent and then negating only at the end obscures intent.
- boolean openOCDexe = ProjectTestOperations.isFileAbsent(projectItem, "openocd.exe");
- boolean GDBexe = ProjectTestOperations.isFileAbsent(projectItem, "riscv32-esp-elf-gdb.exe");
- if (openOCDexe || GDBexe)
- {
- return false;
- }
- return true;
+ final String openocdName = SystemUtils.IS_OS_WINDOWS ? "openocd.exe" : "openocd";
+ // Support both Xtensa and RISC‑V toolchains
+ final String[] gdbCandidates = SystemUtils.IS_OS_WINDOWS
+ ? new String[] {"xtensa-esp32-elf-gdb.exe", "xtensa-esp32s2-elf-gdb.exe",
+ "xtensa-esp32s3-elf-gdb.exe", "riscv32-esp-elf-gdb.exe"}
+ : new String[] {"xtensa-esp32-elf-gdb", "xtensa-esp32s2-elf-gdb",
+ "xtensa-esp32s3-elf-gdb", "riscv32-esp-elf-gdb"};
+
+ boolean openocdPresent = !ProjectTestOperations.isFileAbsent(projectItem, openocdName);
+ boolean gdbPresent = false;
+ for (String gdb : gdbCandidates) {
+ if (!ProjectTestOperations.isFileAbsent(projectItem, gdb)) {
+ gdbPresent = true;
+ break;
+ }
+ }
+ return openocdPresent && gdbPresent;📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| private static boolean checkifOpenOCDandGDBprocessesArePresent() | |
| { | |
| SWTBotTreeItem projectItem = fetchProjectFromDebugView(); | |
| if (projectItem != null) | |
| { | |
| projectItem.select(); | |
| boolean openOCDexe = ProjectTestOperations.isFileAbsent(projectItem, "openocd.exe"); | |
| boolean GDBexe = ProjectTestOperations.isFileAbsent(projectItem, "riscv32-esp-elf-gdb.exe"); | |
| if (openOCDexe || GDBexe) | |
| { | |
| return false; | |
| } | |
| return true; | |
| } | |
| return false; | |
| private static boolean checkifOpenOCDandGDBprocessesArePresent() | |
| { | |
| SWTBotTreeItem projectItem = fetchProjectFromDebugView(); | |
| if (projectItem != null) | |
| { | |
| projectItem.select(); | |
| final String openocdName = SystemUtils.IS_OS_WINDOWS ? "openocd.exe" : "openocd"; | |
| // Support both Xtensa and RISC-V toolchains | |
| final String[] gdbCandidates = SystemUtils.IS_OS_WINDOWS | |
| ? new String[] {"xtensa-esp32-elf-gdb.exe", "xtensa-esp32s2-elf-gdb.exe", | |
| "xtensa-esp32s3-elf-gdb.exe", "riscv32-esp-elf-gdb.exe"} | |
| : new String[] {"xtensa-esp32-elf-gdb", "xtensa-esp32s2-elf-gdb", | |
| "xtensa-esp32s3-elf-gdb", "riscv32-esp-elf-gdb"}; | |
| boolean openocdPresent = !ProjectTestOperations.isFileAbsent(projectItem, openocdName); | |
| boolean gdbPresent = false; | |
| for (String gdb : gdbCandidates) { | |
| if (!ProjectTestOperations.isFileAbsent(projectItem, gdb)) { | |
| gdbPresent = true; | |
| break; | |
| } | |
| } | |
| return openocdPresent && gdbPresent; | |
| } | |
| return false; | |
| } |
🤖 Prompt for AI Agents
In
tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/IDFProjectDebugProcessTest.java
around lines 226 to 241, the process presence check incorrectly looks for
Windows “.exe” filenames on a Linux-only path and uses inverted/obscured logic
by calling isFileAbsent then negating at the end; change the checks to use the
Linux binary names (remove “.exe”, e.g. "openocd" and "riscv32-esp-elf-gdb") and
simplify logic so you directly test presence (either call an isFilePresent
method or immediately return false if isFileAbsent(...) is true), returning true
only when both binaries are found. Ensure the method returns false early if
either file is missing and true otherwise.
| private static void whenDebugStoppedUsingContextMenu() throws IOException | ||
| { | ||
| ProjectTestOperations.launchCommandUsingContextMenu(projectName + "Debug [ESP-IDF GDB OpenOCD Debugging]", | ||
| bot, "Terminate/Disconnect All"); | ||
| bot.sleep(10000); | ||
| ProjectTestOperations.findInConsole(bot, "IDF Process Console", "dropped 'gdb'"); | ||
| TestWidgetWaitUtility.waitForOperationsInProgressToFinishSync(bot); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Terminate via Debug view, not Project Explorer context
The helper launches a Project Explorer context menu, which won’t target the active debug session. Use the Debug view’s toolbar or context menu on the session node.
- ProjectTestOperations.launchCommandUsingContextMenu(projectName + "Debug [ESP-IDF GDB OpenOCD Debugging]",
- bot, "Terminate/Disconnect All");
- bot.sleep(10000);
- ProjectTestOperations.findInConsole(bot, "IDF Process Console", "dropped 'gdb'");
+ SWTBotView debugView = bot.viewByTitle("Debug");
+ debugView.show();
+ debugView.setFocus();
+ SWTBotTreeItem item = fetchProjectFromDebugView();
+ if (item != null) {
+ item.select();
+ // Prefer toolbar; fallback to context menu label if needed
+ try {
+ debugView.toolbarButton("Terminate").click();
+ } catch (Exception e) {
+ item.contextMenu("Terminate/Disconnect All").click();
+ }
+ ProjectTestOperations.findInConsole(bot, "IDF Process Console", "dropped 'gdb'");
+ }
TestWidgetWaitUtility.waitForOperationsInProgressToFinishSync(bot);Committable suggestion skipped: line range outside the PR's diff.
🤖 Prompt for AI Agents
In
tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/IDFProjectDebugProcessTest.java
around lines 249-256, the test currently uses Project Explorer context menu
which doesn't target the active debug session; instead open the Debug view,
locate the running debug session node matching projectName + "Debug [ESP-IDF GDB
OpenOCD Debugging]" and invoke the "Terminate/Disconnect All" action via the
Debug view toolbar or the session node's context menu; keep the subsequent
bot.sleep, console check for "dropped 'gdb'", and wait-for-operations sync but
replace the ProjectTestOperations.launchCommandUsingContextMenu call with a
Debug-view-specific action (or add a helper that selects the Debug view, finds
the session node, and triggers the terminate action).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
♻️ Duplicate comments (3)
tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/IDFProjectDebugProcessTest.java (3)
72-72: Fix critical typos in project setup.Two typos remain from previous reviews that will break the test:
- Category label "EspressIf" should be "Espressif" to match the wizard UI
- Project name "NewProjecDebugTest" should be "NewProjectDebugTest"
Apply this diff to fix both typos:
- Fixture.createNewEspressifProject("EspressIf", "Espressif IDF Project", "NewProjecDebugTest"); + Fixture.createNewEspressifProject("Espressif", "Espressif IDF Project", "NewProjectDebugTest");
258-258: Fix critical string match bug (missing space).The filter checks for
projectName + "Debug [ESP-IDF GDB OpenOCD Debugging]"but the actual debug configuration name isprojectName + " Debug [ESP-IDF GDB OpenOCD Debugging]"(with a space before "Debug"). This will never match and the test will fail.Apply this diff to fix the match:
- .filter(i -> i.getText().equals(projectName + "Debug [ESP-IDF GDB OpenOCD Debugging]")) + .filter(i -> i.getText().equals(projectName + " Debug [ESP-IDF GDB OpenOCD Debugging]"))
110-119: Test does not verify debug configuration fields per PR objectives.The PR description states the test should verify "the match of the project name, Actual Executable, and SVD Path in the New ESP-IDF GDB OpenOCD Debugging Launch Configuration". The current implementation only selects the debug configuration and launches it, but does not assert these fields.
Consider adding verification steps in
whenDebugProject()or a newthenVerifyDebugConfiguration()method that:
- Opens the Debug Configurations dialog
- Selects the ESP-IDF GDB OpenOCD Debugging configuration for the project
- Asserts the "Project" field matches the expected project name
- Asserts the "Actual Executable" path is valid
- Asserts the "SVD Path" is set correctly
You can retrieve these values from the dialog's text fields before clicking "Debug". If you need assistance implementing this verification, please let me know.
🧹 Nitpick comments (1)
tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/IDFProjectDebugProcessTest.java (1)
169-177: Hardcoded hardware dependencies make test brittle.The test hardcodes specific hardware targets (
ESP32-ETHERNET-KIT [usb://1-10]and/dev/ttyUSB1 Dual RS232-HS) which will fail if:
- The board is not connected or connected to a different USB port
- The serial port enumeration differs
- Tests run on different hardware or CI environments
Consider:
- Making these values configurable via system properties or environment variables
- Adding runtime detection to query available targets/ports and select the first available one
- Adding a clear skip condition with a descriptive message when required hardware is not present
Example using system properties:
private static void whenSelectLaunchTargetBoard() throws Exception { String board = System.getProperty("esp.test.board", "ESP32-ETHERNET-KIT [usb://1-10]"); selectLaunchTarget("Board:", board); } private static void whenSelectLaunchTargetSerialPort() throws Exception { String port = System.getProperty("esp.test.serial.port", "/dev/ttyUSB1 Dual RS232-HS"); selectLaunchTarget("Serial Port:", port); }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/IDFProjectDebugProcessTest.java(1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/IDFProjectDebugProcessTest.java (3)
tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/common/WorkBenchSWTBot.java (1)
WorkBenchSWTBot(14-28)tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/operations/EnvSetupOperations.java (1)
EnvSetupOperations(12-85)tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/operations/ProjectTestOperations.java (1)
ProjectTestOperations(51-785)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: build_windows
- GitHub Check: build
| private static void thenOpenOCDexeIsPresent() throws IOException | ||
| { | ||
| fetchProjectFromDebugView(); | ||
| assertTrue("OpenOCD.exe process was not found", | ||
| bot.tree().getTreeItem(projectName + " Debug [ESP-IDF GDB OpenOCD Debugging]").getNodes() | ||
| .contains("openocd")); | ||
| } | ||
|
|
||
| private static void thenGDBexeIsPresent() throws IOException | ||
| { | ||
| fetchProjectFromDebugView(); | ||
| assertTrue("riscv32-esp-elf-gdb.exe process was not found", | ||
| bot.tree().getTreeItem(projectName + " Debug [ESP-IDF GDB OpenOCD Debugging]").getNodes() | ||
| .contains("riscv32-esp-elf-gdb")); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use the returned Debug view tree item for process verification.
thenOpenOCDexeIsPresent() and thenGDBexeIsPresent() call fetchProjectFromDebugView() but discard the returned item and directly use bot.tree(), which may target the wrong tree if another view with a tree is focused. This can cause false negatives.
Apply this diff to both methods:
private static void thenOpenOCDexeIsPresent() throws IOException
{
- fetchProjectFromDebugView();
- assertTrue("OpenOCD.exe process was not found",
- bot.tree().getTreeItem(projectName + " Debug [ESP-IDF GDB OpenOCD Debugging]").getNodes()
- .contains("openocd"));
+ SWTBotTreeItem projectItem = fetchProjectFromDebugView();
+ if (projectItem != null)
+ {
+ projectItem.expand();
+ assertTrue("OpenOCD process was not found", projectItem.getNodes().contains("openocd"));
+ }
+ else
+ {
+ throw new AssertionError("Debug session not found in Debug view");
+ }
}
private static void thenGDBexeIsPresent() throws IOException
{
- fetchProjectFromDebugView();
- assertTrue("riscv32-esp-elf-gdb.exe process was not found",
- bot.tree().getTreeItem(projectName + " Debug [ESP-IDF GDB OpenOCD Debugging]").getNodes()
- .contains("riscv32-esp-elf-gdb"));
+ SWTBotTreeItem projectItem = fetchProjectFromDebugView();
+ if (projectItem != null)
+ {
+ projectItem.expand();
+ assertTrue("riscv32-esp-elf-gdb process was not found",
+ projectItem.getNodes().contains("riscv32-esp-elf-gdb"));
+ }
+ else
+ {
+ throw new AssertionError("Debug session not found in Debug view");
+ }
}📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| private static void thenOpenOCDexeIsPresent() throws IOException | |
| { | |
| fetchProjectFromDebugView(); | |
| assertTrue("OpenOCD.exe process was not found", | |
| bot.tree().getTreeItem(projectName + " Debug [ESP-IDF GDB OpenOCD Debugging]").getNodes() | |
| .contains("openocd")); | |
| } | |
| private static void thenGDBexeIsPresent() throws IOException | |
| { | |
| fetchProjectFromDebugView(); | |
| assertTrue("riscv32-esp-elf-gdb.exe process was not found", | |
| bot.tree().getTreeItem(projectName + " Debug [ESP-IDF GDB OpenOCD Debugging]").getNodes() | |
| .contains("riscv32-esp-elf-gdb")); | |
| } | |
| private static void thenOpenOCDexeIsPresent() throws IOException | |
| { | |
| SWTBotTreeItem projectItem = fetchProjectFromDebugView(); | |
| if (projectItem != null) | |
| { | |
| projectItem.expand(); | |
| assertTrue("OpenOCD process was not found", | |
| projectItem.getNodes().contains("openocd")); | |
| } | |
| else | |
| { | |
| throw new AssertionError("Debug session not found in Debug view"); | |
| } | |
| } | |
| private static void thenGDBexeIsPresent() throws IOException | |
| { | |
| SWTBotTreeItem projectItem = fetchProjectFromDebugView(); | |
| if (projectItem != null) | |
| { | |
| projectItem.expand(); | |
| assertTrue("riscv32-esp-elf-gdb process was not found", | |
| projectItem.getNodes().contains("riscv32-esp-elf-gdb")); | |
| } | |
| else | |
| { | |
| throw new AssertionError("Debug session not found in Debug view"); | |
| } | |
| } |
Description
Add SWTBot test case to check Debug flow
Fixes # (IEP-989)
Type of change
How has this been tested?
Checklist
Summary by CodeRabbit