예제 #1
0
        protected override async Task <ExitCode> InvokeInternal(ILogger logger)
        {
            var xmlResultsFilePath = Path.Combine(_arguments.OutputDirectory, "testResults.xml");

            File.Delete(xmlResultsFilePath);

            var stdoutFilePath = Path.Combine(_arguments.OutputDirectory, "wasm-console.log");

            File.Delete(stdoutFilePath);

            var logProcessor = new WasmTestMessagesProcessor(xmlResultsFilePath, stdoutFilePath, logger);
            var runner       = new WasmBrowserTestRunner(
                _arguments,
                PassThroughArguments,
                logProcessor,
                logger);

            var(driverService, driver) = GetChromeDriver(logger);
            try
            {
                return(await runner.RunTestsWithWebDriver(driverService, driver));
            }
            finally
            {
                driverService.Dispose();
                driver.Dispose();
            }
        }
예제 #2
0
 public WasmBrowserTestRunner(WasmTestBrowserCommandArguments arguments, IEnumerable <string> passThroughArguments,
                              WasmTestMessagesProcessor messagesProcessor, ILogger logger)
 {
     this._arguments            = arguments;
     this._logger               = logger;
     this._passThroughArguments = passThroughArguments;
     this._messagesProcessor    = messagesProcessor;
 }
예제 #3
0
        protected override async Task <ExitCode> InvokeInternal(ILogger logger)
        {
            var processManager = ProcessManagerFactory.CreateProcessManager();

            var engineBinary = _arguments.Engine switch
            {
                JavaScriptEngine.V8 => "v8",
                JavaScriptEngine.JavaScriptCore => "jsc",
                JavaScriptEngine.SpiderMonkey => "sm",
                _ => throw new ArgumentException()
            };

            var engineArgs = new List <string>();

            if (_arguments.Engine == JavaScriptEngine.V8)
            {
                // v8 needs this flag to enable WASM support
                engineArgs.Add("--expose_wasm");
            }

            engineArgs.AddRange(_arguments.EngineArgs);
            engineArgs.Add(_arguments.JSFile);

            if (_arguments.Engine == JavaScriptEngine.V8 || _arguments.Engine == JavaScriptEngine.JavaScriptCore)
            {
                // v8/jsc want arguments to the script separated by "--", others don't
                engineArgs.Add("--");
            }

            engineArgs.AddRange(PassThroughArguments);

            var xmlResultsFilePath = Path.Combine(_arguments.OutputDirectory, "testResults.xml");

            File.Delete(xmlResultsFilePath);

            try
            {
                var logProcessor = new WasmTestMessagesProcessor(xmlResultsFilePath, logger);
                var result       = await processManager.ExecuteCommandAsync(
                    engineBinary,
                    engineArgs,
                    log : new CallbackLog(m => logger.LogInformation(m)),
                    stdoutLog : new CallbackLog(logProcessor.Invoke)
                {
                    Timestamp = false                                                   /* we need the plain XML string so disable timestamp */
                },
                    stderrLog : new CallbackLog(m => logger.LogError(m)),
                    _arguments.Timeout);

                return(result.Succeeded ? ExitCode.SUCCESS : (result.TimedOut ? ExitCode.TIMED_OUT : ExitCode.GENERAL_FAILURE));
            }
            catch (Win32Exception e) when(e.NativeErrorCode == 2)
            {
                logger.LogCritical($"The engine binary `{engineBinary}` was not found");
                return(ExitCode.APP_LAUNCH_FAILURE);
            }
        }
    }
예제 #4
0
        protected override async Task <ExitCode> InvokeInternal(ILogger logger)
        {
            var xmlResultsFilePath = Path.Combine(_arguments.OutputDirectory, "testResults.xml");

            File.Delete(xmlResultsFilePath);

            var logProcessor = new WasmTestMessagesProcessor(xmlResultsFilePath, logger);
            var runner       = new WasmBrowserTestRunner(
                _arguments,
                PassThroughArguments,
                logProcessor.Invoke,
                logger);

            using var driver = GetChromeDriver();
            return(await runner.RunTestsWithWebDriver(driver));
        }
        protected override async Task <ExitCode> InvokeInternal(ILogger logger)
        {
            var xmlResultsFilePath = Path.Combine(_arguments.OutputDirectory, "testResults.xml");

            File.Delete(xmlResultsFilePath);

            var stdoutFilePath = Path.Combine(_arguments.OutputDirectory, "wasm-console.log");

            File.Delete(stdoutFilePath);

            var logProcessor = new WasmTestMessagesProcessor(xmlResultsFilePath, stdoutFilePath, logger);
            var runner       = new WasmBrowserTestRunner(
                _arguments,
                PassThroughArguments,
                logProcessor,
                logger);

            (DriverService driverService, IWebDriver driver) = _arguments.Browser switch
            {
                Browser.Chrome => GetChromeDriver(logger),
                Browser.Safari => GetSafariDriver(logger),
                Browser.Firefox => GetFirefoxDriver(logger),
                Browser.Edge => GetEdgeDriver(logger),

                // shouldn't reach here
                _ => throw new ArgumentException($"Unknown browser : {_arguments.Browser}")
            };

            try
            {
                return(await runner.RunTestsWithWebDriver(driverService, driver));
            }
            finally
            {
                driver.Quit();  // Firefox driver hangs if Quit is not issued.
                driverService.Dispose();
                driver.Dispose();
            }
        }