Skip to content

test: fix broken tests in test-buffer-includes#12040

Closed
aqrln wants to merge 1 commit into
nodejs:masterfrom
aqrln:fix-test-buffer-includes
Closed

test: fix broken tests in test-buffer-includes#12040
aqrln wants to merge 1 commit into
nodejs:masterfrom
aqrln:fix-test-buffer-includes

Conversation

@aqrln

@aqrln aqrln commented Mar 25, 2017

Copy link
Copy Markdown
Contributor

Some of the tests for buffer.includes() functionality introduced in #3567 have been broken in a way that caused them to always pass regardless of the result of the tested method.

This behavior was caused by two reasons:

  • These tests were written as though buffer.includes() was supposed to return the same value that buffer.indexOf() does, i.e., used indices or -1 as expected return values instead of true and false.
  • assert() was used as the assertion function to do that instead of assert.strictEqual().

Thus assert() was called with a non-zero number as the first argument effectively causing these tests to pass.

This commit changes the tests to use assert.ok() and assert.ifError() and removes redundant indices.

Refs: #3567

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • commit message follows commit guidelines
Affected core subsystem(s)

test

@nodejs-github-bot nodejs-github-bot added the test Issues and PRs related to the tests. label Mar 25, 2017

@Trott Trott left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM if CI is ✅. /cc @nodejs/testing

@mscdex mscdex added the buffer Issues and PRs related to the buffer subsystem. label Mar 26, 2017
Comment thread test/parallel/test-buffer-includes.js Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nit: I would use assert.ok(!...) for consistency and proper thrown error in case of failure

@aqrln aqrln force-pushed the fix-test-buffer-includes branch from aaf7a0a to 9e040a1 Compare March 26, 2017 15:25
@aqrln

aqrln commented Mar 26, 2017

Copy link
Copy Markdown
Contributor Author

Updated the PR to address @lpinca's feedback.

@cjihrig cjihrig left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I can never remember if the indentation should be two or four spaces in these cases, but it looks like this PR uses both. Could you pick one or the other. Other than that, LGTM.

Some of the tests for `buffer.includes()` functionality introduced in
nodejs#3567 have been broken in a way that
caused them to always pass regardless of the result of the tested
method.

This behavior was caused by two reasons:

 * These tests were written as though `buffer.includes()` was supposed
   to return the same value that `buffer.indexOf()` does, i.e., used
   indices or -1 as expected return values instead of true and false.
 * `assert()` was used as the assertion function to do that instead of
   `assert.strictEqual()`.

Thus `assert()` was called with a non-zero number as the first argument
effectively causing these tests to pass.

This commit changes the tests to use `assert.ok()` and removes redundant
indices.

Refs: nodejs#3567
@aqrln aqrln force-pushed the fix-test-buffer-includes branch from 9e040a1 to b9977cf Compare March 26, 2017 16:15
@aqrln

aqrln commented Mar 26, 2017

Copy link
Copy Markdown
Contributor Author

@cjihrig thanks for catching that, the PR has been updated. I've chosen four for this commit because it is more common throughout the file, but it is not consistent even in existing code. I guess I'll open a new PR that fixes the code style in this file.

@hiroppy

hiroppy commented Mar 26, 2017

Copy link
Copy Markdown
Member

@aqrln

aqrln commented Mar 26, 2017

Copy link
Copy Markdown
Contributor Author

Failed tests on CentOS 5:

  • parallel/test-dns-regress-6244
  • parallel/test-net-connect-options-ipv6

and on Windows:

  • parallel/test-child-process-exec-kill-throws

are unrelated to this PR, but it think we should investigate those tests.

Troubles on test/arm-fanned (pi1-raspbian-wheezy):

java.io.IOException: Failed to create a temp file on /home/iojs/build/workspace/node-test-binary-arm
java.io.IOException: No space left on device

@gibfahn

gibfahn commented Mar 26, 2017

Copy link
Copy Markdown
Member

@cjihrig I think it's 4 spaces for run-on lines, so that if you have:

while ("Some really really really really really long string" === 
    somethingElse.toString())
  doThis();

The somethingElse.toString() is clearly separate from the doThis().

Seems like something that should be in the STYLE_GUIDE though (except that the STYLE_GUIDE currently doesn't cover code), I assume we don't lint for it because sometimes we want visual linting, but I'm not sure (cc/ @not-an-aardvark, is this something that we could easily lint for)?

Visual linting:

while ("Some really really really really really long string" === 
       somethingElse.toString())
  doThis();

@gibfahn

gibfahn commented Mar 26, 2017

Copy link
Copy Markdown
Member

@aqrln parallel/test-child-process-exec-kill-throws failure is unrelated to this PR, see #11038 (comment)

@not-an-aardvark

Copy link
Copy Markdown
Contributor

(cc/ @not-an-aardvark, is this something that we could easily lint for)?

The built-in indent rule doesn't check for this, but we could probably make a custom rule for it if we wanted to.

@aqrln

aqrln commented Mar 26, 2017

Copy link
Copy Markdown
Contributor Author

@gibfahn I think we can lint that run-on lines are indented with at least four spaces. That should cover both cases.

@aqrln

aqrln commented Mar 27, 2017

Copy link
Copy Markdown
Contributor Author

dont-land-on-v4.x and lts-watch-v6.x labels should be added, I suppose.

@aqrln

aqrln commented Mar 27, 2017

Copy link
Copy Markdown
Contributor Author

@gibfahn is the dont-land-on-v6.x label intentional? It cherry-picks cleanly to v6.x-staging but maybe I'm missing something.

@targos

targos commented Mar 27, 2017

Copy link
Copy Markdown
Member

That was probably a mistake. I changed the label.

@jasnell

jasnell commented Mar 27, 2017

Copy link
Copy Markdown
Member

CI failures are unrelated

jasnell pushed a commit that referenced this pull request Mar 27, 2017
Some of the tests for `buffer.includes()` functionality introduced in
#3567 have been broken in a way that
caused them to always pass regardless of the result of the tested
method.

This behavior was caused by two reasons:

 * These tests were written as though `buffer.includes()` was supposed
   to return the same value that `buffer.indexOf()` does, i.e., used
   indices or -1 as expected return values instead of true and false.
 * `assert()` was used as the assertion function to do that instead of
   `assert.strictEqual()`.

Thus `assert()` was called with a non-zero number as the first argument
effectively causing these tests to pass.

This commit changes the tests to use `assert.ok()` and removes redundant
indices.

PR-URL: #12040
Ref: #3567
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Yuta Hiroto <hello@about-hiroppy.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
@jasnell

jasnell commented Mar 27, 2017

Copy link
Copy Markdown
Member

Landed in 52b666e

@jasnell jasnell closed this Mar 27, 2017
@aqrln aqrln deleted the fix-test-buffer-includes branch March 27, 2017 17:33
@aqrln

aqrln commented Mar 28, 2017

Copy link
Copy Markdown
Contributor Author

@jasnell btw, I see that you changed Refs: to Ref: in the commit message. I'm fine with both, but I thought Refs: was standardized in #10670.

@gibfahn

gibfahn commented Mar 28, 2017

Copy link
Copy Markdown
Member

@aqrln Ref is what node-review uses.

Ref: is still okay, we just suggest Refs: because it was used by more people.

EDIT: nodejs/node-review#9 has landed, so we should be good going forward!

@aqrln

aqrln commented Mar 28, 2017

Copy link
Copy Markdown
Contributor Author

@gibfahn okay, thanks for clarifying this.

gibfahn added a commit to gibfahn/node-review that referenced this pull request Mar 28, 2017
MylesBorins pushed a commit that referenced this pull request Mar 28, 2017
Some of the tests for `buffer.includes()` functionality introduced in
#3567 have been broken in a way that
caused them to always pass regardless of the result of the tested
method.

This behavior was caused by two reasons:

 * These tests were written as though `buffer.includes()` was supposed
   to return the same value that `buffer.indexOf()` does, i.e., used
   indices or -1 as expected return values instead of true and false.
 * `assert()` was used as the assertion function to do that instead of
   `assert.strictEqual()`.

Thus `assert()` was called with a non-zero number as the first argument
effectively causing these tests to pass.

This commit changes the tests to use `assert.ok()` and removes redundant
indices.

PR-URL: #12040
Ref: #3567
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Yuta Hiroto <hello@about-hiroppy.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
@MylesBorins MylesBorins mentioned this pull request Mar 28, 2017
evanlucas pushed a commit to nodejs/node-review that referenced this pull request Mar 29, 2017
@italoacasas italoacasas mentioned this pull request Apr 10, 2017
2 tasks
MylesBorins pushed a commit that referenced this pull request Apr 18, 2017
Some of the tests for `buffer.includes()` functionality introduced in
#3567 have been broken in a way that
caused them to always pass regardless of the result of the tested
method.

This behavior was caused by two reasons:

 * These tests were written as though `buffer.includes()` was supposed
   to return the same value that `buffer.indexOf()` does, i.e., used
   indices or -1 as expected return values instead of true and false.
 * `assert()` was used as the assertion function to do that instead of
   `assert.strictEqual()`.

Thus `assert()` was called with a non-zero number as the first argument
effectively causing these tests to pass.

This commit changes the tests to use `assert.ok()` and removes redundant
indices.

PR-URL: #12040
Ref: #3567
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Yuta Hiroto <hello@about-hiroppy.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
MylesBorins pushed a commit that referenced this pull request Apr 19, 2017
Some of the tests for `buffer.includes()` functionality introduced in
#3567 have been broken in a way that
caused them to always pass regardless of the result of the tested
method.

This behavior was caused by two reasons:

 * These tests were written as though `buffer.includes()` was supposed
   to return the same value that `buffer.indexOf()` does, i.e., used
   indices or -1 as expected return values instead of true and false.
 * `assert()` was used as the assertion function to do that instead of
   `assert.strictEqual()`.

Thus `assert()` was called with a non-zero number as the first argument
effectively causing these tests to pass.

This commit changes the tests to use `assert.ok()` and removes redundant
indices.

PR-URL: #12040
Ref: #3567
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Yuta Hiroto <hello@about-hiroppy.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
@MylesBorins MylesBorins mentioned this pull request Apr 19, 2017
andrew749 pushed a commit to michielbaird/node that referenced this pull request Jul 19, 2017
Some of the tests for `buffer.includes()` functionality introduced in
nodejs/node#3567 have been broken in a way that
caused them to always pass regardless of the result of the tested
method.

This behavior was caused by two reasons:

 * These tests were written as though `buffer.includes()` was supposed
   to return the same value that `buffer.indexOf()` does, i.e., used
   indices or -1 as expected return values instead of true and false.
 * `assert()` was used as the assertion function to do that instead of
   `assert.strictEqual()`.

Thus `assert()` was called with a non-zero number as the first argument
effectively causing these tests to pass.

This commit changes the tests to use `assert.ok()` and removes redundant
indices.

PR-URL: nodejs/node#12040
Ref: nodejs/node#3567
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Yuta Hiroto <hello@about-hiroppy.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
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

buffer Issues and PRs related to the buffer subsystem. test Issues and PRs related to the tests.

Projects

None yet

Development

Successfully merging this pull request may close these issues.