<commit_before>require! {
  'assert'
  'chalk' : {cyan, red}
  'fs'
  'jsdiff-console'
  'path'
  'prelude-ls' : {capitalize}
}
debug = require('debug')('verify-file-content-runner')


# Verifies that a file whose name is provided in bold
# has the content provided as a code block
class VerifyFileContentRunner

  (@markdown-line, @formatter) ->

    # whether we are currently within a bold section that contains the file path
    @reading-file-path = no

    # the path of the file to verify
    @file-path = ''

    # content of the file to verify
    @expected-content = ''

    # the line of the node that is currently being parsed
    @currently-loaded-node-line = 1


  load: (node) ->
    @["_load#{capitalize node.type}"]? node


  run: (done) ->
    @formatter.start-activity "verifying file #{cyan @file-path}", @markdown-line
    try
      actual-content = fs.read-file-sync path.join(global.working-dir, @file-path), 'utf8'
    catch
      if e.code is 'ENOENT'
        @formatter.activity-error "file #{@file-path} not found"
    jsdiff-console actual-content, @expected-content, (err) ~>
      if err
        @formatter.activity-error "mismatching content in #{@file-path}:\n#{err.message}"
      @formatter.activity-success!
      done null, 1



  _load-fence: (node) ~>
    | @expected-content.length > 0  =>  @formatter.error 'Found second file content block, please provide only one', @currently-loaded-node-line<commit_msg>Don't swallow some test failures<commit_after>require! {
  'assert'
  'chalk' : {cyan, red}
  'fs'
  'jsdiff-console'
  'path'
  'prelude-ls' : {capitalize}
}
debug = require('debug')('verify-file-content-runner')


# Verifies that a file whose name is provided in bold
# has the content provided as a code block
class VerifyFileContentRunner

  (@markdown-line, @formatter) ->

    # whether we are currently within a bold section that contains the file path
    @reading-file-path = no

    # the path of the file to verify
    @file-path = ''

    # content of the file to verify
    @expected-content = ''

    # the line of the node that is currently being parsed
    @currently-loaded-node-line = 1


  load: (node) ->
    @["_load#{capitalize node.type}"]? node


  run: (done) ->
    @formatter.start-activity "verifying file #{cyan @file-path}", @markdown-line
    try
      actual-content = fs.read-file-sync path.join(global.working-dir, @file-path), 'utf8'
    catch
      if e.code is 'ENOENT'
        @formatter.activity-error "file #{@file-path} not found"
      else throw e
    jsdiff-console actual-content, @expected-content, (err) ~>
      if err
        @formatter.activity-error "mismatching content in #{@file-path}:\n#{err.message}"
      @formatter.activity-success!
      done null, 1



  _load-fence: (node) ~>
    | @expected-content.length > 0  =>  @formatter.error 'Found second file content block, please provide only one', @currently-loaded-node-line
{'fraction_non_alphanumeric': 0.1287568306010929, 'fraction_numerical': 0.00273224043715847, 'mean_word_length': 3.1253521126760564, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 17, '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': '5514388', 'n_tokens_mistral': 968, 'n_tokens_neox': 910, 'n_words': 276}