Skip to content

IEP-1767 shouldHaveClangFilesPresentAndContentCorrectForNewProject test is not stable#1461

Merged
kolipakakondal merged 4 commits into
masterfrom
IEP-1767
May 19, 2026
Merged

IEP-1767 shouldHaveClangFilesPresentAndContentCorrectForNewProject test is not stable#1461
kolipakakondal merged 4 commits into
masterfrom
IEP-1767

Conversation

@sigmaaa
Copy link
Copy Markdown
Collaborator

@sigmaaa sigmaaa commented May 14, 2026

Description

This PR contains a refactor of the test by replacing assertTrue with assertEquals for better diffs, as well as a test fix. The test was failing because we expected CompilationDatabase as the build value after creating a new project, but it is actually an absolute path now.

Fixes # (IEP-1767)

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)

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
    • Tightened automated checks by switching to strict equality assertions for file presence.
    • Improved editor-content comparisons using normalized text (consistent line endings and trimmed whitespace) to reduce flakiness.
    • Enhanced validation of clang-related config files and main-source formatting, including verification of build-path-specific compilation database entries.

Review Change Stack

@sigmaaa sigmaaa self-assigned this May 14, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 14, 2026

📝 Walkthrough

Walkthrough

Refactors NewEspressifIDFProjectClangFilesTest to use assertEquals and a new assertTextEqualsNormalized helper, replacing helper-based editor checks with direct active-editor text comparisons and explicit boolean presence assertions for .clangd and .clang-format.

Changes

Clang Files Test Assertion Refactoring

Layer / File(s) Summary
Static import refactoring
tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/NewEspressifIDFProjectClangFilesTest.java
Static import changed from assertTrue to assertEquals for assertion handling.
Test flow update
tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/NewEspressifIDFProjectClangFilesTest.java
After opening .clangd, the test now calls thenClangdFileContentChecked(CLEAN_PROJECT1) immediately to validate .clangd content.
Normalization helper added
tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/NewEspressifIDFProjectClangFilesTest.java
Added assertTextEqualsNormalized(...) to normalize \r\n/\r to \n, trim outer whitespace, and assert equality via assertEquals.
File presence and absence verification
tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/NewEspressifIDFProjectClangFilesTest.java
File existence checks use getNodes().contains(...) with explicit assertEquals(true/false) assertions instead of assertTrue/negated assertTrue.
Editor content verification for .clangd, .clang-format, and main file
tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/NewEspressifIDFProjectClangFilesTest.java
Consolidated .clangd checks into thenClangdFileContentChecked(projectName) and compare active editor text directly to expected strings using assertTextEqualsNormalized(...); replaced ProjectTestOperations helper comparisons.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested reviewers

  • kolipakakondal
  • AndriiFilippov

Poem

🐰 I hop through tests with tidy zest,
Replacing asserts for checks more blessed.
I read the editor, normalize each line,
Trim the edges, let comparisons shine.
Clang files verified — the rabbit's work is done!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly summarizes the main change: fixing instability in a specific test by improving assertion methods for better diagnostics.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch IEP-1767

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a 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

🧹 Nitpick comments (3)
tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/NewEspressifIDFProjectClangFilesTest.java (3)

251-252: 💤 Low value

Consider whether trim() might mask whitespace issues.

