add test location to ast validation

This commit is contained in:
Sebastian McKenzie
2015-01-25 15:46:17 +11:00
parent 49c28d449e
commit d8046333c0

View File

@@ -52,7 +52,7 @@ var run = function (task, done) {
var noCheckAst = opts.noCheckAst;
delete opts.noCheckAst;
var checkAst = function (result) {
var checkAst = function (result, opts) {
if (noCheckAst) return;
var errors = esvalid.errors(result.ast.program);
@@ -61,13 +61,13 @@ var run = function (task, done) {
_.each(errors, function (err) {
msg.push(err.message + " - " + JSON.stringify(err.node));
});
throw new Error(msg.join(". "));
throw new Error(opts.loc + ": " + msg.join(". "));
}
};
if (execCode) {
result = transform(execCode, getOpts(exec));
checkAst(result);
checkAst(result, exec);
execCode = result.code;
try {
@@ -94,7 +94,7 @@ var run = function (task, done) {
var expectCode = expect.code;
if (!execCode || actualCode) {
result = transform(actualCode, getOpts(actual));
checkAst(result);
checkAst(result, actual);
actualCode = result.code;
try {