test: refactor test-dgram-setBroadcast.js #11252

Closed
wants to merge 1 commit into
from

Conversation

Projects
None yet
5 participants
@cjihrig
Contributor

cjihrig commented Feb 9, 2017

This test wasn't actually working, as sockets were being closed, allowing the test to exit before any assertions were actually run. This commit refactors the test to maintain the same intended semantics.

If anyone is curious, I found this while looking at the code coverage report.

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

test

test: refactor test-dgram-setBroadcast.js
This test wasn't actually working, as sockets were being closed,
allowing the test to exit before any assertions were actually
run. This commit refactors the test to maintain the same intended
semantics.
@Trott

This comment has been minimized.

Show comment
Hide comment
@Trott

Trott Feb 9, 2017

Member

I don't think test-dgram-membership is afflicted with the same issue, but is it worth refactoring out its identical setup() anyway as a precaution or anything? (I have no opinion either way.)

Member

Trott commented Feb 9, 2017

I don't think test-dgram-membership is afflicted with the same issue, but is it worth refactoring out its identical setup() anyway as a precaution or anything? (I have no opinion either way.)

@Trott

Trott approved these changes Feb 9, 2017

LGTM if CI is green

@mscdex mscdex added the dgram label Feb 9, 2017

@cjihrig

This comment has been minimized.

Show comment
Hide comment
@cjihrig

cjihrig Feb 9, 2017

Contributor

@Trott it looks like test-dgram-membership is fine. I'll probably update it a little bit to at least improve the error message checking with assert.throws().

The problem with this test isn't setup(). The problem here is that the test would synchronously call bind() and then teardown the socket. At least on my machine, this means that nothing was keeping the event loop open, and the code inside the bind() callback was never getting a chance to execute. This seems to be the case on the machine where code coverage was running as well.

Contributor

cjihrig commented Feb 9, 2017

@Trott it looks like test-dgram-membership is fine. I'll probably update it a little bit to at least improve the error message checking with assert.throws().

The problem with this test isn't setup(). The problem here is that the test would synchronously call bind() and then teardown the socket. At least on my machine, this means that nothing was keeping the event loop open, and the code inside the bind() callback was never getting a chance to execute. This seems to be the case on the machine where code coverage was running as well.

@jasnell

jasnell approved these changes Feb 9, 2017

@cjihrig

This comment has been minimized.

Show comment
Hide comment

jasnell added a commit that referenced this pull request Feb 11, 2017

test: refactor test-dgram-setBroadcast.js
This test wasn't actually working, as sockets were being closed,
allowing the test to exit before any assertions were actually
run. This commit refactors the test to maintain the same intended
semantics.

PR-URL: #11252
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
@jasnell

This comment has been minimized.

Show comment
Hide comment
@jasnell

jasnell Feb 11, 2017

Member

Landed in fe2b5f0

Member

jasnell commented Feb 11, 2017

Landed in fe2b5f0

@jasnell jasnell closed this Feb 11, 2017

italoacasas added a commit that referenced this pull request Feb 13, 2017

test: refactor test-dgram-setBroadcast.js
This test wasn't actually working, as sockets were being closed,
allowing the test to exit before any assertions were actually
run. This commit refactors the test to maintain the same intended
semantics.

PR-URL: #11252
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>

italoacasas added a commit to italoacasas/node that referenced this pull request Feb 14, 2017

test: refactor test-dgram-setBroadcast.js
This test wasn't actually working, as sockets were being closed,
allowing the test to exit before any assertions were actually
run. This commit refactors the test to maintain the same intended
semantics.

PR-URL: nodejs#11252
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>

KryDos added a commit to KryDos/node that referenced this pull request Feb 25, 2017

test: refactor test-dgram-setBroadcast.js
This test wasn't actually working, as sockets were being closed,
allowing the test to exit before any assertions were actually
run. This commit refactors the test to maintain the same intended
semantics.

PR-URL: nodejs#11252
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>

jasnell added a commit that referenced this pull request Mar 7, 2017

test: refactor test-dgram-setBroadcast.js
This test wasn't actually working, as sockets were being closed,
allowing the test to exit before any assertions were actually
run. This commit refactors the test to maintain the same intended
semantics.

PR-URL: #11252
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
@jasnell

This comment has been minimized.

Show comment
Hide comment
@jasnell

jasnell Mar 7, 2017

Member

would need a backport PR to land in v4

Member

jasnell commented Mar 7, 2017

would need a backport PR to land in v4

MylesBorins added a commit that referenced this pull request Mar 9, 2017

test: refactor test-dgram-setBroadcast.js
This test wasn't actually working, as sockets were being closed,
allowing the test to exit before any assertions were actually
run. This commit refactors the test to maintain the same intended
semantics.

PR-URL: #11252
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>

@MylesBorins MylesBorins referenced this pull request Mar 9, 2017

Merged

v6.10.1 proposal #11759

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment