Example #1
0
        // In UWP(App models) Run will act as entry point from Application end, so making this method public
        public static void Run(string[] args)
        {
            DebuggerBreakpoint.WaitForNativeDebugger("VSTEST_HOST_NATIVE_DEBUG");
            DebuggerBreakpoint.WaitForDebugger("VSTEST_HOST_DEBUG");
            UILanguageOverride.SetCultureSpecifiedByUser();
            var argsDictionary = CommandLineArgumentsHelper.GetArgumentsDictionary(args);

            // Invoke the engine with arguments
            GetEngineInvoker(argsDictionary).Invoke(argsDictionary);
        }
Example #2
0
 /// <summary>
 /// Main entry point. Hands off execution to the executor class.
 /// </summary>
 /// <param name="args">Arguments provided on the command line.</param>
 /// <returns>0 if everything was successful and 1 otherwise.</returns>
 public static int Main(string[] args)
 {
     DebuggerBreakpoint.WaitForDebugger("VSTEST_RUNNER_DEBUG");
     UILanguageOverride.SetCultureSpecifiedByUser();
     return(new Executor(ConsoleOutput.Instance).Execute(args));
 }
Example #3
0
        public void Run(string[] args)
        {
            DebuggerBreakpoint.WaitForDebugger("VSTEST_DATACOLLECTOR_DEBUG");
            var argsDictionary = CommandLineArgumentsHelper.GetArgumentsDictionary(args);

            // Setup logging if enabled
            if (argsDictionary.TryGetValue(LogFileArgument, out var logFile))
            {
                var traceLevelInt        = CommandLineArgumentsHelper.GetIntArgFromDict(argsDictionary, TraceLevelArgument);
                var isTraceLevelArgValid = Enum.IsDefined(typeof(PlatformTraceLevel), traceLevelInt);

                // In case traceLevelInt is not defined in PlatfromTraceLevel, default it to verbose.
                var traceLevel = isTraceLevelArgValid ? (PlatformTraceLevel)traceLevelInt : PlatformTraceLevel.Verbose;

                // Initialize trace.
                EqtTrace.InitializeTrace(logFile, traceLevel);


                // Log warning in case tracelevel passed in arg is invalid
                if (!isTraceLevelArgValid)
                {
                    EqtTrace.Warning("DataCollectorMain.Run: Invalid trace level: {0}, defaulting to verbose tracelevel.", traceLevelInt);
                }
            }
            else
            {
                EqtTrace.DoNotInitailize = true;
            }

            if (EqtTrace.IsVerboseEnabled)
            {
                var version = typeof(DataCollectorMain)
                              .GetTypeInfo()
                              .Assembly
                              .GetCustomAttribute <AssemblyInformationalVersionAttribute>()?.InformationalVersion;
                EqtTrace.Verbose($"Version: { version }");
            }

            UILanguageOverride.SetCultureSpecifiedByUser();

            EqtTrace.Info("DataCollectorMain.Run: Starting data collector run with args: {0}", string.Join(",", args));

            // Attach to exit of parent process
            var parentProcessId = CommandLineArgumentsHelper.GetIntArgFromDict(argsDictionary, ParentProcessArgument);

            EqtTrace.Info("DataCollector: Monitoring parent process with id: '{0}'", parentProcessId);

            this.processHelper.SetExitCallback(
                parentProcessId,
                (obj) =>
            {
                EqtTrace.Info("DataCollector: ParentProcess '{0}' Exited.", parentProcessId);
                this.environment.Exit(1);
            });

            // Get server port and initialize communication.
            int port = argsDictionary.TryGetValue(PortArgument, out var portValue) ? int.Parse(portValue) : 0;

            if (port <= 0)
            {
                throw new ArgumentException("Incorrect/No Port number");
            }

            this.requestHandler.InitializeCommunication(port);

            // Can only do this after InitializeCommunication because datacollector cannot "Send Log" unless communications are initialized
            if (!string.IsNullOrEmpty(EqtTrace.LogFile))
            {
                (this.requestHandler as DataCollectionRequestHandler)?.SendDataCollectionMessage(new DataCollectionMessageEventArgs(TestMessageLevel.Informational, string.Format("Logging DataCollector Diagnostics in file: {0}", EqtTrace.LogFile)));
            }

            // Start processing async in a different task
            EqtTrace.Info("DataCollector: Start Request Processing.");
            StartProcessing();
        }