<commit_before># Small program that runs the test cases

import strutils, os

const
  dir = "nimpretty/tests/"

var
  failures = 0

when defined(develop):
  const nimp = "bin" / "nimpretty".addFileExt(ExeExt)
  if execShellCmd("nim c -o:$# nimpretty/nimpretty.nim" % [nimp]) != 0:
    quit("FAILURE: compilation of nimpretty failed")
else:
  const nimp = "nimpretty"

proc test(infile, ext: string) =
  if execShellCmd("$# -o:$# --backup:off $#" % [nimp, infile.changeFileExt(ext), infile]) != 0:
    echo "FAILURE: nimpretty cannot prettify ", infile
    failures += 1
    return
  let nimFile = splitFile(infile).name
  let expected = dir / "expected" / nimFile & ".nim"
  let produced = dir / nimFile.changeFileExt(ext)
  if strip(readFile(expected)) != strip(readFile(produced)):
    echo "FAILURE: files differ: ", nimFile
    discard execShellCmd("diff -uNdr " & expected & " " & produced)
    failures += 1
  else:
    echo "SUCCESS: files identical: ", nimFile<commit_msg>nimpretty tester: strengthen the comparison, do not use strip<commit_after># Small program that runs the test cases

import strutils, os

const
  dir = "nimpretty/tests/"

var
  failures = 0

when defined(develop):
  const nimp = "bin" / "nimpretty".addFileExt(ExeExt)
  if execShellCmd("nim c -o:$# nimpretty/nimpretty.nim" % [nimp]) != 0:
    quit("FAILURE: compilation of nimpretty failed")
else:
  const nimp = "nimpretty"

proc test(infile, ext: string) =
  if execShellCmd("$# -o:$# --backup:off $#" % [nimp, infile.changeFileExt(ext), infile]) != 0:
    echo "FAILURE: nimpretty cannot prettify ", infile
    failures += 1
    return
  let nimFile = splitFile(infile).name
  let expected = dir / "expected" / nimFile & ".nim"
  let produced = dir / nimFile.changeFileExt(ext)
  if readFile(expected) != readFile(produced):
    echo "FAILURE: files differ: ", nimFile
    discard execShellCmd("diff -uNdr " & expected & " " & produced)
    failures += 1
  else:
    echo "SUCCESS: files identical: ", nimFile
{'fraction_non_alphanumeric': 0.13640922768304914, 'fraction_numerical': 0.0050150451354062184, 'mean_word_length': 3.877750611246944, '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': '6233371', 'n_tokens_mistral': 700, 'n_tokens_neox': 678, 'n_words': 197}