<commit_before>﻿using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;

namespace Pingu.Tests
{
    class ToolHelper
    {
        public static ProcessResult RunPngCheck(string path)
        {
            var asm = typeof(ToolHelper).GetTypeInfo().Assembly;
            var assemblyDir = Path.GetDirectoryName(asm.Location);
            var pngcheckPath = Path.Combine(
                assemblyDir,
                "..",
                "..",
                "..",
                "..",
                "..",
                "tools",
                "pngcheck.exe");

            return Exe(pngcheckPath, "-v", path);
        }

        public static ProcessResult Exe(string command, params string[] args)
        {
            var startInfo = new ProcessStartInfo {
                FileName = command,
                Arguments = string.Join(
                    " ", 
                    args.Where(x => !string.IsNullOrWhiteSpace(x))
                        .Select(x => "\"" + x + "\"")
                ),
                CreateNoWindow = true,
                RedirectStandardOutput = true,
                RedirectStandardError = true,
                UseShellExecute = false,
            };

            var proc = Process.Start(startInfo);

            var @out = proc.StandardOutput.ReadToEnd();
            var err = proc.StandardError.ReadToEnd();
            proc.WaitForExit(20000);

            return new ProcessResult {
                ExitCode = proc.ExitCode,<commit_msg>Tests: Enable tests running on !Windows too.<commit_after>﻿using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;

namespace Pingu.Tests
{
    class ToolHelper
    {
        public static ProcessResult RunPngCheck(string path)
        {
            var asm = typeof(ToolHelper).GetTypeInfo().Assembly;
            var assemblyDir = Path.GetDirectoryName(asm.Location);

            // It'll be on the path on Linux/Mac, we ship it for Windows.
            var pngcheckPath = Path.DirectorySeparatorChar == '\\' ? Path.Combine(
                assemblyDir,
                "..",
                "..",
                "..",
                "..",
                "..",
                "tools",
                "pngcheck.exe") : "pngcheck";

            return Exe(pngcheckPath, "-v", path);
        }

        public static ProcessResult Exe(string command, params string[] args)
        {
            var startInfo = new ProcessStartInfo {
                FileName = command,
                Arguments = string.Join(
                    " ", 
                    args.Where(x => !string.IsNullOrWhiteSpace(x))
                        .Select(x => "\"" + x + "\"")
                ),
                CreateNoWindow = true,
                RedirectStandardOutput = true,
                RedirectStandardError = true,
                UseShellExecute = false,
            };

            var proc = Process.Start(startInfo);

            var @out = proc.StandardOutput.ReadToEnd();
            var err = proc.StandardError.ReadToEnd();
            proc.WaitForExit(20000);

            return new ProcessResult {
                ExitCode = proc.ExitCode,
{'fraction_non_alphanumeric': 0.10365282547611614, 'fraction_numerical': 0.0031220730565095223, 'mean_word_length': 1.3680709534368072, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '4125943', 'n_tokens_mistral': 836, 'n_tokens_neox': 762, 'n_words': 171}