<commit_before>var chai = require('chai')
  , expect = chai.expect
  , HMRMAIN = require('../src/cli/main')
  , CHALK = require('chalk')
  , FS = require('fs')
  , PATH = require('path')
  , _ = require('underscore');

var gather = '';
var ConsoleLogOrg = console.log;
var ProcessExitOrg = process.exit;

describe('Testing Ouput interface', function () {



  function MyConsoleLog( msg ) {
    gather += msg;
    ConsoleLogOrg.apply(this, arguments);
  }

  function MyProcessExit() {

  }

  function HackMyResumeStub( args ) {

    console.log = MyConsoleLog;
    process.exit = MyProcessExit;
    CHALK.enabled = false;

    try {
      args.unshift( process.argv[1] );
      args.unshift( process.argv[0] );
      var HMRMAIN = require('../src/cli/main');
      HMRMAIN( args );
    }
    catch( ex ) {
      require('../src/core/error-handler').err( ex, false );
    }
    CHALK.enabled = true;
    process.exit = ProcessExitOrg;
    console.log = ConsoleLogOrg;

  }

  function run( title, args, tests ) {
    it( title, function() {

      gather = '';
      HackMyResumeStub( args );

      expect(
        _.all( tests, function(t) {
          return gather.indexOf(t) > -1;
        })
      ).to.equal(true);

    });
  }

  var title = '*** HackMyResume v1.5.2 ***';
  var feedMe = 'Please feed me a resume in FRESH or JSON Resume format.';
  var manPage = FS.readFileSync( PATH.resolve( __dirname, '../src/cli/use.txt' ), 'utf8');

  run('HMR should output a help string when no command is specified',
      [], [ title, 'Please give me a command (BUILD, ANALYZE, VALIDATE, CONVERT, or NEW).' ]);

  run('BUILD should output a tip when no source is specified',
      ['build'], [ title, feedMe ]);

  run('VALIATE should output a tip when no source is specified',
     ['validate'], [ title, feedMe ]);

  run('ANALYZE should output a tip when no source is specified',
      ['analyze'], [ title, feedMe ]);

  run('CONVERT should output a tip when no source is specified',
      ['convert'], [ title, feedMe ]);

  run('NEW should output a tip when no source is specified',
      ['new'], [ title, 'Please specify the filename of the resume to create.' ]);

  // This will cause the HELP doc to be emitted, followed by an "unknown option --help"
  // error in the log, based on the way we're calling into HMR. As long as the test
  // passes, any extraneous error messages can be ignored here.
  run('HMR should output help doc with --help',
      ['--help'], [ manPage ]);

});
<commit_msg>Tests: Remove hard-coded version number.<commit_after>var chai = require('chai')
  , expect = chai.expect
  , HMRMAIN = require('../src/cli/main')
  , CHALK = require('chalk')
  , FS = require('fs')
  , PATH = require('path')
  , PKG = require('../package.json')
  , _ = require('underscore');

var gather = '';
var ConsoleLogOrg = console.log;
var ProcessExitOrg = process.exit;

describe('Testing Ouput interface', function () {



  function MyConsoleLog( msg ) {
    gather += msg;
    ConsoleLogOrg.apply(this, arguments);
  }

  function MyProcessExit() {

  }

  function HackMyResumeStub( args ) {

    console.log = MyConsoleLog;
    process.exit = MyProcessExit;
    CHALK.enabled = false;

    try {
      args.unshift( process.argv[1] );
      args.unshift( process.argv[0] );
      var HMRMAIN = require('../src/cli/main');
      HMRMAIN( args );
    }
    catch( ex ) {
      require('../src/core/error-handler').err( ex, false );
    }
    CHALK.enabled = true;
    process.exit = ProcessExitOrg;
    console.log = ConsoleLogOrg;

  }

  function run( title, args, tests ) {
    it( title, function() {

      gather = '';
      HackMyResumeStub( args );

      expect(
        _.all( tests, function(t) {
          return gather.indexOf(t) > -1;
        })
      ).to.equal(true);

    });
  }

  var title = '*** HackMyResume v' + PKG.version + ' ***';
  var feedMe = 'Please feed me a resume in FRESH or JSON Resume format.';
  var manPage = FS.readFileSync( PATH.resolve( __dirname, '../src/cli/use.txt' ), 'utf8');

  run('HMR should output a help string when no command is specified',
      [], [ title, 'Please give me a command (BUILD, ANALYZE, VALIDATE, CONVERT, or NEW).' ]);

  run('BUILD should output a tip when no source is specified',
      ['build'], [ title, feedMe ]);

  run('VALIATE should output a tip when no source is specified',
     ['validate'], [ title, feedMe ]);

  run('ANALYZE should output a tip when no source is specified',
      ['analyze'], [ title, feedMe ]);

  run('CONVERT should output a tip when no source is specified',
      ['convert'], [ title, feedMe ]);

  run('NEW should output a tip when no source is specified',
      ['new'], [ title, 'Please specify the filename of the resume to create.' ]);

  // This will cause the HELP doc to be emitted, followed by an "unknown option --help"
  // error in the log, based on the way we're calling into HMR. As long as the test
  // passes, any extraneous error messages can be ignored here.
  run('HMR should output help doc with --help',
      ['--help'], [ manPage ]);

});

{'fraction_non_alphanumeric': 0.14459724950884087, 'fraction_numerical': 0.0021611001964636544, 'mean_word_length': 2.839366515837104, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '876711', 'n_tokens_mistral': 1653, 'n_tokens_neox': 1577, 'n_words': 515}