<commit_before>// Copyright 2007 MbUnit Project - http://www.mbunit.com/
// Portions Copyright 2000-2004 <NAME>, <NAME>
// 
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// 
//     http://www.apache.org/licenses/LICENSE-2.0
// 
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

using System;
using System.Collections.Generic;
using System.IO;
using MbUnit.Core.Runner.CommandLine;
using MbUnit.Framework;
using MbUnit.Framework.Kernel.Filters;
using MbUnit.Framework.Kernel.Metadata;
using MbUnit.Framework.Kernel.Model;

namespace MbUnit.Echo
{
    public class MainArguments
    {
        #region Files and Directories

        [DefaultCommandLineArgument(
            CommandLineArgumentType.MultipleUnique,
            LongName = "assemblies",
            Description = "List of assemblies containing the tests."
            )]
        public string[] Assemblies;

        [CommandLineArgument(
            CommandLineArgumentType.MultipleUnique,
            ShortName = "hd",
            LongName = "hint-directories",
            Description = "The list of directories used for loading assemblies and other dependent resources.",
            ArgumentValueType = "dirs"
            )]
        public string[] HintDirectories;

        [CommandLineArgument(
            CommandLineArgumentType.MultipleUnique,
            ShortName = "pd",
            LongName = "plugin-directory",
            Description = "Additional MbUnit plugin directories to search recursively",
            ArgumentValueType = "dirs"
            )]
        public string[] PluginDirectories;

        [CommandLineArgument(
            CommandLineArgumentType.AtMostOnce,
            ShortName = "abd",
            LongName = "application-base-directory",
            Description = "The application base directory to set during test execution.",
            ArgumentValueType = "path"
            )]
        public string AppBaseDirectory = "";

        #endregion

        #region Report Arguments
        [CommandLineArgument(
             CommandLineArgumentType.AtMostOnce,
             ShortName = "rd",
             LongName = "report-directory",
            Description = "Target output directory for the reports",
            ArgumentValueType = "path"
             )]
        public string ReportDirectory = "";

        [CommandLineArgument(
             CommandLineArgumentType.AtMostOnce,
             ShortName = "rnf",
             LongName = "report-name-format",
             Description = "Format string for the report name. {0} is replaced by the date, {1} by the time.  Default = mbunit-{0}{1}",
             ArgumentValueType = "pattern"
             )]
        public string ReportNameFormat = "mbunit-result-{0}{1}";

        [CommandLineArgument(
             CommandLineArgumentType.MultipleUnique,
             ShortName = "rt",
             LongName = "report-type",
             Description = "Report types to generate.  See below for all supported types.",
             ArgumentValueType = "type"
        )]
        public string[] ReportTypes;

        [CommandLineArgument(
             CommandLineArgumentType.AtMostOnce,
             ShortName = "sr",
             LongName = "show-reports",
            Description = "Show generated reports in a window"
        )]
        public bool ShowReports;
        #endregion

        #region Filter Arguments

        [CommandLineArgument(
             CommandLineArgumentType.MultipleUnique,
             ShortName = "fc",
             LongName = "filter-category",
             Description = "Name of the filtered category"
             )]
        public string[] FilterCategories;

        [CommandLineArgument(
             CommandLineArgumentType.MultipleUnique,
             ShortName = "fa",
             LongName = "filter-author",
             Description = "Name of the filtered author name"
             )]
        public string[] FilterAuthors;

        [CommandLineArgument(
             CommandLineArgumentType.MultipleUnique,
             ShortName = "ft",
             LongName = "filter-type",
             Description = "Name of the filtered type"
             )]
        public string[] FilterTypes;

        [CommandLineArgument(
             CommandLineArgumentType.MultipleUnique,
             ShortName = "fn",
             LongName = "filter-namespace",
             Description = "Name of the filtered namespace"
             )]
        public string[] FilterNamespaces;

        [CommandLineArgument(
             CommandLineArgumentType.MultipleUnique,
             ShortName = "fi",
             LongName = "filter-importance",
             Description = "Name of the filtered importance"
             )]
        public TestImportance[] FilterImportances;

        #endregion

        #region Misc arguments

        [CommandLineArgument(
             CommandLineArgumentType.AtMostOnce,
             ShortName = "h",
             LongName = "help",
             Description = "Display this help text"
             )]
        public bool Help;

        [CommandLineArgument(
             CommandLineArgumentType.AtMostOnce,
             ShortName = "v",
             LongName = "verbosity",
             Description = "Controls the level of detail of the information to display"
             )]
        public Verbosity Verbosity = Verbosity.Normal;

