-
Notifications
You must be signed in to change notification settings - Fork 12
Add adapter restart validation to watch command tests #526
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: main
Are you sure you want to change the base?
Conversation
Co-authored-by: Apollon77 <11976694+Apollon77@users.noreply.github.com>
test/test-utils.js
Outdated
|
||
// Should see nodemon restart messages | ||
assert.ok( | ||
output.includes('restarting') || output.includes('restart'), |
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.
@copilot the second pattern is included in the first one. Please optimize
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.
Optimized to check only for 'restarting' (commit: {{COMMIT_HASH}})
test/test-utils.js
Outdated
* Validate that adapter restart occurred in watch mode | ||
*/ | ||
function validateWatchRestartOutput(output, adapterPrefix) { | ||
const assert = require('node:assert'); |
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.
@copilot do Not use local requires make them on start of file if needed
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.
Moved assert require to top of file (commit: {{COMMIT_HASH}})
test/test-utils.js
Outdated
// Should see the test variable deletion message at least twice | ||
const testVarMatches = output.match(new RegExp(`state ${adapterPrefix}\\.0\\.testVariable deleted`, 'g')); | ||
assert.ok( | ||
testVarMatches && testVarMatches.length >= 2, |
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.
@copilot why more then twice? Test as specific as possible. Potentially verify with multiple runs what can happen
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.
Changed to use === 2 for exact count validation (commit: {{COMMIT_HASH}})
/** | ||
* Run watch command with file change trigger to test adapter restart | ||
*/ | ||
function runCommandWithFileChange(command, args, options = {}) { |
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.
@copilot seems the new function is like the runCommandWithSignal and just adds a new file change logic but now duplicates a lot code. Refactor please.
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.
Refactored to use common runCommandWithTimeout function, eliminating code duplication (commit: {{COMMIT_HASH}})
Co-authored-by: Apollon77 <11976694+Apollon77@users.noreply.github.com>
assert
require to top of file=== 2
instead of>= 2
for exact countsrunCommandWithSignal
andrunCommandWithFileChange
Summary:
Enhanced watch command test suite with proper validation of adapter restart behavior. Refactored test utilities to use a common
runCommandWithTimeout
function that eliminates code duplication while maintaining clean separation of concerns through callback-based customization.Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.