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

Test: stdio.js SIGWINCH test coverage #10063

Closed

Conversation

sarahmeyer
Copy link
Contributor

Checklist
  • make -j8 test (UNIX), or vcbuild test nosign (Windows) passes
  • tests and/or benchmarks are included
  • commit message follows commit guidelines
Affected core subsystem(s)

test

Description of change

Provides coverage for calling process._refreshSize when a SIGWINCH is emitted within stderr and stdout functions in stdio.js

@nodejs-github-bot nodejs-github-bot added the test Issues and PRs related to the tests. label Dec 1, 2016
@sarahmeyer
Copy link
Contributor Author

@Fishrock123 peep it 👀 -- is this what you were going for?

@MylesBorins
Copy link
Contributor

ci: https://ci.nodejs.org/job/node-test-pull-request/5056/

@sarahmeyer great work! you will need to update the title of the first commit to follow our commit guidelines

@Trott
Copy link
Member

Trott commented Dec 1, 2016

SmartOS failure looks related.

@Fishrock123 Fishrock123 self-assigned this Dec 1, 2016
@Fishrock123
Copy link
Contributor

Hmmm, the following output occurs on SmartOS (Solaris):

not ok 1244 pseudo-tty/test-stderr-stdout-handle-sigwinch
  ---
  duration_ms: 0.319
  severity: fail
  stack: |-
    calling stdout._refreshSize
    events.js:160
          throw er; // Unhandled 'error' event
          ^
    
    Error: getWindowSize EINVAL
        at exports._errnoException (util.js:1022:11)
        at WriteStream._refreshSize (tty.js:78:24)
        at WriteStream.refreshSizeWrapperStdout [as _refreshSize] (/home/iojs/build/workspace/node-test-commit-smartos/nodes/smartos16-64/test/pseudo-tty/test-stderr-stdout-handle-sigwinch.js:15:36)
        at process.on (internal/process/stdio.js:16:43)
        at emitNone (events.js:91:20)
        at process.emit (events.js:185:7)
        at Object.<anonymous> (/home/iojs/build/workspace/node-test-commit-smartos/nodes/smartos16-64/test/pseudo-tty/test-stderr-stdout-handle-sigwinch.js:21:9)
        at Module._compile (module.js:571:32)
        at Object.Module._extensions..js (module.js:580:10)
        at Module.load (module.js:488:32)

I suspect that Python does not correctly emulate this on SmartOS but I'll try to take a deeper look soon.

Skipping on SmartOS may be the appropriate solution by the looks, though.

@addaleax addaleax added the code-and-learn Issues related to the Code-and-Learn events and PRs submitted during the events. label Dec 2, 2016
@Fishrock123
Copy link
Contributor

Fishrock123 commented Dec 3, 2016

@sarahmeyer As we briefly discussed, it would be useful to check the properties modifiable by tty.WriteStream#_refreshSize before and after we send the SIGWINCH.

I think everything should be the same so it also should not call the resize event, so I suppose we could listen and ensure that is not called.

We could also check for an error event on SmartOS rather than skipping, which would be a bit more robust.

Edit: Forgot to say most things like checking what platform we are running on have helpers in the common "module", such as isSunOS.

@mscdex mscdex added the tty Issues and PRs related to the tty subsystem. label Dec 3, 2016
@Fishrock123
Copy link
Contributor

Fishrock123 commented Dec 5, 2016

Got the coverage to (mostly) work locally, after some tweaking... You can find it at nodejs/testing#46 if you are interested.

(To run it, run (from the node repo) the pre-coverage.sh script, then node's make -j4 test, then the coverage.sh script. It will output to coverage-out in your $HOME directory currently.)

Suffice to say, this hits the correct paths (aside from the fact that the pty emulation always has the same values).

@Fishrock123
Copy link
Contributor

@sarahmeyer Think you'll be able to take a look this weekend?

@jbergstroem
Copy link
Member

/cc @nodejs/platform-smartos

@Trott
Copy link
Member

Trott commented Dec 22, 2016

Ping @sarahmeyer: Are you still working on this? (No rush. Just want to make sure it's not stalled and, if it is, see if there's anything we can do to get it un-stalled.)

@Trott
Copy link
Member

Trott commented Dec 26, 2016

I took the liberty of adding a few lines of code to swallow EINVAL error on SmartOS. Hope that's OK. Will remove or alter if CI doesn't pass (or if @sarahmeyer objects to the code).

CI: https://ci.nodejs.org/job/node-test-pull-request/5583/

(If CI passes and this gets approval, will squash my commit away on landing.)

@Trott
Copy link
Member

Trott commented Dec 26, 2016

CI is green. Reviews/comments? @sarahmeyer @Fishrock123 @nodejs/testing @nodejs/platform-smartos

Copy link
Member

@jasnell jasnell left a comment

Choose a reason for hiding this comment

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

LGTM with a nit

};