        [CommandLineArgument(
             CommandLineArgumentType.AtMostOnce,
             LongName = "save-template-tree",
             Description = "Saves the template tree to a file as XML"
             )]
        public string SaveTemplateTree;

        [CommandLineArgument(
             CommandLineArgumentType.AtMostOnce,
             LongName = "save-test-tree",
             Description = "Saves the test tree to a file as XML"
             )]
        public string SaveTestTree;

        [CommandLineArgument(
             CommandLineArgumentType.AtMostOnce,
             ShortName = "sc",
             LongName = "shadow-copy-files",
             Description = "Enabled/disable shadow copying of the assemblies"
             )]
        public bool ShadowCopyFiles;

        #endregion

        public override string ToString()
        {
            StringWriter sw = new StringWriter();
            sw.WriteLine("-- Parsed Arguments");
            sw.WriteLine("Assemblies:");
            foreach (string file in Assemblies)
                sw.WriteLine("\t{0}", file);

            sw.WriteLine("Hint Directories:");
            foreach (string hintDirectory in HintDirectories)
            {
                sw.WriteLine("\t{0}", hintDirectory);
            }

            sw.WriteLine("Plugin Directories:");
            foreach (string pluginDirectory in PluginDirectories)
            {
                sw.WriteLine("\t{0}", pluginDirectory);
            }

            sw.WriteLine("Report folder: {0}", ReportDirectory);
            sw.WriteLine("Report Name Format: {0}", ReportNameFormat);
            sw.WriteLine("Report types: {0}", String.Join(", ", ReportTypes));
            sw.WriteLine("Show reports: {0}", ShowReports);

            sw.WriteLine("Filter Category: {0}", String.Join(", ", FilterCategories));
            sw.WriteLine("Filter Author: {0}", String.Join(", ", FilterAuthors));
            sw.WriteLine("Filter Namespace: {0}", String.Join(", ", FilterNamespaces));
            sw.WriteLine("Filter Type: {0}", String.Join(", ", FilterTypes));

            sw.WriteLine("Verbosity: {0}", Verbosity);
            sw.WriteLine("Save Template Tree: {0}", SaveTemplateTree);
            sw.WriteLine("Save Test Tree: {0}", SaveTestTree);
            sw.WriteLine("ShadowCopyFiles: {0}", ShadowCopyFiles);
            return sw.ToString();
        }

        public Filter<ITest> GetFilter()
        {
            List<Filter<ITest>> filters = new List<Filter<ITest>>();

            if (FilterCategories.Length != 0)
            {
                List<Filter<ITest>> categoryFilters = new List<Filter<ITest>>();

                foreach (string category in FilterCategories)
                    categoryFilters.Add(new MetadataFilter<ITest>(MetadataKey.CategoryName, category));

                filters.Add(new OrFilter<ITest>(categoryFilters.ToArray()));
            }

            if (FilterAuthors.Length != 0)
            {
                List<Filter<ITest>> authorFilters = new List<Filter<ITest>>();

                foreach (string author in FilterAuthors)
                    authorFilters.Add(new MetadataFilter<ITest>(MetadataKey.AuthorName, author));

                filters.Add(new OrFilter<ITest>(authorFilters.ToArray()));
            }

            if (FilterImportances.Length != 0)
            {
                List<Filter<ITest>> importanceFilters = new List<Filter<ITest>>();

                foreach (TestImportance importance in FilterImportances)
                    importanceFilters.Add(new MetadataFilter<ITest>(MetadataKey.Importance, importance.ToString()));

                filters.Add(new OrFilter<ITest>(importanceFilters.ToArray()));
            }

            if (FilterNamespaces.Length != 0)
            {
                List<Filter<ITest>> namespaceFilters = new List<Filter<ITest>>();

                foreach (string @namespace in FilterNamespaces)
                    namespaceFilters.Add(new NamespaceFilter<ITest>(@namespace));

                filters.Add(new OrFilter<ITest>(namespaceFilters.ToArray()));
            }

            if (FilterTypes.Length != 0)
            {
                List<Filter<ITest>> typeFilters = new List<Filter<ITest>>();

                // FIXME: Should we always include derived types?
                foreach (string type in FilterTypes)
                    typeFilters.Add(new TypeFilter<ITest>(type, true));

                filters.Add(new OrFilter<ITest>(typeFilters.ToArray()));
            }

            return new AndFilter<ITest>(filters.ToArray());
        }
    }
}
<commit_msg>Display "Shadow Copy Files" instead of ShadowCopyFiles in debug output.<commit_after>// Copyright 2007 MbUnit Project - http://www.mbunit.com/
// Portions Copyright 2000-2004 <NAME>, <NAME>
// 
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// 
//     http://www.apache.org/licenses/LICENSE-2.0
// 
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

