diff --git a/external/builder/fixtures_esprima/comments-expected.js b/external/builder/fixtures_esprima/comments-expected.js index f36ff416d..f216553cb 100644 --- a/external/builder/fixtures_esprima/comments-expected.js +++ b/external/builder/fixtures_esprima/comments-expected.js @@ -1,28 +1,17 @@ function f1() { - /* head */ "1"; - /* mid */ "2"; } -/* tail */ function f2() { - // head "1"; - // mid "2"; } -// tail function f2() { if ("1") { - // begin block "1"; } "2"; - // trailing - if (/* s */ - "3") - /*e*/ - { - "4"; - } + if ("3") { + "4"; + } } diff --git a/external/builder/test-fixtures.js b/external/builder/test-fixtures.js index 12fc8af89..17d52a784 100644 --- a/external/builder/test-fixtures.js +++ b/external/builder/test-fixtures.js @@ -1,17 +1,20 @@ 'use strict'; -require('shelljs/make'); - var builder = require('./builder'); var fs = require('fs'); +var path = require('path'); var errors = 0; -cd(__dirname); -cd('fixtures'); -ls('*-expected.*').forEach(function(expectationFilename) { +var baseDir = path.join(__dirname, 'fixtures'); +var files = fs.readdirSync(baseDir).filter(function (name) { + return /-expected\./.test(name); +}).map(function (name) { + return path.join(baseDir, name); +}); +files.forEach(function(expectationFilename) { var inFilename = expectationFilename.replace('-expected', ''); - var expectation = cat(expectationFilename).trim() + var expectation = fs.readFileSync(expectationFilename).toString().trim() .replace(/__filename/g, fs.realpathSync(inFilename)); var outLines = []; @@ -32,20 +35,22 @@ ls('*-expected.*').forEach(function(expectationFilename) { if (out !== expectation) { errors++; - echo('Assertion failed for ' + inFilename); - echo('--------------------------------------------------'); - echo('EXPECTED:'); - echo(expectation); - echo('--------------------------------------------------'); - echo('ACTUAL'); - echo(out); - echo('--------------------------------------------------'); - echo(); + console.log('Assertion failed for ' + inFilename); + console.log('--------------------------------------------------'); + console.log('EXPECTED:'); + console.log(expectation); + console.log('--------------------------------------------------'); + console.log('ACTUAL'); + console.log(out); + console.log('--------------------------------------------------'); + console.log(); } }); if (errors) { - echo('Found ' + errors + ' expectation failures.'); + console.error('Found ' + errors + ' expectation failures.'); + process.exit(1); } else { - echo('All tests completed without errors.'); + console.log('All tests completed without errors.'); + process.exit(0); } diff --git a/external/builder/test-fixtures_esprima.js b/external/builder/test-fixtures_esprima.js index 108d9a35a..944e91a04 100644 --- a/external/builder/test-fixtures_esprima.js +++ b/external/builder/test-fixtures_esprima.js @@ -1,17 +1,20 @@ 'use strict'; -require('shelljs/make'); - var p2 = require('./preprocessor2.js'); var fs = require('fs'); +var path = require('path'); var errors = 0; -cd(__dirname); -cd('fixtures_esprima'); -ls('*-expected.*').forEach(function(expectationFilename) { +var baseDir = path.join(__dirname, 'fixtures_esprima'); +var files = fs.readdirSync(baseDir).filter(function (name) { + return /-expected\./.test(name); +}).map(function (name) { + return path.join(baseDir, name); +}); +files.forEach(function(expectationFilename) { var inFilename = expectationFilename.replace('-expected', ''); - var expectation = cat(expectationFilename).trim() + var expectation = fs.readFileSync(expectationFilename).toString().trim() .replace(/__filename/g, fs.realpathSync(inFilename)); var input = fs.readFileSync(inFilename).toString(); @@ -24,7 +27,6 @@ ls('*-expected.*').forEach(function(expectationFilename) { var ctx = { defines: defines, rootPath: __dirname + '/../..', - saveComments: true }; var out; try { @@ -35,20 +37,22 @@ ls('*-expected.*').forEach(function(expectationFilename) { if (out !== expectation) { errors++; - echo('Assertion failed for ' + inFilename); - echo('--------------------------------------------------'); - echo('EXPECTED:'); - echo(expectation); - echo('--------------------------------------------------'); - echo('ACTUAL'); - echo(out); - echo('--------------------------------------------------'); - echo(); + console.log('Assertion failed for ' + inFilename); + console.log('--------------------------------------------------'); + console.log('EXPECTED:'); + console.log(expectation); + console.log('--------------------------------------------------'); + console.log('ACTUAL'); + console.log(out); + console.log('--------------------------------------------------'); + console.log(); } }); if (errors) { - echo('Found ' + errors + ' expectation failures.'); + console.error('Found ' + errors + ' expectation failures.'); + process.exit(1); } else { - echo('All tests completed without errors.'); + console.log('All tests completed without errors.'); + process.exit(0); } diff --git a/gulpfile.js b/gulpfile.js index 703981b9c..9371002e0 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -1424,3 +1424,12 @@ gulp.task('mozcentraldiff', ['mozcentral', 'mozcentralbaseline'], }); }); }); + +gulp.task('externaltest', function () { + gutil.log('Running test-fixtures.js'); + safeSpawnSync('node', ['external/builder/test-fixtures.js'], + {stdio: 'inherit'}); + gutil.log('Running test-fixtures_esprima.js'); + safeSpawnSync('node', ['external/builder/test-fixtures_esprima.js'], + {stdio: 'inherit'}); +}); diff --git a/package.json b/package.json index 982a7e148..e3ee2c866 100644 --- a/package.json +++ b/package.json @@ -35,7 +35,7 @@ "yargs": "^3.14.0" }, "scripts": { - "test": "gulp lint unittestcli" + "test": "gulp lint unittestcli externaltest" }, "repository": { "type": "git",