Skip to content

Conversation

@jasnell
Copy link
Member

@jasnelljasnell commented Mar 25, 2017

Adds a cctest for the new native URL class

Depends on: #11801 and #11956

/cc @bmeck@TimothyGu

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)

url, test

@jasnelljasnell added dont-land-on-v4.x whatwg-url Issues and PRs related to the WHATWG URL implementation. labels Mar 25, 2017
@nodejs-github-botnodejs-github-bot added build Issues and PRs related to build files or the CI. c++ Issues and PRs that require attention from people who are familiar with C++. dont-land-on-v4.x whatwg-url Issues and PRs related to the WHATWG URL implementation. labels Mar 25, 2017
@mscdexmscdex added test Issues and PRs related to the tests. and removed build Issues and PRs related to build files or the CI. labels Mar 26, 2017
Copy link
Member

Choose a reason for hiding this comment

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

Nit: Why not CHECK_EQ(simple.protocol(), "https:");?

Copy link
Member

Choose a reason for hiding this comment

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

I’d just put this once at the top level instead of having it in each test, tbh

@jasnelljasnellforce-pushed the native-url-test branch 2 times, most recently from e62c36f to 6d369a1CompareMarch 27, 2017 01:45
@jasnell
Copy link
MemberAuthor

Copy link
Contributor

Choose a reason for hiding this comment

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

Just wondering for future reference if it is preferred to use CHECK_EQ instead of EXPECT_EQ?
The difference seems to be that CHECK_EQ will abort straight away without allowing for the rest of the tests to be run, whereas EXPECT_EQ which is non-fatal and would allow for the rest of the tests to be run and report the errors afterwards.

For example, using CHECK_EQ and forcing a check to fail:

[ RUN ] URLTest.Simple Assertion failed: ((simple.protocol()) == ("httpsss")), function TestBody, file ../test/cctest/test_url.cc, line 23. make: *** [cctest] Abort trap: 6 

Compared to EXPECT_EQ, and forcing a the expectation to fail:

[ RUN ] URLTest.Simple ../test/cctest/test_url.cc:24: Failure Value of: "httpss:" Expected: simple.protocol() Which is: "https:" [ FAILED ] URLTest.Simple (13 ms) ... [ PASSED ] 36 tests. [ FAILED ] 1 test, listed below: [ FAILED ] URLTest.Simple 

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

Good point. I'd actually forgotten that EXPECT_EQ existed :-) I'll switch it up to use that instead.

src/node_url.h Outdated
Copy link
Member

Choose a reason for hiding this comment

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

Is there a reason for this change?

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

Yes, when node_url.h is included in the cctest/test_url.h, a compile error occurs because the url_error_cb_args is defined multiple times. I had to make similar changes to the other structs defined in this file. It would likely be good to refactor the node_url.h file a bit if we intend for it to be generally includable in more than just node_url.cc.

@jasnell
Copy link
MemberAuthor

@jasnell
Copy link
MemberAuthor

CI failures are unrelated.

jasnell added a commit that referenced this pull request Mar 27, 2017
PR-URL: #12042 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Joyee Cheung <[email protected]> Reviewed-By: Timothy Gu <[email protected]> Reviewed-By: Daijiro Wachi <[email protected]>
@jasnell
Copy link
MemberAuthor

Landed in 51b007a

@jasnelljasnell closed this Mar 27, 2017
@jasnelljasnell reopened this Mar 27, 2017
@addaleax
Copy link
Member

@jasnell Reopened by accident?

@jasnell
Copy link
MemberAuthor

Yep lol.

@jasnelljasnell closed this Mar 27, 2017
@MylesBorins
Copy link
Contributor

This needs a manual backport to v7.x

@aqrln
Copy link
Contributor

@MylesBorins it will cherry-pick cleanly after #12321.

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

Labels

c++Issues and PRs that require attention from people who are familiar with C++.testIssues and PRs related to the tests.whatwg-urlIssues and PRs related to the WHATWG URL implementation.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

11 participants

@jasnell@addaleax@MylesBorins@aqrln@danbev@TimothyGu@watilde@joyeecheung@mscdex@gibfahn@nodejs-github-bot