using System;
using System.Collections.Generic;
using System.IO;
using MbUnit.Core.Runner.CommandLine;
using MbUnit.Framework;
using MbUnit.Framework.Kernel.Filters;
using MbUnit.Framework.Kernel.Metadata;
using MbUnit.Framework.Kernel.Model;

namespace MbUnit.Echo
{
    public class MainArguments
    {
        #region Files and Directories

        [DefaultCommandLineArgument(
            CommandLineArgumentType.MultipleUnique,
            LongName = "assemblies",
            Description = "List of assemblies containing the tests."
            )]
        public string[] Assemblies;

        [CommandLineArgument(
            CommandLineArgumentType.MultipleUnique,
            ShortName = "hd",
            LongName = "hint-directories",
            Description = "The list of directories used for loading assemblies and other dependent resources.",
            ArgumentValueType = "dirs"
            )]
        public string[] HintDirectories;

        [CommandLineArgument(
            CommandLineArgumentType.MultipleUnique,
            ShortName = "pd",
            LongName = "plugin-directory",
            Description = "Additional MbUnit plugin directories to search recursively",
            ArgumentValueType = "dirs"
            )]
        public string[] PluginDirectories;

        [CommandLineArgument(
            CommandLineArgumentType.AtMostOnce,
            ShortName = "abd",
            LongName = "application-base-directory",
            Description = "The application base directory to set during test execution.",
            ArgumentValueType = "path"
            )]
        public string AppBaseDirectory = "";

        #endregion

        #region Report Arguments
        [CommandLineArgument(
             CommandLineArgumentType.AtMostOnce,
             ShortName = "rd",
             LongName = "report-directory",
            Description = "Target output directory for the reports",
            ArgumentValueType = "path"
             )]
        public string ReportDirectory = "";

        [CommandLineArgument(
             CommandLineArgumentType.AtMostOnce,
             ShortName = "rnf",
             LongName = "report-name-format",
             Description = "Format string for the report name. {0} is replaced by the date, {1} by the time.  Default = mbunit-{0}{1}",
             ArgumentValueType = "pattern"
             )]
        public string ReportNameFormat = "mbunit-result-{0}{1}";

        [CommandLineArgument(
             CommandLineArgumentType.MultipleUnique,
             ShortName = "rt",
             LongName = "report-type",
             Description = "Report types to generate.  See below for all supported types.",
             ArgumentValueType = "type"
        )]
        public string[] ReportTypes;

        [CommandLineArgument(
             CommandLineArgumentType.AtMostOnce,
             ShortName = "sr",
             LongName = "show-reports",
            Description = "Show generated reports in a window"
        )]
        public bool ShowReports;
        #endregion

        #region Filter Arguments

        [CommandLineArgument(
             CommandLineArgumentType.MultipleUnique,
             ShortName = "fc",
             LongName = "filter-category",
             Description = "Name of the filtered category"
             )]
        public string[] FilterCategories;

        [CommandLineArgument(
             CommandLineArgumentType.MultipleUnique,
             ShortName = "fa",
             LongName = "filter-author",
             Description = "Name of the filtered author name"
             )]
        public string[] FilterAuthors;

        [CommandLineArgument(
             CommandLineArgumentType.MultipleUnique,
             ShortName = "ft",
             LongName = "filter-type",
             Description = "Name of the filtered type"
             )]
        public string[] FilterTypes;

        [CommandLineArgument(
             CommandLineArgumentType.MultipleUnique,
             ShortName = "fn",
             LongName = "filter-namespace",
             Description = "Name of the filtered namespace"
             )]
        public string[] FilterNamespaces;

        [CommandLineArgument(
             CommandLineArgumentType.MultipleUnique,
             ShortName = "fi",
             LongName = "filter-importance",
             Description = "Name of the filtered importance"
             )]
        public TestImportance[] FilterImportances;

        #endregion

        #region Misc arguments

        [CommandLineArgument(
             CommandLineArgumentType.AtMostOnce,
             ShortName = "h",
             LongName = "help",
             Description = "Display this help text"
             )]
        public bool Help;

        [CommandLineArgument(
             CommandLineArgumentType.AtMostOnce,
             ShortName = "v",
             LongName = "verbosity",
             Description = "Controls the level of detail of the information to display"
             )]
        public Verbosity Verbosity = Verbosity.Normal;

        [CommandLineArgument(
             CommandLineArgumentType.AtMostOnce,
             LongName = "save-template-tree",
             Description = "Saves the template tree to a file as XML"
             )]
        public string SaveTemplateTree;

