<commit_before>const watcher = require('../lib')

const path = require('path')
const fs = require('fs-extra')

describe('entry point', function () {
  let subs, fixtureDir, watchDir, mainLogFile, workerLogFile

  beforeEach(async function () {
    subs = []

    const rootDir = path.join(__dirname, 'fixture')
    fixtureDir = await fs.mkdtemp(path.join(rootDir, 'watched-'))
    watchDir = path.join(fixtureDir, 'root')
    await fs.mkdirs(watchDir)

    mainLogFile = path.join(fixtureDir, 'main.test.log')
    workerLogFile = path.join(fixtureDir, 'worker.test.log')

    await Promise.all([
      [mainLogFile, workerLogFile].map(fname => fs.readFile(fname, {encoding: 'utf8'}).catch(() => ''))
    ])
  })

  afterEach(async function () {
    if (this.currentTest.state === 'failed') {
      const [mainLog, workerLog] = await Promise.all(
        [mainLogFile, workerLogFile].map(fname => fs.readFile(fname, {encoding: 'utf8'}).catch(() => ''))
      )

      console.log(`main log ${mainLogFile}:\n${mainLog}`)
      console.log(`worker log ${workerLogFile}:\n${workerLog}`)
    }

    await Promise.all([
      fs.remove(watchDir),
      ...subs.map(sub => sub.unwatch())
    ])
  })

  describe('configuration', function () {
    it('validates its arguments', async function () {
      await assert.isRejected(watcher.configure(), /requires an option object/)
    })

    it('configures the main thread logger', async function () {
      await watcher.configure({mainLogFile})

      const contents = await fs.readFile(mainLogFile)
      assert.match(contents, /FileLogger opened/)
    })
<commit_msg>Unlink log files, not read them<commit_after>const watcher = require('../lib')

const path = require('path')
const fs = require('fs-extra')

describe('entry point', function () {
  let subs, fixtureDir, watchDir, mainLogFile, workerLogFile

  beforeEach(async function () {
    subs = []

    const rootDir = path.join(__dirname, 'fixture')
    fixtureDir = await fs.mkdtemp(path.join(rootDir, 'watched-'))
    watchDir = path.join(fixtureDir, 'root')
    await fs.mkdirs(watchDir)

    mainLogFile = path.join(fixtureDir, 'main.test.log')
    workerLogFile = path.join(fixtureDir, 'worker.test.log')

    await Promise.all([
      [mainLogFile, workerLogFile].map(fname => fs.unlink(fname, {encoding: 'utf8'}).catch(() => ''))
    ])
  })

  afterEach(async function () {
    if (this.currentTest.state === 'failed') {
      const [mainLog, workerLog] = await Promise.all(
        [mainLogFile, workerLogFile].map(fname => fs.readFile(fname, {encoding: 'utf8'}).catch(() => ''))
      )

      console.log(`main log ${mainLogFile}:\n${mainLog}`)
      console.log(`worker log ${workerLogFile}:\n${workerLog}`)
    }

    await Promise.all([
      fs.remove(watchDir),
      ...subs.map(sub => sub.unwatch())
    ])
  })

  describe('configuration', function () {
    it('validates its arguments', async function () {
      await assert.isRejected(watcher.configure(), /requires an option object/)
    })

    it('configures the main thread logger', async function () {
      await watcher.configure({mainLogFile})

      const contents = await fs.readFile(mainLogFile)
      assert.match(contents, /FileLogger opened/)
    })

{'fraction_non_alphanumeric': 0.16337245213094503, 'fraction_numerical': 0.0012353304508956147, 'mean_word_length': 3.5237430167597767, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, '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': '457349', 'n_tokens_mistral': 1038, 'n_tokens_neox': 1023, 'n_words': 209}