<commit_before>import chai from 'chai'
import chaiAsPromised from 'chai-as-promised'
import requireInject from 'require-inject'
import sinon from 'sinon'
import sinonChai from 'sinon-chai'
import test from 'ava'

chai.use(chaiAsPromised)
chai.use(sinonChai)

const expect = chai.expect

test.beforeEach(t => {
  const exec = sinon.stub()
  const stubs = {
    child_process: {
      exec
    }
  }
  const util = requireInject('../../src/util', stubs)
  t.context = {exec, util}
})

test('exec rejects if childProcess.exec fails', t => {
  const {exec, util} = t.context
  exec.yields('some error')
  return expect(util.exec('command'))
    .to.be.eventually.rejectedWith('some error')
})

test('exec resolves if childProcess.exec succeeds', t => {
  const {exec, util} = t.context
  exec.yields(null, 'stdout', 'stderr')
  return expect(util.exec('command')).to.eventually.deep.equal({
    command: 'command',
    stdout: 'stdout',
    stderr: 'stderr'
  })
})

<commit_msg>Update test/util/exec to use ava assertions<commit_after>import requireInject from 'require-inject'
import sinon from 'sinon'
import test from 'ava'

test.beforeEach(t => {
  const exec = sinon.stub()
  const stubs = {
    child_process: {
      exec
    }
  }
  const util = requireInject('../../src/util', stubs)
  t.context = {exec, util}
})

test('exec rejects if childProcess.exec fails', t => {
  const {exec, util} = t.context
  exec.yields('some error')
  return t.throws(util.exec('command'), 'some error')
})

test('exec resolves if childProcess.exec succeeds', t => {
  const {exec, util} = t.context
  exec.yields(null, 'stdout', 'stderr')
  return util.exec('command').then(result => {
    t.same(result, {
      command: 'command',
      stdout: 'stdout',
      stderr: 'stderr'
    })
  })
})

{'fraction_non_alphanumeric': 0.15591699383062255, 'fraction_numerical': 0.0, 'mean_word_length': 3.6824146981627295, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 10, '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': '2594844', 'n_tokens_mistral': 621, 'n_tokens_neox': 614, 'n_words': 151}