<commit_before>﻿open System
open System.IO
open System.Text
open System.Reflection
open System.Diagnostics
open Persimmon
open Persimmon.ActivePatterns
open Persimmon.Runner
open Persimmon.Output
open Persimmon.Ripe
open FsYaml
open Nessos.Vagabond

let loadTests (files: FileInfo list) =
  let asms = files |> List.map (fun f ->
    let assemblyRef = AssemblyName.GetAssemblyName(f.FullName)
    Assembly.Load(assemblyRef))
  TestCollector.collectRootTestObjects asms
  |> List.map (fun x -> fun () ->
    match x with
    | Context ctx -> ctx.Run(ignore) |> box
    | TestCase tc -> tc.Run() |> box
  )

let collectResult (watch: Stopwatch) (reporter: Reporter) (consoleReporter: Reporter) rc =
  let rec inner (collector: ResultCollector) = async {
    match collector.Results with
    | Incomplete -> return! inner collector
    | Complete res ->
      watch.Stop()
      let errors = Seq.sumBy TestRunner.countErrors res
      reporter.ReportProgress(TestResult.endMarker)
      reporter.ReportSummary(res)
      consoleReporter.ReportSummary(res)
      return errors
  }
  inner rc

let entryPoint (args: Args) =
  
  let watch = Stopwatch()
  
  use progress = if args.NoProgress then TextWriter.Null else Console.Out
  use output = new StreamWriter(args.Output.FullName, false, Encoding.UTF8) :> TextWriter<commit_msg>print executed test name<commit_after>﻿open System
open System.IO
open System.Text
open System.Reflection
open System.Diagnostics
open Persimmon
open Persimmon.ActivePatterns
open Persimmon.Runner
open Persimmon.Output
open Persimmon.Ripe
open FsYaml
open Nessos.Vagabond

let loadTests (files: FileInfo list) =

  let rec writeResult prefix = function
  | ContextResult ctx ->
    ctx.Children
    |> Seq.iter (writeResult (sprintf "%s.%s." prefix ctx.Name))
  | EndMarker -> printfn ""
  | TestResult tr -> printfn "end test: %s%s" prefix tr.FullName

  let asms = files |> List.map (fun f ->
    let assemblyRef = AssemblyName.GetAssemblyName(f.FullName)
    Assembly.Load(assemblyRef))
  TestCollector.collectRootTestObjects asms
  |> List.map (fun x -> fun () ->
    match x with
    | Context ctx -> ctx.Run(writeResult (sprintf "%s." ctx.Name)) |> box
    | TestCase tc ->
      let result = tc.Run()
      writeResult "" result
      box result
  )

let collectResult (watch: Stopwatch) (reporter: Reporter) (consoleReporter: Reporter) rc =
  let rec inner (collector: ResultCollector) = async {
    match collector.Results with
    | Incomplete -> return! inner collector
    | Complete res ->
      watch.Stop()
      let errors = Seq.sumBy TestRunner.countErrors res
      reporter.ReportProgress(TestResult.endMarker)
      reporter.ReportSummary(res)
      consoleReporter.ReportSummary(res)
      return errors
  }
  inner rc

let entryPoint (args: Args) =
  
  let watch = Stopwatch()
  
  use progress = if args.NoProgress then TextWriter.Null else Console.Out
  use output = new StreamWriter(args.Output.FullName, false, Encoding.UTF8) :> TextWriter
{'fraction_non_alphanumeric': 0.09525401069518717, 'fraction_numerical': 0.0006684491978609625, 'mean_word_length': 3.597542242703533, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 30, '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': '3089425', 'n_tokens_mistral': 918, 'n_tokens_neox': 917, 'n_words': 264}