<commit_before>﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml;
using System.Xml.Linq;

namespace NUnitTestParser
{
    class Program
    {
        static readonly List<KeyValuePair<string, double>> TestFixtures = new List<KeyValuePair<string, double>>();
        static void Main(string[] args)
        {
            if (args.Length != 1)
            {
                Console.WriteLine("Usage: NUnitTestParser.exe <nunit-2-results-xml-file>");
                return;
            }
            var doc = XDocument.Load(new FileStream(args[0], FileMode.Open),LoadOptions.None);
            var results = doc.Root;
            
            ListTests(results, "");

            foreach (var result in TestFixtures.OrderByDescending(f => f.Value))
            {
                Console.WriteLine("{0} - {1}", result.Key, result.Value);
            }
            Console.ReadKey();
        }

        private static void ListTests(XElement results, string prefix)
        {
            foreach (var xNode in results.Nodes().Where(n => n is XElement))
            {
                var thing = (XElement) xNode;
                var name = prefix;
                if (thing.Name == "test-suite")
                {
                    name = (prefix + "." + GetAttribute(thing, "name")).TrimStart('.');<commit_msg>Allow for use in scripts<commit_after>﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml;
using System.Xml.Linq;

namespace NUnitTestParser
{
    class Program
    {
        static readonly List<KeyValuePair<string, double>> TestFixtures = new List<KeyValuePair<string, double>>();
        static void Main(string[] args)
        {
            if (args.Length != 1)
            {
                Console.WriteLine("Usage: NUnitTestParser.exe <nunit-2-results-xml-file>");
                return;
            }
            var doc = XDocument.Load(new FileStream(args[0], FileMode.Open),LoadOptions.None);
            var results = doc.Root;
            
            ListTests(results, "");

            foreach (var result in TestFixtures.OrderByDescending(f => f.Value))
            {
                Console.WriteLine("{0} - {1}", result.Key, result.Value);
            }
        }

        private static void ListTests(XElement results, string prefix)
        {
            foreach (var xNode in results.Nodes().Where(n => n is XElement))
            {
                var thing = (XElement) xNode;
                var name = prefix;
                if (thing.Name == "test-suite")
                {
                    name = (prefix + "." + GetAttribute(thing, "name")).TrimStart('.');
{'fraction_non_alphanumeric': 0.11777301927194861, 'fraction_numerical': 0.0035688793718772305, 'mean_word_length': 1.8514750762970498, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, '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': '5364430', 'n_tokens_mistral': 768, 'n_tokens_neox': 749, 'n_words': 178}