8000 test: add command line test for multi-search-replace by KJ7LNW · Pull Request #2220 · RooCodeInc/Roo-Code · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

test: add command line test for multi-search-replace #2220

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

Merged
merged 1 commit into from
Jun 2, 2025

Conversation

KJ7LNW
Copy link
Collaborator
@KJ7LNW KJ7LNW commented Apr 2, 2025

Context

This PR will address apply_diff related issues mentioned in #1713. We've added a command line test capability to the multi-search-replace diff strategy to start trying out known issues.

Implementation

So far just bootstrapping test harness. Added a new test case that allows testing the multi-search-replace diff strategy directly from the command line by passing source and diff files as arguments. This enables easier debugging and manual testing of the diff application functionality without needing to modify test code for each test case.

The test can be run with:

npx jest src/core/diff/strategies/__tests__/multi-search-replace.test.ts -t 'should process diff' -- --source <file.ts> --diff <diff.diff>

How to Test

  • Create a sample source file and diff file
  • Run the test with the command above, passing your files as arguments
  • The test will display the source content, diff content, and the result of applying the diff

Get in Touch

Discord: KJ7LNW

Will help with #1713


Important

Adds command line test for MultiSearchReplaceDiffStrategy in multi-search-replace.test.ts to process diffs using command line arguments.

  • Testing:
    • Adds command line test in multi-search-replace.test.ts for MultiSearchReplaceDiffStrategy.
    • Test processes diffs using --source and --diff command line arguments.
    • Outputs first 50 lines of source and diff files, applies diff, and displays result.
  • Usage:
    • Run with: npx jest src/core/diff/strategies/__tests__/multi-search-replace.test.ts -t 'should process diff' -- --source <file.ts> --diff <diff.diff>.
  • Misc:

This description was created by Ellipsis for 37e83d5. You can customize this summary. It will automatically update as commits are pushed.

Adds a new test case that allows testing the multi-search-replace diff strategy directly from the command line by passing source and diff files as arguments.

This enables easier debugging and manual testing of the diff application functionality without needing to modify test code for each test case.

Signed-off-by: Eric Wheeler <roo-code@z.ewheeler.org>
Copy link
changeset-bot bot commented Apr 2, 2025

⚠️ No Changeset found

Latest commit: 37e83d5

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@KJ7LNW
Copy link
Collaborator Author
KJ7LNW commented Apr 2, 2025

See also: #1234 (comment)

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Apr 2, 2025
@KJ7LNW KJ7LNW mentioned this pull request Apr 3, 2025
@hannesrudolph hannesrudolph moved this from New to PR [Pre Approval Review] in Roo Code Roadmap Apr 6, 2025
@hannesrudolph hannesrudolph moved this from PR [Pre Approval Review] to PR [Draft/WIP] in Roo Code Roadmap May 10, 2025
@hannesrudolph hannesrudolph moved this from New to PR [Draft/WIP] in Roo Code Roadmap May 20, 2025
@hannesrudolph hannesrudolph moved this from PR [Draft / In Progress] to TEMP in Roo Code Roadmap May 26, 2025
@hannesrudolph hannesrudolph marked this pull request as ready for review May 26, 2025 17:57
@hannesrudolph hannesrudolph requested a review from cte as a code owner May 26, 2025 17:57
@hannesrudolph hannesrudolph moved this from TEMP to PR [Needs Review] in Roo Code Roadmap May 26, 2025
8000
}
}

if (!sourceFile || !diffFile) {
Copy link

Choose a reason for hiding this comment

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

Avoid silently returning when required file arguments are missing. Instead, consider using test.skip or explicitly failing so that missing arguments don't yield a false positive.

`=============================== END ================================\n`,
)
expect(result.success).toBe(true)
} else {
Copy link

Choose a reason for hiding this comment

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

Ensure the test fails when diff application is unsuccessful by adding an assertion or calling fail() in the else branch. Currently, the else branch only logs output without failing the test.

@hannesrudolph hannesrudolph moved this from PR [Needs Review] to TEMP in Roo Code Roadmap May 26, 2025
@hannesrudolph hannesrudolph moved this from TEMP to PR [Needs Review] in Roo Code Roadmap May 26, 2025
process.stdout.write(
`====================================================================\n`,
)
process.stdout.write(result.content + "\n")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Hey @KJ7LNW, for this line where result.content is printed: does it make sense to print the whole content here since it might be long? Or perhaps print only the first 50 lines, similar to how the input source (line 1411) and diff (line 1430) are truncated?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is really a debugging tool wrapped in jest, not a test itself: this is just for debugging for direct user interact , it is not intended for automated testing.

I wrote this because I was troubleshooting some apply_diff problems and I have been collecting you failed samples from a number of bug reports. In order to understand the issue when a diff fails to apply I almost always need to see the entire output.

Maybe the line limit should be trimmed, but I specifically remember not wanting it to trim: the model originally wrote this trimming the output, but I had to tell it not to because I needed to see it all at once to compare what was happening.

@daniel-lxs daniel-lxs moved this from Needs Preliminary Review to PR [Changes Requested] in Roo Code Roadmap May 27, 2025
@daniel-lxs daniel-lxs moved this from PR [Changes Requested] to PR [Needs Review] in Roo Code Roadmap May 28, 2025
@daniel-lxs
Copy link
Collaborator

Looks good to me, this is useful for quickly testing changes to the multi-search-replace tool whenever someone decides to improve it.

@mrubens mrubens merged commit b39080c into RooCodeInc:main Jun 2, 2025
33 checks passed
@github-project-automation github-project-automation bot moved this from PR [Draft/WIP] to Done in Roo Code Roadmap Jun 2, 2025
@github-project-automation github-project-automation bot moved this from PR [Needs Review] to Done in Roo Code Roadmap Jun 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lgtm This PR has been approved by a maintainer PR - Needs Review
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

4 participants
0