Skip to content

Commit

Permalink
chore: Improve tests logging
Browse files Browse the repository at this point in the history
  • Loading branch information
3y3 committed Jan 9, 2025
1 parent e3c53c7 commit 94b50f7
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions tests/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ const assets = require('@diplodoc/client/manifest');
export function platformless(text: string) {
return text
.replace(/\r\n/g, '\n')
.replace(/(\\(?![\/"'])){1,2}/g, '/')
.replace(/(Config|Documentation)-\d+-\d+.\d+/g, '$1-RANDOM');
.replace(/(\\(?![\/"'])){1,2}/g, '/');
}

export function bundleless(text: string) {
Expand Down Expand Up @@ -60,15 +59,24 @@ interface RunYfmDocsArgs {
export function runYfmDocs(inputPath: string, outputPath: string, {md2md=true, md2html=true, args = ''}: RunYfmDocsArgs = {}): void {
shell.rm('-rf', outputPath);

const defaults = ` --quiet --allowHTML`;
const run = `node ${yfmDocsPath} --input ${inputPath} --output ${outputPath} ${defaults}`;

if (md2md && md2html) {
shell.rm('-rf', `${outputPath}-html`);

shell.exec(`node ${yfmDocsPath} --input ${inputPath} --output ${outputPath} --output-format=md --allowHTML --quiet ${args}`);
shell.exec(`node ${yfmDocsPath} --input ${outputPath} --output ${outputPath}-html --allowHTML --quiet ${args}`);
logResult(shell.exec(`${run} --output ${outputPath} -f md ${args}`));
logResult(shell.exec(`${run} --output ${outputPath}-html ${args}`));
} else if (md2md) {
shell.exec(`node ${yfmDocsPath} --input ${inputPath} --output ${outputPath} --output-format=md --allowHTML --quiet ${args}`);
logResult(shell.exec(`${run} --output ${outputPath} -f md ${args}`));
} else {
shell.exec(`node ${yfmDocsPath} --input ${inputPath} --output ${outputPath} --allowHTML --quiet ${args}`);
logResult(shell.exec(`${run} --output ${outputPath} ${args}`));
}
}

function logResult(result) {
if (result.code > 0) {
console.log('=== STDOUT ===\n' + result.stdout + '\n=== STDERR ===\n' + result.stderr);
}
}

Expand Down

0 comments on commit 94b50f7

Please sign in to comment.