Skip to content
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

🏗 Silence subprocesses in visual diffs by default #16704

Conversation

danielrozenberg
Copy link
Member

Per this comment: #16541 (comment)

@codecov-io
Copy link

codecov-io commented Jul 12, 2018

Codecov Report

Merging #16704 into master will decrease coverage by 0.03%.
The diff coverage is n/a.

@@            Coverage Diff             @@
##           master   #16704      +/-   ##
==========================================
- Coverage   78.12%   78.09%   -0.04%     
==========================================
  Files         553      553              
  Lines       40336    40325      -11     
==========================================
- Hits        31513    31492      -21     
- Misses       8823     8833      +10
Flag Coverage Δ
#integration_tests 34.91% <ø> (-0.03%) ⬇️
#unit_tests 77.16% <ø> (-0.03%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e2735b4...3f3ce4d. Read the comment docs.

Copy link
Contributor

@rsimha rsimha left a comment

Choose a reason for hiding this comment

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

A few comments below.

process.env.WEBSERVER_QUIET = '';
argv.chrome_debug = true; // eslint-disable-line google-camelcase/google-camelcase
argv.gulp_debug = true; // eslint-disable-line google-camelcase/google-camelcase
argv.webserver_debug = true; // eslint-disable-line google-camelcase/google-camelcase
Copy link
Contributor

Choose a reason for hiding this comment

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

I think you can avoid having to disable the camel case warning by using argv['chrome_debug'], etc.

Copy link
Member Author

Choose a reason for hiding this comment

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

Thank the heavens

@@ -62,9 +62,10 @@ exports.execScriptAsync = function(script, options) {
* Executes the provided command, and terminates the program in case of failure.
*
* @param {string} cmd Command line to execute.
* @param {<Object>} options extra options send to the process.
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: Extra options to send to the process

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

// The child node process has an asynchronous stdout. See #10409.
await sleep(100);
}
process.exit();
Copy link
Contributor

Choose a reason for hiding this comment

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

process.exit() doesn't do a clean exit, and could cause stray console output to be printed after the gulp process has printed its completion status. I see that you're doing a sleep after killing webServerProcess to avoid this.

A better way to signal task completion is to return a promise or call done(). If the exit code needs to be something other than 0, you can set the value of process.exitCode before signaling task completion.

Having said that, I'm not even sure you need to call process.exit here, since there's nothing more to do after returning from shutdown.

Copy link
Member Author

Choose a reason for hiding this comment

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

What is this "done" that you're talking about? I saw it in tests but not in any of the gulp files

Unfortunately the process doesn't exit unless I explicitly call process.exit(), for some reason
My guess is that somehow the child processes are hanging it. I'd be happy if you can help me figure this out! I want the process to exit cleanly...

Copy link
Contributor

Choose a reason for hiding this comment

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

done is just a callback you can pass to a gulp task (can be called anything). Look up the gulp 3.9 docs.

For the child task, you could try sending it a kill instead of an int, and then call done in the main task. If all that fails, add a TODO.

@@ -306,7 +319,8 @@ function cleanupAmpConfig() {
log('verbose', 'Cleaning up existing AMP config');
AMP_RUNTIME_TARGET_FILES.forEach(targetFile => {
execOrDie(
`gulp prepend-global --local_dev --target ${targetFile} --remove`);
`gulp prepend-global --local_dev --target ${targetFile} --remove`,
getStdioOptions(argv.gulp_debug));
Copy link
Contributor

Choose a reason for hiding this comment

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

gulp prepend-global doesn't really print any useful info, so I'm not convinced that the gulp_debug flag is necessary. (The log('verbose') above should be sufficient.)

I think you can simply pass in {'stdio': 'ignore'} here.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

`gulp prepend-global --local_dev --target ${targetFile} ` +
`--${config}`);
`gulp prepend-global --local_dev --target ${targetFile} --${config}`,
getStdioOptions(argv.gulp_debug));
Copy link
Contributor

Choose a reason for hiding this comment

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

Same comment as above.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

@@ -116,7 +116,7 @@ function setPercyBranch() {
async function launchWebServer() {
const gulpServeAsync = execScriptAsync(
`gulp serve --host ${HOST} --port ${PORT} ${process.env.WEBSERVER_QUIET}`,
{stdio: 'inherit'});
getStdioOptions(argv.gulp_debug || argv.webserver_debug));

gulpServeAsync.on('exit', code => {
if (code != 0) {
Copy link
Contributor

@rsimha rsimha Jul 12, 2018

Choose a reason for hiding this comment

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

I'm seeing an error code of null being returned by gulp serve in the .on('exit', ...) handler: https://travis-ci.org/ampproject/amphtml/jobs/403246979#L627

[18:55:04] ERROR: 'serve' errored with code null. Cannot continue with visual diff tests

From the spawn documentation, it appears you should be handling errors in .on('close', ...) and not .on('exit', ...).

@@ -116,7 +116,7 @@ function setPercyBranch() {
async function launchWebServer() {
const gulpServeAsync = execScriptAsync(
`gulp serve --host ${HOST} --port ${PORT} ${process.env.WEBSERVER_QUIET}`,
{stdio: 'inherit'});
getStdioOptions(argv.gulp_debug || argv.webserver_debug));
Copy link
Contributor

Choose a reason for hiding this comment

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

I think the server output should depend only on whether webserver_debug is enabled. This could be simplified to:

{'stdio': argv.webserver_debug ? 'inherit' : 'ignore'},

Copy link
Member Author

Choose a reason for hiding this comment

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

Sure, but in this case argv.gulp_debug becomes useless. I'll remove it too :)

* @param {boolean} shouldPrint true if the sub-process should print its output
* @return {<Object>} sub-process options
*/
function getStdioOptions(shouldPrint) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think this function is required. See other comments.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

* @param {!ChildProcess} webServerProcess the webserver process to shut down.
*/
async function shutdown(webServerProcess) {
if (webServerProcess.exitCode == null) {
Copy link
Contributor

@rsimha rsimha Jul 12, 2018

Choose a reason for hiding this comment

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

Is this check meant to see if webServerProcess is still running? If so, I think you can use webServerProcess.connected. See reference.

Copy link
Member Author

Choose a reason for hiding this comment

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

I failed to figure this out, and since the current code, fragile as it might be, "works™", I just added a TODO in your name to figure this out :)

@@ -62,7 +62,7 @@ exports.execScriptAsync = function(script, options) {
* Executes the provided command, and terminates the program in case of failure.
*
* @param {string} cmd Command line to execute.
* @param {<Object>} options extra options send to the process.
* @param {<Object>} options Extra options send to the process.
Copy link
Contributor

Choose a reason for hiding this comment

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

The nit was that you were missing to before send :)

Copy link
Member Author

Choose a reason for hiding this comment

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

🙄🙄🙄

@danielrozenberg danielrozenberg merged commit 7afc160 into ampproject:master Jul 13, 2018
@danielrozenberg danielrozenberg deleted the silence-visual-diff-logs-travis branch July 13, 2018 17:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants