Make phantom type tests work when run from any directory

This commit is contained in:
Jeroen Engels 2020-03-24 17:15:55 +01:00
parent ae15334993
commit 912ed3ded4
2 changed files with 3 additions and 2 deletions

View File

@ -9,7 +9,7 @@
},
"scripts": {
"test": "elm make --docs=/tmp/docs.json && elm-format src/ --validate && elm-test && npm run phantom-tests && elm-review && elm-xref",
"phantom-tests": "(cd phantom-type-tests && node ./run-phantom-tests.js)",
"phantom-tests": "node phantom-type-tests/run.js",
"test:watch": "npx elm-test --watch"
},
"repository": {

View File

@ -1,11 +1,12 @@
const fs = require('fs');
const path = require('path');
const { execSync } = require("child_process");
const files = fs.readdirSync(__dirname);
const elmFiles = files.filter(file => file.endsWith(".elm"));
elmFiles.forEach(elmFile => {
const expectedOutput = fs.readFileSync(`${elmFile.slice(0, -4)}.txt`, 'utf8');
const expectedOutput = fs.readFileSync(path.join(__dirname, `${elmFile.slice(0, -4)}.txt`), 'utf8');
try {
const output = execSync(`elm make ./${elmFile}`, {encoding:"utf8", stdio: 'pipe', cwd: __dirname}).toString();