public void CheckObsoleteGenerateFunction() { var path = PythonPaths.Versions.LastOrDefault(p => p != null && p.IsCPython); path.AssertInstalled(); var factory = InterpreterFactoryCreator.CreateInterpreterFactory(new InterpreterFactoryCreationOptions { Id = path.Id, LanguageVersion = path.Version.ToVersion(), Description = "Test Interpreter", Architecture = path.Isx64 ? ProcessorArchitecture.Amd64 : ProcessorArchitecture.X86, LibraryPath = path.LibPath, PrefixPath = path.PrefixPath, InterpreterPath = path.InterpreterPath, WatchLibraryForNewModules = false }); var tcs = new TaskCompletionSource <int>(); var beforeProc = Process.GetProcessesByName("Microsoft.PythonTools.Analyzer"); var request = new PythonTypeDatabaseCreationRequest { Factory = factory, OutputPath = TestData.GetTempPath(randomSubPath: true), 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"); }
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"); }