@diplodoc/cli-tests 5.19.4 → 5.19.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/bin.mjs
CHANGED
|
@@ -7,22 +7,47 @@ import {createRequire} from 'node:module';
|
|
|
7
7
|
|
|
8
8
|
const require = createRequire(import.meta.url);
|
|
9
9
|
const vitestPath = require.resolve('vitest');
|
|
10
|
+
const configPath = resolve(dirname(fileURLToPath(import.meta.url)), 'vitest.config.ts');
|
|
10
11
|
|
|
11
|
-
|
|
12
|
+
let stdout = '';
|
|
13
|
+
let stderr = '';
|
|
14
|
+
|
|
15
|
+
const childProcess = execa(
|
|
12
16
|
join(dirname(vitestPath), 'vitest.mjs'),
|
|
13
|
-
[
|
|
14
|
-
'run',
|
|
15
|
-
'--config',
|
|
16
|
-
resolve(dirname(fileURLToPath(import.meta.url)), 'vitest.config.ts'),
|
|
17
|
-
...process.argv.slice(2),
|
|
18
|
-
],
|
|
17
|
+
['run', '--config', configPath, ...process.argv.slice(2)],
|
|
19
18
|
{
|
|
20
|
-
stdio: 'inherit',
|
|
21
|
-
env: {
|
|
22
|
-
|
|
23
|
-
NODE_ENV: 'test',
|
|
24
|
-
},
|
|
19
|
+
stdio: ['inherit', 'pipe', 'pipe'],
|
|
20
|
+
env: {...process.env, NODE_ENV: 'test'},
|
|
21
|
+
reject: false,
|
|
25
22
|
},
|
|
26
|
-
)
|
|
27
|
-
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
childProcess.stdout.on('data', (chunk) => {
|
|
26
|
+
const text = chunk.toString();
|
|
27
|
+
stdout += text;
|
|
28
|
+
process.stdout.write(chunk);
|
|
28
29
|
});
|
|
30
|
+
|
|
31
|
+
childProcess.stderr.on('data', (chunk) => {
|
|
32
|
+
const text = chunk.toString();
|
|
33
|
+
stderr += text;
|
|
34
|
+
process.stderr.write(chunk);
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
const result = await childProcess;
|
|
38
|
+
|
|
39
|
+
if (result.exitCode !== 0) {
|
|
40
|
+
const output = stdout + stderr;
|
|
41
|
+
const hasTimeout = /Test timed out|timed out in \d+ms/gi.test(output);
|
|
42
|
+
const exitCode = hasTimeout ? 124 : result.exitCode || 1;
|
|
43
|
+
|
|
44
|
+
const error = new Error(`Command failed with exit code ${result.exitCode}`);
|
|
45
|
+
error.exitCode = exitCode;
|
|
46
|
+
|
|
47
|
+
if (hasTimeout) {
|
|
48
|
+
const timeoutCount = (output.match(/Test timed out|timed out in \d+ms/gi) || []).length;
|
|
49
|
+
error.message += ` (${timeoutCount} timeout${timeoutCount > 1 ? 's' : ''} detected)`;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
process.exit(exitCode);
|
|
53
|
+
}
|
package/e2e/errors.spec.ts
CHANGED
|
@@ -9,15 +9,21 @@ type TestResult = {
|
|
|
9
9
|
html: Report;
|
|
10
10
|
};
|
|
11
11
|
|
|
12
|
-
function test(path: string, expect: Function) {
|
|
12
|
+
function test(path: string, expect: Function, additionalArgs: string[] = []) {
|
|
13
13
|
it(path, async () => {
|
|
14
14
|
const {inputPath, outputPath} = getTestPaths(path);
|
|
15
15
|
|
|
16
|
-
const md = await TestAdapter.build.run(inputPath, outputPath, [
|
|
16
|
+
const md = await TestAdapter.build.run(inputPath, outputPath, [
|
|
17
|
+
'-j2',
|
|
18
|
+
'-f',
|
|
19
|
+
'md',
|
|
20
|
+
...additionalArgs,
|
|
21
|
+
]);
|
|
17
22
|
const html = await TestAdapter.build.run(inputPath, outputPath + '-html', [
|
|
18
23
|
'-j2',
|
|
19
24
|
'-f',
|
|
20
25
|
'html',
|
|
26
|
+
...additionalArgs,
|
|
21
27
|
]);
|
|
22
28
|
return expect({md, html});
|
|
23
29
|
});
|
|
@@ -42,6 +48,16 @@ describe('Errors', () => {
|
|
|
42
48
|
]);
|
|
43
49
|
});
|
|
44
50
|
|
|
51
|
+
test(
|
|
52
|
+
'mocks/errors/max-asset-size',
|
|
53
|
+
({md}: TestResult) => {
|
|
54
|
+
expectErrors(md, [
|
|
55
|
+
'ERR YFM013 _images/large-image.png: YFM013 / File asset limit exceeded: 3057 (limit is 2048)',
|
|
56
|
+
]);
|
|
57
|
+
},
|
|
58
|
+
['--max-asset-size', '2K'],
|
|
59
|
+
);
|
|
60
|
+
|
|
45
61
|
it('translate extract with filtered links', async () => {
|
|
46
62
|
const {inputPath, outputPath} = getTestPaths('mocks/errors/extract-filtered-link');
|
|
47
63
|
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
href: index.md
|