| 65 | ); |
| 66 | |
| 67 | function test(title, command, expectedName) { |
| 68 | const expectedPath = path.join(__dirname, expectedName); |
| 69 | const expected = fs.readFileSync(expectedPath, "utf8"); |
| 70 | |
| 71 | console.log(`Testing with Node.js ${process.version} - ${title}`); |
| 72 | const out = normalize( |
| 73 | cp.execSync( |
| 74 | `node ${ |
| 75 | major === 23 || (major === 22 && minor >= 12) |
| 76 | ? "--disable-warning=ExperimentalWarning " |
| 77 | : "" |
| 78 | }${command}`, |
| 79 | { |
| 80 | cwd: __dirname, |
| 81 | encoding: "utf8", |
| 82 | } |
| 83 | ) |
| 84 | ); |
| 85 | |
| 86 | if (expected === out) { |
| 87 | console.log("OK"); |
| 88 | } else if (process.env.OVERWRITE) { |
| 89 | fs.writeFileSync(expectedPath, out); |
| 90 | console.log("UPDATED"); |
| 91 | } else { |
| 92 | console.error("FAILED\n\n"); |
| 93 | console.error(out); |
| 94 | process.exitCode = 1; |
| 95 | } |
| 96 | console.log("\n"); |
| 97 | } |
| 98 | |
| 99 | function normalize(output) { |
| 100 | const root = path.resolve(__dirname, "../.."); |