-
Notifications
You must be signed in to change notification settings - Fork 30k
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 doctool #6031
Test doctool #6031
Conversation
Should these tests be including in the Are we going to want to run these in ci? /cc @nodejs/build |
@thealphanerd I put them there because tools/doc is its own independent package which could be distributed separately from node code. |
|
||
if (err) throw err; | ||
assert(output.source == 'foo'); | ||
assert(JSON.stringify(output) == JSON.stringify(item.json)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reason not to use assert.equal(output.source, 'foo')
, assert.deepStrictEqual(output, item.json)
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because I didn't know those existed. Let me fix that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
931ff1d
to
f240d02
Compare
Should definitely run in ci.
I think these tests should be in docs/ |
This PR adds |
Yes. Tests should go in the As far as where in the |
I see the logic there and wouldn't stand in the way if others agreed. I look at it this way, though: All tests for the project are in the |
CI runs the |
Another argument for adding these to the project-wide EDIT: Putting them in |
Last comment for now, I promise, sorry for the storm of notifications: YES YES YES! +100 to having some tests for the doc tools. |
@Trott I don't have access to a windows system. I could put some code in vcbuild.bat and hope that it works if you'd like. |
One more benefit to putting these tests in |
@Trott here's a version with the tests living under |
💯 😍 👍 |
@thealphanerd @jasnell I'm adding the |
@@ -0,0 +1,50 @@ | |||
'use strict'; | |||
|
|||
var assert = require('assert'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit (which means you can ignore this comment if you want to): The project has been favoring const
over var
for module imports like this.
👍 |
I think that is pretty much what @silverwind intended. Good stuff. |
}); | ||
} | ||
|
||
test_toHTML(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we not wrap this in a function. With this being the only thing in the file, it's a bit redundant.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
Thanks for the contribution! I'm with @Trott. Please make every variable I would prefer that we keep these in the |
// Test data is a list of objects with two properties. | ||
// The file property is the file path. | ||
// The html property is some html which will be generated by the doctool. | ||
// This html will be stripped of all whitespace. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe change the comment to state that it will be stripped of all unnecessary whitespace?
Edit: disregard. I just realized why you were doing that. Maybe update the comment to be more clear?
Looks like CI passed. |
Looks like the new tests got picked up fine: https://ci.nodejs.org/job/node-test-commit-linux/3062/nodes=debian8-64/tapTestReport/test.tap-1065/ LGTM |
7da4fd4
to
c7066fb
Compare
@silverwind Is there anyone else I need to get to take a look at this? |
fs.readFile(item.file, 'utf8', common.mustCall(function(err, input) { | ||
assert.ifError(err); | ||
html(input, 'foo', 'doc/template.html', | ||
common.mustCall(function(err, output) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't common.mustCall...
be aligned with input
?
@iankronquist after you've handled above comments, I suggest you squash the commits into a single one and add a nice summary of the changes in the commit message. |
Addresses nodejs#5955 on GitHub. * Test the toHTML function in html.js. Check that given valid markdown it produces the expected html. One test case will prevent regressions of big nodejs#5873. * Check that when given valid markdown toJSON produces valid JSON with the expected schema. * Add doctool to the list of built in tests so it runs in CI.
b7968ed
to
94318cd
Compare
@silverwind fixed & squashed. |
* Test the toHTML function in html.js. Check that given valid markdown it produces the expected html. One test case will prevent regressions of #5873. * Check that when given valid markdown toJSON produces valid JSON with the expected schema. * Add doctool to the list of built in tests so it runs in CI. PR-URL: #6031 Fixes: #5955 Reviewed-By: Roman Reiss <[email protected]> Reviewed-By: Rich Trott <[email protected]>
Thanks! Landed in 2e845f8 with some minor corrections to the commit message. Nice work! |
Yes, really nice. Thx for the effort. Time to try it myself :) Awesome guys. |
@silverwind excellent, thanks! |
* Test the toHTML function in html.js. Check that given valid markdown it produces the expected html. One test case will prevent regressions of #5873. * Check that when given valid markdown toJSON produces valid JSON with the expected schema. * Add doctool to the list of built in tests so it runs in CI. PR-URL: #6031 Fixes: #5955 Reviewed-By: Roman Reiss <[email protected]> Reviewed-By: Rich Trott <[email protected]>
if someone would like to see this landed it will need to be manually backported |
@thealphanerd didn't this land in 2e845f8? Do you mean landed in the next release? |
Sorry for not being exact... I was referring to lts |
* Test the toHTML function in html.js. Check that given valid markdown it produces the expected html. One test case will prevent regressions of #5873. * Check that when given valid markdown toJSON produces valid JSON with the expected schema. * Add doctool to the list of built in tests so it runs in CI. PR-URL: #6031 Fixes: #5955 Reviewed-By: Roman Reiss <[email protected]> Reviewed-By: Rich Trott <[email protected]>
* Test the toHTML function in html.js. Check that given valid markdown it produces the expected html. One test case will prevent regressions of #5873. * Check that when given valid markdown toJSON produces valid JSON with the expected schema. * Add doctool to the list of built in tests so it runs in CI. PR-URL: #6031 Fixes: #5955 Reviewed-By: Roman Reiss <[email protected]> Reviewed-By: Rich Trott <[email protected]>
* Test the toHTML function in html.js. Check that given valid markdown it produces the expected html. One test case will prevent regressions of #5873. * Check that when given valid markdown toJSON produces valid JSON with the expected schema. * Add doctool to the list of built in tests so it runs in CI. PR-URL: #6031 Fixes: #5955 Reviewed-By: Roman Reiss <[email protected]> Reviewed-By: Rich Trott <[email protected]>
Pull Request check-list
make -j8 test
(UNIX) orvcbuild test nosign
(Windows) pass withthis change (including linting)?
test (or a benchmark) included?
existing APIs, or introduces new ones)? (N/A)
Affected core subsystem(s)
tools/doc
Description of change
Add tests for tools/doc. Fixes #5955. Includes tests for the functions toHTML (in html.js) and doJSON (in json.js). Also includes a regression test for #5873. Also introduces a new make target to run the tests.
I expect to be asked to squash these commits.