public void FromCommandLineArgsRaceCondition()
        {
            // https://pytools.codeplex.com/workitem/1429

            var mre   = new ManualResetEvent(false);
            var tasks = new Task <bool> [100];

            try {
                for (int i = 0; i < tasks.Length; i += 1)
                {
                    tasks[i] = Task.Run(() => {
                        mre.WaitOne();
                        using (var arg = VisualStudioApp.FromCommandLineArgs(new[] { "/parentProcessId", "123" })) {
                            return(arg is VisualStudioApp);
                        }
                    });
                }
                mre.Set();
                Assert.IsTrue(Task.WaitAll(tasks, TimeSpan.FromSeconds(30.0)));
                Assert.IsTrue(tasks.All(t => t.Result));
            } finally {
                mre.Dispose();
                Task.WaitAll(tasks, TimeSpan.FromSeconds(30.0));
            }
        }
예제 #2
0
        private void RunTestCases(IEnumerable <TestCase> tests, IRunContext runContext, IFrameworkHandle frameworkHandle)
        {
            // May be null, but this is handled by RunTestCase if it matters.
            // No VS instance just means no debugging, but everything else is
            // okay.
            using (var app = VisualStudioApp.FromCommandLineArgs(Environment.GetCommandLineArgs())) {
                // .njsproj file path -> project settings
                var sourceToSettings = new Dictionary <string, NodejsProjectSettings>();

                foreach (var test in tests)
                {
                    if (_cancelRequested.WaitOne(0))
                    {
                        break;
                    }

                    try {
                        RunTestCase(app, frameworkHandle, runContext, test, sourceToSettings);
                    } catch (Exception ex) {
                        frameworkHandle.SendMessage(TestMessageLevel.Error, ex.ToString());
                    }
                }
            }
        }
예제 #3
0
파일: TestDiscoverer.cs 프로젝트: krus/PTVS
 public TestDiscoverer()
 {
     _app = VisualStudioApp.FromCommandLineArgs(Environment.GetCommandLineArgs());
     _interpreterService = InterpreterOptionsServiceProvider.GetService(_app);
 }