-
Notifications
You must be signed in to change notification settings - Fork 12k
test: improve test error message logs #23694
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
@@ -96,39 +96,47 @@ function _exec(options: ExecOptions, cmd: string, args: string[]): Promise<Proce | |||
_processes.push(childProcess); | |||
|
|||
// Create the error here so the stack shows who called this function. |
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.
Seems like this wasn't actually done before? Creating the error
with the stack trace at this point is the primary change. Otherwise the stack trace is always just the child_process exit/error stack which is useless.
// Return log info about the current process status | ||
function envDump() { | ||
return [ | ||
`ENV:${JSON.stringify(spawnOptions.env, null, 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.
This also changed but is a bit hard to see. It now outputs the env of the process being spawned, not the parent process - spawnOptions.env
isntead of process.env
. I think that is far more useful and probably the original intention?
@@ -96,39 +96,47 @@ function _exec(options: ExecOptions, cmd: string, args: string[]): Promise<Proce | |||
_processes.push(childProcess); | |||
|
|||
// Create the error here so the stack shows who called this function. | |||
let error: Error; |
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.
Wouldn't the below do the same?
let error: Error; | |
const error = new Error(); |
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.
Looks like you're correct. I always thought the stack was where the error was thrown, but it's actually just where it was constructed?
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.
That is correct. Can also change the catch
to which is more readable.
}).catch((err) => {
// Create the error here so the stack shows who called this function.
return Promise.reject(new Error(err));
});
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.
If you do the new Error
in the catch callback doesn't that mean the stack trace will be just the callback?
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.
right
f1cdb91
to
e5c5c4e
Compare
e5c5c4e
to
320f6ea
Compare
320f6ea
to
ac9a6c8
Compare
reject( | ||
`Process output didn't match - "${cmd} ${args.join(' ')}": '${ | ||
options.waitForMatch | ||
}': ${code}...\n\n${envDump()}\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.
Note both the code
(formerly error
) and the envDump()
were not here previously.
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. |
No description provided.