Applying trim() to both expected and actual text makes the test more lenient but may hide legitimate formatting problems. If the actual .clang-format file has unexpected trailing whitespace or newlines, this test won't detect it. Since .clang-format is a YAML configuration file where whitespace can matter, consider whether this tolerance is appropriate or if exact matching (including trailing whitespace) would catch more issues.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/NewEspressifIDFProjectClangFilesTest.java`
around lines 251 - 252, The test in NewEspressifIDFProjectClangFilesTest
currently uses assertEquals("ClangFormat content did not match",
expectedText.trim(), actualText.trim()), which may hide legitimate
trailing-whitespace/newline differences in the .clang-format YAML; change the
assertion to compare exact content (remove trim() calls) so it asserts
expectedText.equals(actualText) via assertEquals("ClangFormat content did not
match", expectedText, actualText), or alternatively normalize only line endings
(e.g., replace "\r\n" with "\n") but do not strip trailing whitespace/newlines
before asserting to ensure true formatting differences are detected.

157-158: ⚡ Quick win

Prefer assertTrue/assertFalse for boolean assertions.

Using assertEquals(true/false, boolean) doesn't provide better failure diagnostics than assertTrue/assertFalse for boolean values. The benefit of assertEquals for richer diffs applies to complex objects and strings, not to simple boolean comparisons where the output is just "expected: true, actual: false".

♻️ Revert to idiomatic boolean assertions
-		boolean isPresent = bot.tree().getTreeItem(projectName).getNodes().contains(".clangd");
-		assertEquals("The .clangd file should be present", true, isPresent);
+		assertTrue("The .clangd file should be present", 
+			bot.tree().getTreeItem(projectName).getNodes().contains(".clangd"));
-		boolean isPresent = bot.tree().getTreeItem(projectName).getNodes().contains(".clang-format");
-		assertEquals("The .clang-format file should be present", true, isPresent);
+		assertTrue("The .clang-format file should be present",
+			bot.tree().getTreeItem(projectName).getNodes().contains(".clang-format"));
-		boolean isPresent = bot.tree().getTreeItem(projectName).getNodes().contains(".clangd");
-		assertEquals("The .clangd file should be absent", false, isPresent);
+		assertFalse("The .clangd file should be absent",
+			bot.tree().getTreeItem(projectName).getNodes().contains(".clangd"));

Also applies to: 163-164, 177-178

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/NewEspressifIDFProjectClangFilesTest.java`
around lines 157 - 158, Replace boolean equality assertions using assertEquals
with the idiomatic boolean assertions assertTrue/assertFalse: change the
assertion that checks the boolean variable isPresent (in
NewEspressifIDFProjectClangFilesTest, where you call
bot.tree().getTreeItem(projectName).getNodes().contains(".clangd")) to
assertTrue when expecting presence (and assertFalse for absence). Apply the same
replacement for the other boolean checks referenced in the comment (the
assertions around the same pattern at the other occurrences noted).

304-305: ⚡ Quick win

Using trim() in a formatting verification test may defeat its purpose.

This test validates that Clang-Format correctly applied formatting settings. Using trim() on both expected and actual text means trailing whitespace differences won't be detected. If Clang-Format produces unexpected trailing spaces or newlines, this test won't catch it. Consider whether exact byte-for-byte matching (without trim()) would provide stronger validation of the formatting behavior.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/NewEspressifIDFProjectClangFilesTest.java`
around lines 304 - 305, The test NewEspressifIDFProjectClangFilesTest currently
uses assertEquals("Formatted main file content did not match",
expectedText.trim(), actualText.trim()); which hides trailing whitespace/newline
differences; update the assertion to compare expectedText and actualText exactly
(remove trim()) so the test asserts byte-for-byte equality, or if line-ending
normalization is required, normalize both strings to a consistent newline
sequence first and then assert exact equality using the same assertEquals call.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/NewEspressifIDFProjectClangFilesTest.java`:
- Around line 218-221: The test uses direct assertEquals on
bot.activeEditor().toTextEditor().getText() which skips the prior
line-ending/whitespace normalization and will fail on Windows; restore
normalization by either calling the existing helper
checkExactMatchInTextEditor(...) or normalize actualText before asserting
(replace CRLF "\r\n" with "\n" and trim trailing spaces on each line) so
NewEspressifIDFProjectClangFilesTest compares platform-independent text content;
update both assertion sites (the assertEquals at the getText() usage and the
similar one at the later lines) to use the same normalization helper or inline
normalization.

---

Nitpick comments:
In
`@tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/NewEspressifIDFProjectClangFilesTest.java`:
- Around line 251-252: The test in NewEspressifIDFProjectClangFilesTest
currently uses assertEquals("ClangFormat content did not match",
expectedText.trim(), actualText.trim()), which may hide legitimate
trailing-whitespace/newline differences in the .clang-format YAML; change the
assertion to compare exact content (remove trim() calls) so it asserts
expectedText.equals(actualText) via assertEquals("ClangFormat content did not
match", expectedText, actualText), or alternatively normalize only line endings
(e.g., replace "\r\n" with "\n") but do not strip trailing whitespace/newlines
before asserting to ensure true formatting differences are detected.
- Around line 157-158: Replace boolean equality assertions using assertEquals
with the idiomatic boolean assertions assertTrue/assertFalse: change the
assertion that checks the boolean variable isPresent (in
NewEspressifIDFProjectClangFilesTest, where you call
bot.tree().getTreeItem(projectName).getNodes().contains(".clangd")) to
assertTrue when expecting presence (and assertFalse for absence). Apply the same
replacement for the other boolean checks referenced in the comment (the
assertions around the same pattern at the other occurrences noted).
- Around line 304-305: The test NewEspressifIDFProjectClangFilesTest currently
uses assertEquals("Formatted main file content did not match",
expectedText.trim(), actualText.trim()); which hides trailing whitespace/newline
differences; update the assertion to compare expectedText and actualText exactly
(remove trim()) so the test asserts byte-for-byte equality, or if line-ending
normalization is required, normalize both strings to a consistent newline
sequence first and then assert exact equality using the same assertEquals call.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 5f73a6ed-e220-474c-94e3-ebf686f542cb

📥 Commits

Reviewing files that changed from the base of the PR and between 559f443 and d20a821.

📒 Files selected for processing (1)
  • tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/NewEspressifIDFProjectClangFilesTest.java

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a 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

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/NewEspressifIDFProjectClangFilesTest.java`:
- Line 69: The test calls Fixture.thenClangFormatContentChecked() immediately
after opening ".clangd" which is wrong because ".clang-format" isn't opened yet;
replace that invocation with Fixture.thenClangdContentChecked() so the check
verifies the opened ".clangd" buffer (method names:
thenClangFormatContentChecked -> thenClangdContentChecked, context:
NewEspressifIDFProjectClangFilesTest test that opens ".clangd" before checking
content) and keep the existing thenClangFormatContentChecked() call later where
".clang-format" is actually opened.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 7e77c26c-4c0d-4816-a61f-05ba3dbb9bc2

📥 Commits

Reviewing files that changed from the base of the PR and between d20a821 and dec595a.

📒 Files selected for processing (1)
  • tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/NewEspressifIDFProjectClangFilesTest.java

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (4)
tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/NewEspressifIDFProjectClangFilesTest.java (4)

235-253: 💤 Low value

Remove redundant trim() calls.

The assertTextEqualsNormalized helper already trims both strings (line 128-129), so the explicit .trim() calls on line 252 are redundant. The comment on line 251 suggests concern about text block processing, but the helper already handles this.

♻️ Simplified version
-		// Using trim() to avoid mismatch purely due to trailing spaces/newlines from text block processing
-		assertTextEqualsNormalized("ClangFormat content did not match", expectedText.trim(), actualText.trim());
+		assertTextEqualsNormalized("ClangFormat content did not match", expectedText, actualText);
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/NewEspressifIDFProjectClangFilesTest.java`
around lines 235 - 253, The helper thenClangFormatContentChecked calls
assertTextEqualsNormalized("ClangFormat content did not match",
expectedText.trim(), actualText.trim()) but assertTextEqualsNormalized already
normalizes/trims both inputs, so remove the redundant .trim() calls on
expectedText and actualText in thenClangFormatContentChecked and update/keep the
comment to reflect that normalization is handled by assertTextEqualsNormalized;
locate the method name thenClangFormatContentChecked and the assertion call to
make the change.

166-167: 💤 Low value

Consider using assertTrue for boolean presence checks.

While assertEquals(true, isPresent) works correctly, assertTrue(isPresent) is more idiomatic for boolean assertions and provides the same diff quality. The benefit of assertEquals for better diffs mainly applies to comparing complex objects or strings where seeing both values side-by-side is helpful.

♻️ Alternative using assertTrue
-		boolean isPresent = bot.tree().getTreeItem(projectName).getNodes().contains(".clangd");
-		assertEquals("The .clangd file should be present", true, isPresent);
+		boolean isPresent = bot.tree().getTreeItem(projectName).getNodes().contains(".clangd");
+		assertTrue("The .clangd file should be present", isPresent);

And similarly for .clang-format:

-		boolean isPresent = bot.tree().getTreeItem(projectName).getNodes().contains(".clang-format");
-		assertEquals("The .clang-format file should be present", true, isPresent);
+		boolean isPresent = bot.tree().getTreeItem(projectName).getNodes().contains(".clang-format");
+		assertTrue("The .clang-format file should be present", isPresent);

Also applies to: 172-173

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/NewEspressifIDFProjectClangFilesTest.java`
around lines 166 - 167, Replace the boolean equality assertions that use
assertEquals(true, isPresent) in the NewEspressifIDFProjectClangFilesTest with
assertTrue(isPresent); specifically update the assertion that validates the
presence of the ".clangd" file (variable isPresent) to use assertTrue and do the
same for the similar check that validates the ".clang-format" file to make the
boolean checks more idiomatic.

288-307: 💤 Low value

Remove redundant trim() calls.

Similar to the clang-format check, the explicit .trim() calls on lines 305-306 are redundant since assertTextEqualsNormalized already trims both strings.

♻️ Simplified version
-		assertTextEqualsNormalized("Formatted main file content did not match", expectedText.trim(),
-				actualText.trim());
+		assertTextEqualsNormalized("Formatted main file content did not match", expectedText, actualText);
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/NewEspressifIDFProjectClangFilesTest.java`
around lines 288 - 307, The test method
checkMainFileContentFormattedUnderActualSettings contains redundant .trim()
calls on both expectedText and actualText when calling
assertTextEqualsNormalized; remove the .trim() invocations so you pass the raw
expectedText and actualText to assertTextEqualsNormalized (which already
normalizes/trims inputs) and keep the rest of the method intact.

186-187: 💤 Low value

Consider using assertFalse for boolean absence checks.

Similar to the presence checks, assertFalse(isPresent) is more idiomatic than assertEquals(false, isPresent) for boolean assertions.

♻️ Alternative using assertFalse
-		boolean isPresent = bot.tree().getTreeItem(projectName).getNodes().contains(".clangd");
-		assertEquals("The .clangd file should be absent", false, isPresent);
+		boolean isPresent = bot.tree().getTreeItem(projectName).getNodes().contains(".clangd");
+		assertFalse("The .clangd file should be absent", isPresent);
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/NewEspressifIDFProjectClangFilesTest.java`
around lines 186 - 187, Replace the boolean equality assertion with an idiomatic
boolean assertion: in NewEspressifIDFProjectClangFilesTest where you compute
boolean isPresent =
bot.tree().getTreeItem(projectName).getNodes().contains(".clangd"), change the
assertion from assertEquals("The .clangd file should be absent", false,
isPresent) to use assertFalse (either assertFalse("The .clangd file should be
absent", isPresent) or assertFalse(isPresent)) so the test expresses absence
more clearly and follows JUnit conventions.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In
`@tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/NewEspressifIDFProjectClangFilesTest.java`:
- Around line 235-253: The helper thenClangFormatContentChecked calls
assertTextEqualsNormalized("ClangFormat content did not match",
expectedText.trim(), actualText.trim()) but assertTextEqualsNormalized already
normalizes/trims both inputs, so remove the redundant .trim() calls on
expectedText and actualText in thenClangFormatContentChecked and update/keep the
comment to reflect that normalization is handled by assertTextEqualsNormalized;
locate the method name thenClangFormatContentChecked and the assertion call to
make the change.
- Around line 166-167: Replace the boolean equality assertions that use
assertEquals(true, isPresent) in the NewEspressifIDFProjectClangFilesTest with
assertTrue(isPresent); specifically update the assertion that validates the
presence of the ".clangd" file (variable isPresent) to use assertTrue and do the
same for the similar check that validates the ".clang-format" file to make the
boolean checks more idiomatic.
- Around line 288-307: The test method
checkMainFileContentFormattedUnderActualSettings contains redundant .trim()
calls on both expectedText and actualText when calling
assertTextEqualsNormalized; remove the .trim() invocations so you pass the raw
expectedText and actualText to assertTextEqualsNormalized (which already
normalizes/trims inputs) and keep the rest of the method intact.
- Around line 186-187: Replace the boolean equality assertion with an idiomatic
boolean assertion: in NewEspressifIDFProjectClangFilesTest where you compute
boolean isPresent =
bot.tree().getTreeItem(projectName).getNodes().contains(".clangd"), change the
assertion from assertEquals("The .clangd file should be absent", false,
isPresent) to use assertFalse (either assertFalse("The .clangd file should be
absent", isPresent) or assertFalse(isPresent)) so the test expresses absence
more clearly and follows JUnit conventions.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 0d6199bf-f630-4162-a450-165c79da9e24

📥 Commits

Reviewing files that changed from the base of the PR and between dec595a and 8cc1465.

📒 Files selected for processing (1)
  • tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/NewEspressifIDFProjectClangFilesTest.java

@sigmaaa sigmaaa changed the title WIP: test: use assertEquals for better diffs IEP-1767 shouldHaveClangFilesPresentAndContentCorrectForNewProject test is not stable May 15, 2026
Copy link
Copy Markdown
Collaborator

@AndriiFilippov AndriiFilippov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@kolipakakondal kolipakakondal merged commit c9d69a0 into master May 19, 2026
8 of 9 checks passed
@kolipakakondal kolipakakondal deleted the IEP-1767 branch May 19, 2026 12:40
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.

3 participants