        [CommandLineArgument(
             CommandLineArgumentType.AtMostOnce,
             LongName = "save-test-tree",
             Description = "Saves the test tree to a file as XML"
             )]
        public string SaveTestTree;

        [CommandLineArgument(
             CommandLineArgumentType.AtMostOnce,
             ShortName = "sc",
             LongName = "shadow-copy-files",
             Description = "Enabled/disable shadow copying of the assemblies"
             )]
        public bool ShadowCopyFiles;

        #endregion

        public override string ToString()
        {
            StringWriter sw = new StringWriter();
            sw.WriteLine("-- Parsed Arguments");
            sw.WriteLine("Assemblies:");
            foreach (string file in Assemblies)
                sw.WriteLine("\t{0}", file);

            sw.WriteLine("Hint Directories:");
            foreach (string hintDirectory in HintDirectories)
            {
                sw.WriteLine("\t{0}", hintDirectory);
            }

            sw.WriteLine("Plugin Directories:");
            foreach (string pluginDirectory in PluginDirectories)
            {
                sw.WriteLine("\t{0}", pluginDirectory);
            }

            sw.WriteLine("Report folder: {0}", ReportDirectory);
            sw.WriteLine("Report Name Format: {0}", ReportNameFormat);
            sw.WriteLine("Report types: {0}", String.Join(", ", ReportTypes));
            sw.WriteLine("Show reports: {0}", ShowReports);

            sw.WriteLine("Filter Category: {0}", String.Join(", ", FilterCategories));
            sw.WriteLine("Filter Author: {0}", String.Join(", ", FilterAuthors));
            sw.WriteLine("Filter Namespace: {0}", String.Join(", ", FilterNamespaces));
            sw.WriteLine("Filter Type: {0}", String.Join(", ", FilterTypes));

            sw.WriteLine("Verbosity: {0}", Verbosity);
            sw.WriteLine("Save Template Tree: {0}", SaveTemplateTree);
            sw.WriteLine("Save Test Tree: {0}", SaveTestTree);
            sw.WriteLine("Shadow Copy Files: {0}", ShadowCopyFiles);
            return sw.ToString();
        }

        public Filter<ITest> GetFilter()
        {
            List<Filter<ITest>> filters = new List<Filter<ITest>>();

            if (FilterCategories.Length != 0)
            {
                List<Filter<ITest>> categoryFilters = new List<Filter<ITest>>();

                foreach (string category in FilterCategories)
                    categoryFilters.Add(new MetadataFilter<ITest>(MetadataKey.CategoryName, category));

                filters.Add(new OrFilter<ITest>(categoryFilters.ToArray()));
            }

            if (FilterAuthors.Length != 0)
            {
                List<Filter<ITest>> authorFilters = new List<Filter<ITest>>();

                foreach (string author in FilterAuthors)
                    authorFilters.Add(new MetadataFilter<ITest>(MetadataKey.AuthorName, author));

                filters.Add(new OrFilter<ITest>(authorFilters.ToArray()));
            }

            if (FilterImportances.Length != 0)
            {
                List<Filter<ITest>> importanceFilters = new List<Filter<ITest>>();

                foreach (TestImportance importance in FilterImportances)
                    importanceFilters.Add(new MetadataFilter<ITest>(MetadataKey.Importance, importance.ToString()));

                filters.Add(new OrFilter<ITest>(importanceFilters.ToArray()));
            }

            if (FilterNamespaces.Length != 0)
            {
                List<Filter<ITest>> namespaceFilters = new List<Filter<ITest>>();

                foreach (string @namespace in FilterNamespaces)
                    namespaceFilters.Add(new NamespaceFilter<ITest>(@namespace));

                filters.Add(new OrFilter<ITest>(namespaceFilters.ToArray()));
            }

            if (FilterTypes.Length != 0)
            {
                List<Filter<ITest>> typeFilters = new List<Filter<ITest>>();

                // FIXME: Should we always include derived types?
                foreach (string type in FilterTypes)
                    typeFilters.Add(new TypeFilter<ITest>(type, true));

                filters.Add(new OrFilter<ITest>(typeFilters.ToArray()));
            }

            return new AndFilter<ITest>(filters.ToArray());
        }
    }
}

{'fraction_non_alphanumeric': 0.09326643533714714, 'fraction_numerical': 0.003938853981055988, 'mean_word_length': 1.8087712366653497, 'pattern_counts': {'":': 0, '<': 79, '<?xml version=': 0, '>': 79, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, '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': '2353360', 'n_tokens_mistral': 5204, 'n_tokens_neox': 4870, 'n_words': 1305}