Example #1
0
 /// <summary>
 /// Sends a request to a child process, then waits for the response.
 /// </summary>
 /// <param name="pipe"> The pipe to use to send the message. </param>
 /// <param name="request"> The request to send. </param>
 /// <returns> The response. </returns>
 private WorkerProcessResponse Send(PipeServer pipe, WorkerProcessRequest request)
 {
     return(JsonConvert.DeserializeObject <WorkerProcessResponse>(pipe.Send(JsonConvert.SerializeObject(request))));
 }
Example #2
0
        /// <summary>
        /// Executes the test suite.
        /// </summary>
        public override void Run()
        {
            using (var pipeServer = new PipeServer(Id))
            {
                var dir          = @"..\..\..\Kangax\";
                var globalScript = File.ReadAllText(Path.Combine(dir, "global.js"));
                var entries      = JsonConvert.DeserializeObject <CompatTableEntry[]>(File.ReadAllText(Path.Combine(dir, "compat-table.json")));
                foreach (var testCase in entries)
                {
                    try
                    {
                        testCase.Response = Send(pipeServer, new WorkerProcessRequest
                        {
                            VariablesToReturn = new[] { "__asyncTestPassed" },
                            Script            = globalScript + Environment.NewLine + $"(function () {{ {testCase.script} }})();"
                        });
                        if (testCase.Response.JsonResult == "true" || testCase.Response.Variables?["__asyncTestPassed"] == "true")
                        {
                            testCase.Success = true;
                        }
                        if (testCase.Success == false &&
                            !testCase.name.StartsWith("Proxy") &&
                            !testCase.name.StartsWith("Reflect") &&
                            !testCase.name.StartsWith("generators") &&
                            !testCase.name.StartsWith("class") &&
                            !testCase.name.StartsWith("super") &&
                            !testCase.name.StartsWith("arrow functions") &&
                            !testCase.name.StartsWith("let") &&
                            !testCase.name.StartsWith("const") &&
                            !testCase.name.StartsWith("destructuring") &&
                            !testCase.name.StartsWith("spread syntax for iterable objects") &&
                            !testCase.name.StartsWith("miscellaneous subclassables") &&
                            !testCase.name.Contains("is subclassable"))
                        {
                            Console.WriteLine($"{testCase.name} -- {testCase.detail}, result: {testCase.Response.JsonResult ?? $"{testCase.Response.ErrorType}: {testCase.Response.ErrorMessage}"}");
                        }
                    }
                    catch (IOException)
                    {
                        Console.WriteLine("*** Worker process crashed ***");
                    }
                }

                Console.WriteLine();
                Console.WriteLine();
                foreach (var group in entries.GroupBy(e => e.group))
                {
                    Console.WriteLine($"**{group.Key}**|");
                    foreach (var test in group.GroupBy(e => e.name))
                    {
                        int successCount = test.Count(t => t.Success);
                        int totalCount   = test.Count();

                        string status = ":x:";
                        if (successCount == 0)
                        {
                            status = ":x:";
                        }
                        else if (successCount == totalCount)
                        {
                            status = $":white_check_mark: {successCount}/{totalCount}";
                        }
                        else
                        {
                            status = $"{successCount}/{totalCount}";
                        }
                        Console.WriteLine($"&nbsp;&nbsp;{test.Key.Replace("_", "\\_")}|{status}");
                    }
                }
            }
        }
Example #3
0
        /// <summary>
        /// Executes the test suite.
        /// </summary>
        public override void Run()
        {
            using (var pipeServer = new PipeServer(Id))
            {
                var entries = JsonConvert.DeserializeObject <CompatTableEntry[]>(File.ReadAllText(@"Kangax\compat-table.json"));
                foreach (var testCase in entries)
                {
                    try
                    {
                        testCase.Response = Send(pipeServer, new WorkerProcessRequest {
                            Script = $"(function () {{ {testCase.script} }})();"
                        });
                        if (testCase.Response.JsonResult == "true")
                        {
                            testCase.Success = true;
                        }
                        if (testCase.Success == false && Array.IndexOf(
                                new string[]
                        {
                            "default function parameters",
                            "for..of loops",
                            "template literals",
                            "typed arrays",
                            "WeakMap",
                            "Set",
                            "WeakMap",
                            "WeakSet",
                            "Object static methods",
                            @"function ""name"" property",
                            "Array static methods",
                            "Array.prototype methods",
                        }, testCase.name) >= 0)
                        {
                            Console.WriteLine($"{testCase.name} -- {testCase.detail}, result: {testCase.Response.JsonResult ?? $"{testCase.Response.ErrorType}: {testCase.Response.ErrorMessage}"}");
                        }
                    }
                    catch (IOException)
                    {
                        Console.WriteLine("*** Worker process crashed ***");
                    }
                }

                Console.WriteLine();
                Console.WriteLine();
                foreach (var group in entries.GroupBy(e => e.group))
                {
                    Console.WriteLine($"**{group.Key}**|");
                    foreach (var test in group.GroupBy(e => e.name))
                    {
                        int successCount = test.Count(t => t.Success);
                        int totalCount   = test.Count();

                        string status = ":x:";
                        if (successCount == 0)
                        {
                            status = ":x:";
                        }
                        else if (successCount == totalCount)
                        {
                            status = $":white_check_mark: {successCount}/{totalCount}";
                        }
                        else
                        {
                            status = $"{successCount}/{totalCount}";
                        }
                        Console.WriteLine($"&nbsp;&nbsp;{test.Key.Replace("_", "\\_")}|{status}");
                    }
                }
            }
        }