2020-03-19 22:56:40 +03:00
|
|
|
const fs = require('fs');
|
2020-03-24 19:15:55 +03:00
|
|
|
const path = require('path');
|
2020-03-19 22:56:40 +03:00
|
|
|
const { execSync } = require("child_process");
|
|
|
|
|
|
|
|
const files = fs.readdirSync(__dirname);
|
|
|
|
const elmFiles = files.filter(file => file.endsWith(".elm"));
|
|
|
|
|
|
|
|
elmFiles.forEach(elmFile => {
|
2020-03-24 19:15:55 +03:00
|
|
|
const expectedOutput = fs.readFileSync(path.join(__dirname, `${elmFile.slice(0, -4)}.txt`), 'utf8');
|
2020-03-19 22:56:40 +03:00
|
|
|
|
|
|
|
try {
|
|
|
|
const output = execSync(`elm make ./${elmFile}`, {encoding:"utf8", stdio: 'pipe', cwd: __dirname}).toString();
|
|
|
|
console.log(`ERROR: File ${elmFile} compiled, though it shouldn't have!`);
|
|
|
|
process.exit(1);
|
|
|
|
}
|
|
|
|
catch (error) {
|
|
|
|
if (error.stderr !== expectedOutput) {
|
|
|
|
console.log(`ERROR: File ${elmFile} failed to compile, but with the wrong error message!`);
|
|
|
|
console.log(`EXPECTED:\n\n${expectedOutput}\n\n`);
|
|
|
|
console.log(`GOT:\n\n${error.stderr}`);
|
|
|
|
process.exit(1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
2020-03-20 22:53:09 +03:00
|
|
|
|
|
|
|
console.log('No problems with phantom types!');
|