|
|
@ -1,17 +1,20 @@ |
|
|
|
'use strict'; |
|
|
|
'use strict'; |
|
|
|
|
|
|
|
|
|
|
|
require('shelljs/make'); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var p2 = require('./preprocessor2.js'); |
|
|
|
var p2 = require('./preprocessor2.js'); |
|
|
|
var fs = require('fs'); |
|
|
|
var fs = require('fs'); |
|
|
|
|
|
|
|
var path = require('path'); |
|
|
|
|
|
|
|
|
|
|
|
var errors = 0; |
|
|
|
var errors = 0; |
|
|
|
|
|
|
|
|
|
|
|
cd(__dirname); |
|
|
|
var baseDir = path.join(__dirname, 'fixtures_esprima'); |
|
|
|
cd('fixtures_esprima'); |
|
|
|
var files = fs.readdirSync(baseDir).filter(function (name) { |
|
|
|
ls('*-expected.*').forEach(function(expectationFilename) { |
|
|
|
return /-expected\./.test(name); |
|
|
|
|
|
|
|
}).map(function (name) { |
|
|
|
|
|
|
|
return path.join(baseDir, name); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
files.forEach(function(expectationFilename) { |
|
|
|
var inFilename = expectationFilename.replace('-expected', ''); |
|
|
|
var inFilename = expectationFilename.replace('-expected', ''); |
|
|
|
var expectation = cat(expectationFilename).trim() |
|
|
|
var expectation = fs.readFileSync(expectationFilename).toString().trim() |
|
|
|
.replace(/__filename/g, fs.realpathSync(inFilename)); |
|
|
|
.replace(/__filename/g, fs.realpathSync(inFilename)); |
|
|
|
var input = fs.readFileSync(inFilename).toString(); |
|
|
|
var input = fs.readFileSync(inFilename).toString(); |
|
|
|
|
|
|
|
|
|
|
@ -24,7 +27,6 @@ ls('*-expected.*').forEach(function(expectationFilename) { |
|
|
|
var ctx = { |
|
|
|
var ctx = { |
|
|
|
defines: defines, |
|
|
|
defines: defines, |
|
|
|
rootPath: __dirname + '/../..', |
|
|
|
rootPath: __dirname + '/../..', |
|
|
|
saveComments: true |
|
|
|
|
|
|
|
}; |
|
|
|
}; |
|
|
|
var out; |
|
|
|
var out; |
|
|
|
try { |
|
|
|
try { |
|
|
@ -35,20 +37,22 @@ ls('*-expected.*').forEach(function(expectationFilename) { |
|
|
|
if (out !== expectation) { |
|
|
|
if (out !== expectation) { |
|
|
|
errors++; |
|
|
|
errors++; |
|
|
|
|
|
|
|
|
|
|
|
echo('Assertion failed for ' + inFilename); |
|
|
|
console.log('Assertion failed for ' + inFilename); |
|
|
|
echo('--------------------------------------------------'); |
|
|
|
console.log('--------------------------------------------------'); |
|
|
|
echo('EXPECTED:'); |
|
|
|
console.log('EXPECTED:'); |
|
|
|
echo(expectation); |
|
|
|
console.log(expectation); |
|
|
|
echo('--------------------------------------------------'); |
|
|
|
console.log('--------------------------------------------------'); |
|
|
|
echo('ACTUAL'); |
|
|
|
console.log('ACTUAL'); |
|
|
|
echo(out); |
|
|
|
console.log(out); |
|
|
|
echo('--------------------------------------------------'); |
|
|
|
console.log('--------------------------------------------------'); |
|
|
|
echo(); |
|
|
|
console.log(); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
if (errors) { |
|
|
|
if (errors) { |
|
|
|
echo('Found ' + errors + ' expectation failures.'); |
|
|
|
console.error('Found ' + errors + ' expectation failures.'); |
|
|
|
|
|
|
|
process.exit(1); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
echo('All tests completed without errors.'); |
|
|
|
console.log('All tests completed without errors.'); |
|
|
|
|
|
|
|
process.exit(0); |
|
|
|
} |
|
|
|
} |
|
|
|