-
Notifications
You must be signed in to change notification settings - Fork 12k
test: watch full stdout when waiting for match #23767
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
Conversation
@@ -17,7 +17,7 @@ export default async function () { | |||
]; | |||
}); | |||
|
|||
const errorMessage = await expectToFail(() => ng('build')); |
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.
errorMessage
is an Error
and this was relying on errorMessage.toString()
in the .test
below. When making the expectToFail
return type stricter this becomes an error.
`STDOUT:\n${stdout}`, | ||
`STDERR:\n${stderr}`, | ||
].join('\n\n'); | ||
} |
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.
Everything above here was just moved into the new Promise
so the waitForMatch
logic in the callbacks can resolve
the promise.
childProcess.stdout!.on('data', (data: Buffer) => { | ||
stdout += data.toString('utf-8'); | ||
|
||
if (options.waitForMatch && stdout.match(options.waitForMatch)) { |
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.
Previously this did data.match
which in theory could fail if the stdout was spread across multiple 'data'
events (this was in the deleted if (options.waitForMatch
below). Same with stderr
.
.forEach((line) => console.error(colors.yellow(' ' + line))); | ||
}); | ||
|
||
childProcess.on('close', (code: number) => { |
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.
Note this changed from exit
to close
to ensure stdout/err have completed:
https://nodejs.org/api/child_process.html#event-close
The 'close' event is emitted after a process has ended and the stdio streams of a child process have been closed
https://nodejs.org/api/child_process.html#event-exit
When the 'exit' event is triggered, child process stdio streams might still be open.
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
... and cleanup a few typescript types.
I've been debugging a failing test where stderr is not being matched. I tried these fixes and figured they may as well be merged? 🤷