| 46 | |
| 47 | // Build our project for E2E testing |
| 48 | function buildProject() { |
| 49 | const ROOT_DIR = path.join(__dirname, '..'); |
| 50 | const buildCommand = "npm run build"; |
| 51 | |
| 52 | console.log("\n\n🛠 Building dogescript...\n") |
| 53 | return new Promise((resolve, reject) => { |
| 54 | /** |
| 55 | * Compile the binary for testing |
| 56 | */ |
| 57 | exec(`cd ${ROOT_DIR} && ${buildCommand}`, { encoding: 'UTF-8' }, (error, stdout, stderr) => { |
| 58 | const errorOutput = stderr.toString(); |
| 59 | const stdOutput = stdout.toString(); |
| 60 | const errMsg = "Failed to start testing suite, compiler build failed. Check details above or err.log"; |
| 61 | |
| 62 | if (error || errorOutput) { |
| 63 | console.log(error); |
| 64 | console.error(errorOutput); |
| 65 | console.error(stdOutput); |
| 66 | console.error(errMsg) |
| 67 | |
| 68 | if (!fs.existsSync('./test_out/compiler')){ |
| 69 | fs.mkdirSync('./test_out/compiler', {recursive: true}); |
| 70 | } |
| 71 | fs.writeFileSync('./test_out/compiler/err.txt', error); |
| 72 | fs.writeFileSync('./test_out/compiler/out.log', stdOutput); |
| 73 | fs.writeFileSync('./test_out/compiler/err.log', errorOutput); |
| 74 | |
| 75 | reject([ |
| 76 | new Error(errMsg), |
| 77 | stdOutput, |
| 78 | errorOutput, |
| 79 | ]); |
| 80 | } |
| 81 | |
| 82 | resolve(); |
| 83 | }); |
| 84 | }); |
| 85 | } |
| 86 | |
| 87 | // Takes a specFileMapping and transforms it into a serializable format |
| 88 | // For the test suite to use (globals are not permitted) |