|
1 |
| -const fs = require('fs') |
2 |
| -const path = require('path') |
3 |
| -const child_process = require('child_process') |
4 |
| -const rescript_exe = require("../../../scripts/bin_path").rescript_exe |
| 1 | +const fs = require("fs"); |
| 2 | +const path = require("path"); |
| 3 | +const child_process = require("child_process"); |
| 4 | +const rescript_exe = require("../../../scripts/bin_path").rescript_exe; |
5 | 5 |
|
6 |
| -const expectedFilePath = path.join(__dirname, 'out.expected') |
| 6 | +const expectedFilePath = path.join(__dirname, "out.expected"); |
7 | 7 |
|
8 |
| -const updateTests = process.argv[2] === 'update' |
| 8 | +const updateTests = process.argv[2] === "update"; |
9 | 9 |
|
10 |
| -function postProcessErrorOutput (output) { |
11 |
| - output = output.trimRight() |
12 |
| - output = output.replace(new RegExp(__dirname, 'gi'), '.') |
13 |
| - return output |
| 10 | +function postProcessErrorOutput(output) { |
| 11 | + output = output.trimRight(); |
| 12 | + output = output.replace(new RegExp(__dirname, "gi"), "."); |
| 13 | + return output; |
14 | 14 | }
|
15 |
| -child_process.execSync(`${rescript_exe} clean`,{cwd:__dirname}) |
16 |
| -child_process.exec(rescript_exe, {cwd: __dirname}, (err, stdout, stderr) => { |
17 |
| - const actualErrorOutput = postProcessErrorOutput(stderr.toString()) |
| 15 | +child_process.execSync(`${rescript_exe} clean`, { cwd: __dirname }); |
| 16 | +child_process.exec(rescript_exe, { cwd: __dirname }, (err, stdout, stderr) => { |
| 17 | + const actualErrorOutput = postProcessErrorOutput(stderr.toString()); |
18 | 18 | if (updateTests) {
|
19 |
| - fs.writeFileSync(expectedFilePath, actualErrorOutput) |
| 19 | + fs.writeFileSync(expectedFilePath, actualErrorOutput); |
20 | 20 | } else {
|
21 |
| - const expectedErrorOutput = postProcessErrorOutput(fs.readFileSync(expectedFilePath, {encoding: 'utf-8'})) |
| 21 | + const expectedErrorOutput = postProcessErrorOutput( |
| 22 | + fs.readFileSync(expectedFilePath, { encoding: "utf-8" }) |
| 23 | + ); |
22 | 24 | if (expectedErrorOutput !== actualErrorOutput) {
|
23 |
| - console.error(`The old and new error output aren't the same`) |
24 |
| - console.error('\n=== Old:') |
25 |
| - console.error(expectedErrorOutput) |
26 |
| - console.error('\n=== New:') |
27 |
| - console.error(actualErrorOutput) |
28 |
| - process.exit(1) |
| 25 | + console.error(`The old and new error output aren't the same`); |
| 26 | + console.error("\n=== Old:"); |
| 27 | + console.error(expectedErrorOutput); |
| 28 | + console.error("\n=== New:"); |
| 29 | + console.error(actualErrorOutput); |
| 30 | + process.exit(1); |
29 | 31 | }
|
30 | 32 | }
|
31 |
| -}) |
32 |
| - |
33 |
| - |
| 33 | +}); |
0 commit comments