mirror of
https://github.com/nodejs/node.git
synced 2026-11-27 17:52:27 -05:00
test: fix flaky doctool and test
Doctool tests have been failing a lot in CI on Win2008 R2. It appears async functions and callback-based functions are being used in combination such that the callback-based function cannot guarantee that it will invoke its callback. Convert the callback-based functions to async functions so we have one paradigm and reliable results. PR-URL: https://github.com/nodejs/node/pull/29979 Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
This commit is contained in:
1 parent
a23b5cbf61
commit
b93c8a77a3
3 files changed
+19
-34
No files matched your search
@@ -22,7 +22,7 @@ const remark2rehype = require('remark-rehype');
|
||||
const raw = require('rehype-raw');
|
||||
const htmlStringify = require('rehype-stringify');
|
||||
|
||||
function toHTML({ input, filename, nodeVersion }, cb) {
|
||||
async function toHTML({ input, filename, nodeVersion }) {
|
||||
const content = unified()
|
||||
.use(markdown)
|
||||
.use(html.firstHeader)
|
||||
@@ -34,10 +34,7 @@ function toHTML({ input, filename, nodeVersion }, cb) {
|
||||
.use(htmlStringify)
|
||||
.processSync(input);
|
||||
|
||||
html.toHTML(
|
||||
{ input, content, filename, nodeVersion },
|
||||
cb
|
||||
);
|
||||
return html.toHTML({ input, content, filename, nodeVersion });
|
||||
}
|
||||
|
||||
// Test data is a list of objects with two properties.
|
||||
@@ -107,23 +104,16 @@ testData.forEach(({ file, html }) => {
|
||||
// Normalize expected data by stripping whitespace.
|
||||
const expected = html.replace(spaces, '');
|
||||
|
||||
readFile(file, 'utf8', common.mustCall((err, input) => {
|
||||
readFile(file, 'utf8', common.mustCall(async (err, input) => {
|
||||
assert.ifError(err);
|
||||
toHTML(
|
||||
{
|
||||
input: input,
|
||||
filename: 'foo',
|
||||
nodeVersion: process.version,
|
||||
},
|
||||
common.mustCall((err, output) => {
|
||||
assert.ifError(err);
|
||||
const output = await toHTML({ input: input,
|
||||
filename: 'foo',
|
||||
nodeVersion: process.version });
|
||||
|
||||
const actual = output.replace(spaces, '');
|
||||
// Assert that the input stripped of all whitespace contains the
|
||||
// expected markup.
|
||||
assert(actual.includes(expected),
|
||||
`ACTUAL: ${actual}\nEXPECTED: ${expected}`);
|
||||
})
|
||||
);
|
||||
const actual = output.replace(spaces, '');
|
||||
// Assert that the input stripped of all whitespace contains the
|
||||
// expected markup.
|
||||
assert(actual.includes(expected),
|
||||
`ACTUAL: ${actual}\nEXPECTED: ${expected}`);
|
||||
}));
|
||||
});
|
||||
Reference in new issue
Block a user