error_code.js 819 B

12345678910111213141516171819202122232425262728
  1. var test = require('tap').test;
  2. var spawn = require('child_process').spawn;
  3. var path = require('path');
  4. var semver = require('semver');
  5. // TODO this should be fixable I guess
  6. var knownFailure = process.platform === 'win32' && semver.satisfies(process.version, 'v0.10.x');
  7. test('error code', { skip: knownFailure }, function (t) {
  8. t.plan(2);
  9. var cwd = process.cwd();
  10. process.chdir(__dirname);
  11. var ps = spawn(process.execPath, [
  12. path.resolve(__dirname, '../bin/cmd.js'),
  13. path.resolve(__dirname, 'error_code/src.js')
  14. ]);
  15. var err = '';
  16. ps.stderr.on('data', function (buf) { err += buf });
  17. ps.stderr.on('end', function () {
  18. t.ok(/^(Syntax|Parse)Error:/m.test(err));
  19. });
  20. ps.on('exit', function (code) {
  21. t.notEqual(code, 0);
  22. });
  23. });