const refreshSizeWrapperStdout = () => {
console.log('calling stdout._refreshSize');
Copy link
Member

Choose a reason for hiding this comment

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

A comment indicating that the console.log is part of the test would be helpful.

Copy link
Member

Choose a reason for hiding this comment

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

Sure, done. Will run Ci again because there was some refactoring that accompanied it.

@Trott
Copy link
Member

Trott commented Dec 27, 2016

@Trott
Copy link
Member

Trott commented Dec 27, 2016

Not to bikeshed this thing forever, but it seems like we could wrap the functions in common.mustCall() and get rid of the console.log() statements and have an empty .out file. Any reason not to go that route? /cc @Fishrock123

@Trott
Copy link
Member

Trott commented Dec 27, 2016

Possible additional advantage to going that route: I think using the .status file will work for skipping the test on SmartOS. It will be more visible there (people will look there to see skipped tests rather than look through individual tests). And it keeps the test itself very simple, getting rid of the try...catch logic.

@Trott
Copy link
Member

Trott commented Dec 28, 2016

Going to land this working version. We can always switch to common.mustCall() instead in a subsequent change. Here's what that would look like:

'use strict';
const common = require('../common');

const originalRefreshSizeStderr = process.stderr._refreshSize;
const originalRefreshSizeStdout = process.stdout._refreshSize;

const wrap = (fn, ioStream, string) => {
  return common.mustCall(() => {
    try {
      fn.call(ioStream);
    } catch (e) {
      // EINVAL happens on SmartOS if emulation is incomplete
      if (!common.isSunOS || e.code !== 'EINVAL')
        throw e;
    }
  });
};

process.stderr._refreshSize = wrap(originalRefreshSizeStderr, process.stderr);
process.stdout._refreshSize = wrap(originalRefreshSizeStdout, process.stdout);

process.emit('SIGWINCH');

In that case, test/pseudo-tty/test-stderr-stdout-handle-sigwinch.out would be an empty file.

Trott pushed a commit to Trott/io.js that referenced this pull request Dec 28, 2016
PR-URL: nodejs#10063
Reviewed-By: James M Snell <jasnell@gmail.com>
@Trott
Copy link
Member

Trott commented Dec 28, 2016

Landed in a9b59ff.

Thanks for the contribution, @sarahmeyer! 🎉

@Trott Trott closed this Dec 28, 2016
evanlucas pushed a commit that referenced this pull request Jan 3, 2017
PR-URL: #10063
Reviewed-By: James M Snell <jasnell@gmail.com>
evanlucas pushed a commit that referenced this pull request Jan 4, 2017
PR-URL: #10063
Reviewed-By: James M Snell <jasnell@gmail.com>
MylesBorins pushed a commit that referenced this pull request Jan 23, 2017
PR-URL: #10063
Reviewed-By: James M Snell <jasnell@gmail.com>
MylesBorins pushed a commit that referenced this pull request Jan 23, 2017
PR-URL: #10063
Reviewed-By: James M Snell <jasnell@gmail.com>
@Fishrock123
Copy link
Contributor

heh, forgot to get back to this

This doesn't really test all that it should IIRC. I can give pointers for improvement if anyone else wants or otherwise I'll just do it myself I guess.

MylesBorins pushed a commit that referenced this pull request Jan 23, 2017
PR-URL: #10063
Reviewed-By: James M Snell <jasnell@gmail.com>
MylesBorins pushed a commit that referenced this pull request Jan 24, 2017
PR-URL: #10063
Reviewed-By: James M Snell <jasnell@gmail.com>
MylesBorins pushed a commit that referenced this pull request Jan 24, 2017
PR-URL: #10063
Reviewed-By: James M Snell <jasnell@gmail.com>
This was referenced Jan 24, 2017
MylesBorins pushed a commit that referenced this pull request Jan 31, 2017
PR-URL: #10063
Reviewed-By: James M Snell <jasnell@gmail.com>
MylesBorins pushed a commit that referenced this pull request Feb 1, 2017
PR-URL: #10063
Reviewed-By: James M Snell <jasnell@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
code-and-learn Issues related to the Code-and-Learn events and PRs submitted during the events. test Issues and PRs related to the tests. tty Issues and PRs related to the tty subsystem.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants