FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

test: refactor the code in test-dns-ipv6 by edsadr · Pull Request #10219 · nodejs/node · GitHub

/ node Public

test: refactor the code in test-dns-ipv6 - #10219

Closed
edsadr wants to merge 1 commit into
nodejs:masterfrom
edsadr:test-dns-ipv6
Closed

test: refactor the code in test-dns-ipv6#10219
edsadr wants to merge 1 commit into
nodejs:masterfrom
edsadr:test-dns-ipv6

Conversation

edsadr commented Dec 10, 2016

Copy link
Copy Markdown
Contributor
Checklist
  • make -j4 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
  • remove the manual control for functions execution
  • use common.mustCall to control the functions execution automatically
  • use let and const instead of var

nodejs-github-bot added dont-land-on-v7.x test Issues and PRs related to the tests. labels Dec 10, 2016
mscdex added the dns Issues and PRs related to the dns subsystem. label Dec 10, 2016
Comment thread test/internet/test-dns-ipv6.js Outdated

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.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Same deal as the other dns test refactor PR, this should be formatted better.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Fixing this now for both

edsadr commented Dec 10, 2016

Copy link
Copy Markdown
Contributor Author

@mscdex went for the arrow function, but in many cases even a new line was required, so idented them too, PTAL and if you are OK with this format will fix the other PR to match

Comment thread test/internet/test-dns-ipv6.js Outdated

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.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Nit: isIPv6 is already defined at the beginning of the file. We can use that consistently.

edsadr commented Dec 11, 2016

Copy link
Copy Markdown
Contributor Author

@thefourtheye just fixed it as suggested

Comment thread test/internet/test-dns-ipv6.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.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Nit: either assert.strictEqual(running, false); or assert(!running);.

edsadr commented Dec 11, 2016

Copy link
Copy Markdown
Contributor Author

@Trott just fixed as suggested

Copy link
Copy Markdown

edsadr commented Dec 13, 2016

Copy link
Copy Markdown
Contributor Author

the CI looks good, I guess just need the LGTM from @mscdex, @thefourtheye and @Trott about their requested changes

Trott commented Dec 13, 2016

Copy link
Copy Markdown
Member

@nodejs/testing

edsadr commented Dec 15, 2016

Copy link
Copy Markdown
Contributor Author

any feedback/update for this one? want to also update #10200 according which is also pending

Copy link
Copy Markdown

ping @nodejs/testing

Comment thread test/internet/test-dns-ipv6.js Outdated

santigimeno Dec 15, 2016
edited
Loading

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.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I would align the dns.resolve6 arguments

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

@santigimeno , sorry buts just learning about the codestyle, could you please provide an example of how to properly align this:

