Пример #1
0
        public static void Launch()
        {
            if (!HasSolidityDebugAttachRequest)
            {
                MSTestRunner.RunAllTests(Assembly.GetExecutingAssembly());
            }
            else
            {
                var debugStopOnEntry = (Environment.GetEnvironmentVariable("DEBUG_STOP_ON_ENTRY") ?? string.Empty).Equals("true", StringComparison.OrdinalIgnoreCase);

                if (debugStopOnEntry && !Debugger.IsAttached)
                {
                    Debugger.Launch();
                }


                var cancelToken = new CancellationTokenSource();

                using (AttachSolidityDebugger(cancelToken))
                {
                    // Run all tests (blocking)
                    MSTestRunner.RunAllTests(Assembly.GetExecutingAssembly(), cancelToken.Token);
                    Console.WriteLine("Tests completed");
                }
            }
        }
Пример #2
0
        public static void Launch()
        {
            var debugSessionID = Environment.GetEnvironmentVariable("DEBUG_SESSION_ID");

            if (string.IsNullOrWhiteSpace(debugSessionID))
            {
                MSTestRunner.RunAllTests(Assembly.GetExecutingAssembly());
            }
            else
            {
                var debugStopOnEntry = (Environment.GetEnvironmentVariable("DEBUG_STOP_ON_ENTRY") ?? string.Empty).Equals("true", StringComparison.OrdinalIgnoreCase);

                if (debugStopOnEntry && !Debugger.IsAttached)
                {
                    Debugger.Launch();
                }

                using (var debuggingInstance = new Debugging(debugSessionID))
                {
                    debuggingInstance.InitializeDebugConnection();
                    debuggingInstance.SetupRpcDebuggingHook();

                    var cancelToken = new CancellationTokenSource();

                    debuggingInstance.OnDebuggerDisconnect += () =>
                    {
                        // If the C# debugger is not attached, we don't care about running the rest of the tests
                        // so exit program
                        if (!Debugger.IsAttached)
                        {
                            cancelToken.Cancel();
                            Environment.Exit(0);
                        }
                    };

                    // Run all tests (blocking)
                    MSTestRunner.RunAllTests(Assembly.GetExecutingAssembly(), cancelToken.Token);
                    Console.WriteLine("Tests completed");
                }
            }
        }