CSPspEmu.AutoTests.AutoTestsProgram.Run C# (CSharp) Method

Run() protected method

protected Run ( bool RunTestsViewOut, string PspAutoTestsFolder, string WildCardFilter ) : void
RunTestsViewOut bool
PspAutoTestsFolder string
WildCardFilter string
return void
        protected void Run(bool RunTestsViewOut, string PspAutoTestsFolder, string WildCardFilter)
        {
            foreach (var FileNameExpected in Directory.GetFiles(PspAutoTestsFolder, "*.expected", SearchOption.AllDirectories))
            {
                var FileNameBaseBase = Path.GetFileNameWithoutExtension(FileNameExpected);
                var FileNameBase = Path.GetDirectoryName(FileNameExpected) + @"\" + FileNameBaseBase;
                var FileNameExecutable = FileNameBase + ".prx";
                var FileNameSourceCode = FileNameBase + ".c";

                var MatchName = FileNameBase.Substr(PspAutoTestsFolder.Length).Replace("\\", "/");

                //Console.WriteLine(MatchName + " ~ " + Wildcard.WildcardToRegex(WildCardFilter));
                if (!new Regex(Wildcard.WildcardToRegex(WildCardFilter)).IsMatch(MatchName))
                {
                    continue;
                }

                bool Recompile = false;
                //bool Recompile = true;

                if (File.GetLastWriteTime(FileNameExecutable) != File.GetLastWriteTime(FileNameSourceCode))
                {
                    Recompile = true;
                }

            #if ENABLE_RECOMPILE
                if (Recompile)
                {
                    //PspAutoTestsFolder + @"\make.bat"
                    // FileNameBase
                    try { File.Delete(FileNameExecutable); } catch { }
                    var Output = ExecuteBat(PspAutoTestsFolder + @"\build.bat", FileNameBase);
                    if (!string.IsNullOrEmpty((Output)))
                    {
                        Console.Write("Compiling {0}...", FileNameBase);
                        Console.WriteLine("Result:");
                        Console.WriteLine("{0}", Output);
                    }
                    try
                    {
                        File.SetLastWriteTime(FileNameExecutable, File.GetLastWriteTime(FileNameSourceCode));
                    }
                    catch
                    {
                    }
                }
            #endif

                if (File.Exists(FileNameExecutable))
                {
                    RunFile(RunTestsViewOut, PspAutoTestsFolder, FileNameExecutable, FileNameExpected, FileNameBase);
                }
                else
                {
                    Console.WriteLine("Can't find executable for '{0}' '{1}'", FileNameExpected, FileNameExecutable);
                }
            }
        }