const req = dns.resolve6('ipv6.google.com',
    common.mustCall((err, ips) => {
      assert.ifError(err);

      assert.ok(ips.length > 0);

      for (let i = 0; i < ips.length; i++)
        assert.ok(isIPv6(ips[i]));

      done();
    }));```

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.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I would do something like this, but I don't think is that important:

TEST(function test_resolve6(done) {
  const req = dns.resolve6('ipv6.google.com',
                           common.mustCall((err, ips) => {
    assert.ifError(err);
    assert.ok(ips.length > 0);
    for (let i = 0; i < ips.length; i++)
      assert.ok(isIPv6(ips[i]));

    done();
  }));

  checkWrap(req);
});

edsadr Dec 16, 2016
edited by Trott
Loading

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

well... that way has problems with the linter as it is expecting the code to be like this:

const req = dns.resolve6('ipv6.google.com',
                            common.mustCall((err, ips) => {
                              assert.ifError(err);

                              assert.ok(ips.length > 0);

                              for (let i = 0; i < ips.length; i++)
                                assert.ok(isIPv6(ips[i]));

                              done();
                            }));

in the previous way I didn't have linter problems... just let me know what to do here then to keep the current or ident the whole function code...

I implemented all the other suggestions 🙂

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.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

@edsadr I think you have common.mustCall() and everything below it indented by 3 spaces too much. I think it should be like this:

const req = dns.resolve6('ipv6.google.com',
                         common.mustCall((err, ips) => {
                           assert.ifError(err);

                           assert.ok(ips.length > 0);

                           for (let i = 0; i < ips.length; i++)
                             assert.ok(isIPv6(ips[i]));

                           done();
                         }));

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.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

And, of course, you can always do something like this too:

const callback = common.mustCall((err, ipe) => {
  assert.ifError(err);
  ...
});

const req = dns.resolve6('ipv6.google.com', callback);

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.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

@edsadr forget about my styling comments. It's been more trouble than anything.

edsadr Dec 17, 2016
edited
Loading

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

no prob @santigimeno, still your suggestions helped me to learn a little bit about the codestyling ... I like @Trott suggestions, but I would propose to keep the current format for consistency, if I implement as suggested some other tests below will look weird... so.. what do you say?

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.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

@edsadr I think any reasonable indentation for this that the linter finds acceptable is acceptable by me. I think @santigimeno seems to feel the same.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Ok @Trott ... then I think I will let it with the current identation... is not offending the linter, and looks ok

Comment thread test/internet/test-dns-ipv6.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.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I think you can remove the braces

Comment thread test/internet/test-dns-ipv6.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.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

arg aligment

Comment thread test/internet/test-dns-ipv6.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.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I would do return done(); as in other places in the file and would get rid of the else

Comment thread test/internet/test-dns-ipv6.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.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Is this check really necessary?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

@santigimeno so, should I just remove the whole process.on('exit'.. ?

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.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Yes, that's what I was suggesting

Comment thread test/internet/test-dns-ipv6.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.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I think assert.ok(domains[i]); is redundant

Comment thread test/internet/test-dns-ipv6.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.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

maybe use assert.ifError(err); here

santigimeno 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.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

LGTM with some suggestions

Comment thread test/internet/test-dns-ipv6.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.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I would do something like this, but I don't think is that important:

TEST(function test_resolve6(done) {
  const req = dns.resolve6('ipv6.google.com',
                           common.mustCall((err, ips) => {
    assert.ifError(err);
    assert.ok(ips.length > 0);
    for (let i = 0; i < ips.length; i++)
      assert.ok(isIPv6(ips[i]));

    done();
  }));

  checkWrap(req);
});

Comment thread test/internet/test-dns-ipv6.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.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Style nit. I would rewrite it like this:

if (common.isFreeBSD) {
  assert(err instanceof Error);
  assert.strictEqual(err.code, 'EAI_BADFLAGS');
  assert.strictEqual(err.hostname, 'www.google.com');
  assert.ok(/getaddrinfo EAI_BADFLAGS/.test(err.message));
  return done();
}

assert.ifError(err);

Comment thread test/internet/test-dns-ipv6.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.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Yes, that's what I was suggesting

* remove the manual control for functions execution
* use common.mustCall to control the functions execution automatically
* use let and const instead of var
* use assert.strictEqual instead assert.equal

Copy link
Copy Markdown
Member

Copy link
Copy Markdown

Landed 5e781a3

italoacasas pushed a commit that referenced this pull request Dec 19, 2016
* remove the manual control for functions execution
* use common.mustCall to control the functions execution automatically
* use let and const instead of var
* use assert.strictEqual instead assert.equal

PR-URL: #10219
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
cjihrig pushed a commit to cjihrig/node that referenced this pull request Dec 20, 2016
* remove the manual control for functions execution
* use common.mustCall to control the functions execution automatically
* use let and const instead of var
* use assert.strictEqual instead assert.equal

PR-URL: nodejs#10219
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
italoacasas mentioned this pull request Dec 20, 2016
cjihrig pushed a commit that referenced this pull request Dec 20, 2016
* remove the manual control for functions execution
* use common.mustCall to control the functions execution automatically
* use let and const instead of var
* use assert.strictEqual instead assert.equal

PR-URL: #10219
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
MylesBorins pushed a commit that referenced this pull request Jan 22, 2017
* remove the manual control for functions execution
* use common.mustCall to control the functions execution automatically
* use let and const instead of var
* use assert.strictEqual instead assert.equal

PR-URL: #10219
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
MylesBorins pushed a commit that referenced this pull request Jan 24, 2017
* remove the manual control for functions execution
* use common.mustCall to control the functions execution automatically
* use let and const instead of var
* use assert.strictEqual instead assert.equal

PR-URL: #10219
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
MylesBorins mentioned this pull request Jan 24, 2017
MylesBorins pushed a commit that referenced this pull request Jan 31, 2017
* remove the manual control for functions execution
* use common.mustCall to control the functions execution automatically
* use let and const instead of var
* use assert.strictEqual instead assert.equal

PR-URL: #10219
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants


Back | FazBrowse Home | New Git URL