test: fix flaky doctool and test · nodejs/node@b93c8a7 · GitHub
Skip to content

Commit b93c8a7

Browse files
Trotttargos
authored andcommitted
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: #29979 Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
1 parent a23b5cb commit b93c8a7

3 files changed

Lines changed: 19 additions & 34 deletions

File tree

test/doctool/test-doctool-html.js

Lines changed: 11 additions & 21 deletions

tools/doc/generate.js

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ if (!filename) {
6767
}
6868

6969

70-
fs.readFile(filename, 'utf8', (er, input) => {
70+
fs.readFile(filename, 'utf8', async (er, input) => {
7171
if (er) throw er;
7272

7373
const content = unified()
@@ -84,15 +84,10 @@ fs.readFile(filename, 'utf8', (er, input) => {
8484

8585
const basename = path.basename(filename, '.md');
8686

87-
html.toHTML(
88-
{ input, content, filename, nodeVersion },
89-
(err, html) => {
90-
const target = path.join(outputDir, `${basename}.html`);
91-
if (err) throw err;
92-
fs.writeFileSync(target, html);
93-
}
94-
);
87+
const myHtml = await html.toHTML({ input, content, filename, nodeVersion });
88+
const htmlTarget = path.join(outputDir, `${basename}.html`);
89+
fs.writeFileSync(htmlTarget, myHtml);
9590

96-
const target = path.join(outputDir, `${basename}.json`);
97-
fs.writeFileSync(target, JSON.stringify(content.json, null, 2));
91+
const jsonTarget = path.join(outputDir, `${basename}.json`);
92+
fs.writeFileSync(jsonTarget, JSON.stringify(content.json, null, 2));
9893
});

tools/doc/html.js

Lines changed: 2 additions & 2 deletions

0 commit comments

Comments
 (0)