예제 #1
0
        public static bool DoTests(string root, string type, CompilationUnit unit, ref int id)
        {
            var all_succeeded = true;

            if (!Directory.Exists(root))
            {
                Console.WriteLine("Skipping non-existent directory: " + root);
                return(all_succeeded);
            }
            foreach (var file in GetFiles(root, "malformed"))
            {
                var collector = new DirtyCollector();
                var parser    = Parser.Open(file);
                parser.ParseFile(collector, unit, "Test" + id++);
                Console.WriteLine("{0} {1} {2} {3}", collector.ParseDirty ? "----" : "FAIL", "M", type,
                                  Path.GetFileNameWithoutExtension(file));
                all_succeeded &= collector.ParseDirty;
            }
            var task_master = new TestTaskMaster();

            foreach (var file in GetFiles(root, "errors"))
            {
                bool success;
                try
                {
                    var collector = new DirtyCollector();
                    var parser    = Parser.Open(file);
                    var test_type = parser.ParseFile(collector, unit, "Test" + id++);
                    success = collector.AnalyseDirty;
                    if (!success && test_type != null)
                    {
                        var tester = new CheckResult(task_master, test_type);
                        task_master.Slot(tester);
                        task_master.Run();
                        success = !tester.Success;
                    }
                }
                catch (Exception)
                {
                    success = false;
                }
                Console.WriteLine("{0} {1} {2} {3}", success ? "----" : "FAIL", "E", type,
                                  Path.GetFileNameWithoutExtension(file));
                all_succeeded &= success;
            }
            foreach (var file in GetFiles(root, "working"))
            {
                bool success;
                try
                {
                    var collector = new DirtyCollector();
                    var parser    = Parser.Open(file);
                    var test_type = parser.ParseFile(collector, unit, "Test" + id++);
                    success = !collector.AnalyseDirty && !collector.ParseDirty;
                    if (success && test_type != null)
                    {
                        var tester = new CheckResult(task_master, test_type);
                        task_master.Slot(tester);
                        task_master.Run();
                        success = tester.Success;
                    }
                }
                catch (Exception)
                {
                    success = false;
                }
                Console.WriteLine("{0} {1} {2} {3}", success ? "----" : "FAIL", "W", type,
                                  Path.GetFileNameWithoutExtension(file));
                all_succeeded &= success;
            }
            return(all_succeeded);
        }
예제 #2
0
 public static bool DoTests(string root, string type, CompilationUnit unit, UriLoader lib, ref int id)
 {
     var all_succeeded = true;
     if (!Directory.Exists(root))
     {
         Console.WriteLine("Skipping non-existent directory: " + root);
         return all_succeeded;
     }
     foreach (var file in GetFiles(root, "malformed"))
     {
         var collector = new DirtyCollector();
         var parser = Parser.Open(file);
         parser.ParseFile(collector, unit, "Test" + id++);
         Console.WriteLine("{0} {1} {2} {3}", collector.ParseDirty ? "----" : "FAIL", "M", type,
             Path.GetFileNameWithoutExtension(file));
         all_succeeded &= collector.ParseDirty;
     }
     var task_master = new TestTaskMaster();
     task_master.AddUriHandler(lib);
     foreach (var file in GetFiles(root, "errors"))
     {
         bool success;
         try
         {
             var collector = new DirtyCollector();
             var parser = Parser.Open(file);
             var test_type = parser.ParseFile(collector, unit, "Test" + id++);
             success = collector.AnalyseDirty;
             if (!success && test_type != null)
             {
                 var tester = new CheckResult(task_master, test_type);
                 tester.Slot();
                 task_master.Run();
                 success = !tester.Success;
             }
         }
         catch (Exception)
         {
             success = false;
         }
         Console.WriteLine("{0} {1} {2} {3}", success ? "----" : "FAIL", "E", type,
             Path.GetFileNameWithoutExtension(file));
         all_succeeded &= success;
     }
     foreach (var file in GetFiles(root, "working"))
     {
         bool success;
         try
         {
             var collector = new DirtyCollector();
             var parser = Parser.Open(file);
             var test_type = parser.ParseFile(collector, unit, "Test" + id++);
             success = !collector.AnalyseDirty && !collector.ParseDirty;
             if (success && test_type != null)
             {
                 var tester = new CheckResult(task_master, test_type);
                 tester.Slot();
                 task_master.Run();
                 success = tester.Success;
             }
         }
         catch (Exception)
         {
             success = false;
         }
         Console.WriteLine("{0} {1} {2} {3}", success ? "----" : "FAIL", "W", type,
             Path.GetFileNameWithoutExtension(file));
         all_succeeded &= success;
     }
     return all_succeeded;
 }