Exemplo n.º 1
0
        public void Test(bool debug = false, bool json = false, bool autoRemarks = false)
        {
            var errors = new StringBuilder();

            foreach (var samplePath in samples)
            {
                IList <FilesComparator> comparators = GetComparators(_sampleRoot, _resultsRoot, samplePath, debug);
                if (comparators.Count < 1)
                {
                    Console.WriteLine(" /!\\ ERROR: Missing result file \"" + samplePath + "\"");
                    errors.AppendLine("Missing result file \"" + samplePath + "\"");
                    continue;
                }
                foreach (var comparator in comparators)
                {
                    Console.WriteLine(comparator.paths.Result + " checked with " + comparator.GetType().Name);
                    var unit = new TestUnit(comparator, debug);
                    unit.Init(compilerExtensions, autoRemarks);
                    unit.Parse();
                    if (unit.Observer.HasErrors)
                    {
                        Console.WriteLine(" /!\\ EXCEPTION\n" + unit.Observer.DumpErrors());
                        errors.AppendLine(unit.Observer.DumpErrors());
                    }
                    else
                    {
                        if (json)
                        {
                            string filename = comparator.paths.Result;
                            //string name = Path.GetFileName(filename);
                            string extension = Path.GetExtension(filename);
                            filename = filename.Substring(0, filename.Length - extension.Length);
                            string[] lines = { unit.ToJSON() };
                            System.IO.File.WriteAllLines(filename + ".json", lines);
                        }

                        try
                        {
                            unit.Compare();
                            _nbOfTests++;
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(" /!\\ MISMATCH\n" + ex);
                            errors.Append("E");
                        }
                    }
                }
            }
            if (errors.Length > 0)
            {
                throw new Exception(errors.ToString());
            }
        }
Exemplo n.º 2
0
        public void Test(bool debug = false, bool json = false)
        {
            var errors = new StringBuilder();
            foreach (var samplePath in samples) {
                IList<FilesComparator> comparators = GetComparators(_sampleRoot, _resultsRoot, samplePath, debug);
                if (comparators.Count < 1) {
                    Console.WriteLine(" /!\\ ERROR: Missing result file \"" + samplePath + "\"");
                    errors.AppendLine("Missing result file \"" + samplePath + "\"");
                    continue;
                }
                foreach (var comparator in comparators) {
                    Console.WriteLine(comparator.paths.Result + " checked with " + comparator.GetType().Name);
                    var unit = new TestUnit(comparator, debug);
                    unit.Init(extensions);
                    unit.Parse();
                    if (unit.Observer.HasErrors)
                    {
                        Console.WriteLine(" /!\\ EXCEPTION\n" + unit.Observer.DumpErrors());
                        errors.AppendLine(unit.Observer.DumpErrors());
                    }
                    else
                    {
                        if (json)
                        {
                            string filename = comparator.paths.Result;
                            //string name = Path.GetFileName(filename);
                            string extension = Path.GetExtension(filename);
                            filename = filename.Substring(0, filename.Length - extension.Length);
                            string[] lines = {unit.ToJSON()};
                            System.IO.File.WriteAllLines(filename + ".json", lines);
                        }

                        try
                        {
                            unit.Compare();
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(" /!\\ MISMATCH\n" + ex);
                            errors.Append("E");
                        }
                    }
                }
            }
            if (errors.Length > 0) throw new Exception(errors.ToString());
        }