<commit_before>var test = require('tap').test;
var path = require('path');
var os = require('os');

var mkdirp = require('mkdirp');
var rimraf = require('rimraf');
var rewire = require('rewire');

var run = rewire('../lib/npm/script/run');

var passingScript = path.join(__dirname, 'fixtures', 'example-test-script-passing.sh');
var failingScript = path.join(__dirname, 'fixtures', 'example-test-script-failing.sh');
var badPath = path.join(__dirname, 'fixtures', 'example-test-script-does-not-exist');

var sandbox = path.join(os.tmpdir(), 'citgm-' + Date.now(), 'run-test');

test('npm.script.run: setup', function (t) {
  mkdirp(sandbox, function (err) {
    t.error(err);
    t.done();
  });
});

test('npm.script.run: should pass with passing script', function (t) {
  var context = {
    path: sandbox,
    emit: function () {},
    module: {
      name: 'run-test'
    },
    options: {}
  };
  run(context, passingScript, 'the canary is dead', function (err) {
    t.error(err);
    t.done();
  });
});

test('npm.script.run: should fail with failing script', function (t) {
  var context = {
    path: sandbox,
    emit: function () {},
    module: {
      name: 'run-test'
    },
    options: {}
  };
  var failingMsg = 'the canary is dead';
  run(context, failingScript, failingMsg, function (err) {
    t.equals(err.message, failingMsg);
    t.done();
  });<commit_msg>test: improve coverage on npm.script.run<commit_after>var test = require('tap').test;
var path = require('path');
var os = require('os');

var mkdirp = require('mkdirp');
var rimraf = require('rimraf');
var rewire = require('rewire');

var run = rewire('../lib/npm/script/run');

var passingScript = path.join(__dirname, 'fixtures', 'example-test-script-passing.sh');
var failingScript = path.join(__dirname, 'fixtures', 'example-test-script-failing.sh');
var badPath = path.join(__dirname, 'fixtures', 'example-test-script-does-not-exist');

var sandbox = path.join(os.tmpdir(), 'citgm-' + Date.now(), 'run-test');

test('npm.script.run: setup', function (t) {
  mkdirp(sandbox, function (err) {
    t.error(err);
    t.done();
  });
});

test('npm.script.run: should pass with passing script', function (t) {
  var context = {
    path: sandbox,
    emit: function () {},
    module: {
      name: 'run-test',
      stripAnsi: true
    },
    options: {}
  };
  run(context, passingScript, 'the canary is dead', function (err) {
    t.error(err);
    t.done();
  });
});

test('npm.script.run: should fail with failing script', function (t) {
  var context = {
    path: sandbox,
    emit: function () {},
    module: {
      name: 'run-test'
    },
    options: {}
  };
  var failingMsg = 'the canary is dead';
  run(context, failingScript, failingMsg, function (err) {
    t.equals(err.message, failingMsg);
    t.done();
  });
{'fraction_non_alphanumeric': 0.18669985775248932, 'fraction_numerical': 0.0, 'mean_word_length': 3.6039279869067102, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '7291682', 'n_tokens_mistral': 972, 'n_tokens_neox': 950, 'n_words': 228}