Beispiel #1
0
        public void CheckObsoleteGenerateFunction()
        {
            var path = PythonPaths.Versions.LastOrDefault(p => p != null && p.IsCPython);

            path.AssertInstalled();

            var factory = InterpreterFactoryCreator.CreateInterpreterFactory(path.Configuration) as PythonInterpreterFactoryWithDatabase;

            if (factory == null)
            {
                Assert.Inconclusive("Test requires PythonInterpreterFactoryWithDatabase");
            }

            var tcs        = new TaskCompletionSource <int>();
            var beforeProc = Process.GetProcessesByName("Microsoft.PythonTools.Analyzer");

            var request = new PythonTypeDatabaseCreationRequest {
                Factory       = factory,
                OutputPath    = TestData.GetTempPath(),
                SkipUnchanged = true,
                OnExit        = tcs.SetResult
            };

            Console.WriteLine("OutputPath: {0}", request.OutputPath);

#pragma warning disable 618
            PythonTypeDatabase.Generate(request);
#pragma warning restore 618

            int expected = 0;

            if (!tcs.Task.Wait(TimeSpan.FromMinutes(1.0)))
            {
                var proc = Process.GetProcessesByName("Microsoft.PythonTools.Analyzer")
                           .Except(beforeProc)
                           .ToArray();

                // Ensure we actually started running
                Assert.AreNotEqual(0, proc.Length, "Process is not running");

                expected = -1;

                // Kill the process
                foreach (var p in proc)
                {
                    Console.WriteLine("Killing process {0}", p.Id);
                    p.Kill();
                }

                Assert.IsTrue(tcs.Task.Wait(TimeSpan.FromMinutes(1.0)), "Process did not die");
            }

            Assert.AreEqual(expected, tcs.Task.Result, "Incorrect exit code");
        }
Beispiel #2
0
 public void InconclusiveTest()
 {
     Assert.Inconclusive();
 }