예제 #1
0
 static SendToReplTests()
 {
     AssertListener.Initialize();
     PythonTestData.Deploy();
 }
예제 #2
0
 static BaseDebuggerTests()
 {
     AssertListener.Initialize();
 }
예제 #3
0
 static IronPythonReplEvaluatorTests()
 {
     AssertListener.Initialize();
 }
예제 #4
0
 static DatabaseTest27()
 {
     AssertListener.Initialize();
 }
예제 #5
0
 static MutateStdLibTest()
 {
     AssertListener.Initialize();
 }
예제 #6
0
파일: SmartTagTests.cs 프로젝트: xNUTs/PTVS
 public static void DoDeployment(TestContext context)
 {
     AssertListener.Initialize();
     PythonTestData.Deploy(includeTestData: false);
 }
예제 #7
0
 public static void DoDeployment(TestContext context)
 {
     AssertListener.Initialize();
     VsProjectAnalyzer.DefaultTimeout         = 10000;
     VsProjectAnalyzer.AssertOnRequestFailure = true;
 }
예제 #8
0
 public static new void DoDeployment(TestContext context)
 {
     AssertListener.Initialize();
     PythonTestData.Deploy();
 }
예제 #9
0
 static BuildTasksUI27Tests()
 {
     AssertListener.Initialize();
     PythonTestData.Deploy();
 }
예제 #10
0
 public void TestInitialize()
 {
     AnalysisLog.Reset();
     AssertListener.Initialize();
 }
예제 #11
0
 public static void DoDeployment(TestContext context)
 {
     AssertListener.Initialize();
     NodejsUwpTestData.Deploy();
 }
예제 #12
0
 static BaseAnalysisTest()
 {
     AnalysisLog.Reset();
     AssertListener.Initialize();
 }
예제 #13
0
 public static void DoDeployment(TestContext context)
 {
     AssertListener.Initialize();
     AstPythonInterpreterFactory.LogToConsole = true;
 }
예제 #14
0
 public override void DoDeployment(TestContext context)
 {
     AssertListener.Initialize();
 }
예제 #15
0
파일: ProjectTests.cs 프로젝트: yuts/PTVS
 public static void Initialize(TestContext context)
 {
     AssertListener.Initialize();
 }
예제 #16
0
 static BaseDebuggerTests()
 {
     AssertListener.Initialize();
     PythonTestData.Deploy();
 }
예제 #17
0
 static ReplWindowPythonSmokeTests()
 {
     PythonTestData.Deploy();
     AssertListener.Initialize();
 }
예제 #18
0
 static DatabaseTest27()
 {
     AssertListener.Initialize();
     PythonTestData.Deploy(includeTestData: false);
 }
예제 #19
0
 static IronPythonReplEvaluatorTests()
 {
     AssertListener.Initialize();
     PythonTestData.Deploy(includeTestData: false);
 }
예제 #20
0
 public static void DoDeployment(TestContext context)
 {
     AssertListener.Initialize();
     ExtractResource("ruleFormattingTests.json");
 }
예제 #21
0
 public static void DoDeployment(TestContext context)
 {
     AssertListener.Initialize();
 }
        private IVsHostedPythonToolsTestResult InvokeTest(Type type, MethodInfo method, object[] arguments)
        {
            object instance;

            if (!_activeInstances.TryGetValue(type, out instance))
            {
                instance = Activator.CreateInstance(type);
                _activeInstances[type] = instance;
            }

            var args      = new List <object>();
            var inputArgs = arguments.ToList();
            var sp        = ServiceProvider.GlobalProvider;
            var dte       = ServiceProvider.GlobalProvider.GetService(typeof(EnvDTE.DTE));

            try {
                try {
                    var shell = (IVsShell)ServiceProvider.GlobalProvider.GetService(typeof(SVsShell));
                    foreach (var guid in _dependentPackageGuids)
                    {
                        int installed;
                        var pkgGuid = guid;
                        ErrorHandler.ThrowOnFailure(
                            shell.IsPackageInstalled(ref pkgGuid, out installed)
                            );
                        if (installed == 0)
                        {
                            throw new NotSupportedException($"Package {pkgGuid} is not installed");
                        }
                        ErrorHandler.ThrowOnFailure(shell.LoadPackage(pkgGuid, out _));
                    }
                } catch (Exception ex) {
                    return(new HostedPythonToolsTestResult {
                        IsSuccess = false,
                        ExceptionType = ex.GetType().FullName,
                        ExceptionMessage = "Failed to load a dependent VS package." + Environment.NewLine + ex.Message,
                        ExceptionTraceback = ex.StackTrace
                    });
                }

                foreach (var a in method.GetParameters())
                {
                    if (a.ParameterType.IsAssignableFrom(typeof(IServiceProvider)))
                    {
                        args.Add(sp);
                    }
                    else if (a.ParameterType.IsAssignableFrom(typeof(EnvDTE.DTE)))
                    {
                        args.Add(dte);
                    }
                    else if (inputArgs.Count > 0 && a.ParameterType.IsAssignableFrom(inputArgs[0].GetType()))
                    {
                        args.Add(inputArgs[0]);
                        inputArgs.RemoveAt(0);
                    }
                    else
                    {
                        args.Add(ConstructParameter(a.ParameterType, sp, dte, inputArgs));
                    }
                }
            } catch (Exception ex) {
                return(new HostedPythonToolsTestResult {
                    IsSuccess = false,
                    ExceptionType = ex.GetType().FullName,
                    ExceptionMessage = "Failed to invoke test method with correct arguments." + Environment.NewLine + ex.Message,
                    ExceptionTraceback = ex.StackTrace
                });
            }

            AssertListener.Initialize();

            try {
                try {
                    if (typeof(Task).IsAssignableFrom(method.ReturnType))
                    {
                        ThreadHelper.JoinableTaskFactory.Run(() => (Task)method.Invoke(instance, args.ToArray()));
                    }
                    else
                    {
                        method.Invoke(instance, args.ToArray());
                    }

                    AssertListener.ThrowUnhandled();
                } finally {
                    foreach (var a in args)
                    {
                        if (a == sp || a == dte)
                        {
                            continue;
                        }
                        (a as IDisposable)?.Dispose();
                    }
                }
            } catch (Exception ex) {
                if (ex is TargetInvocationException || ex is AggregateException)
                {
                    ex = ex.InnerException;
                }

                return(new HostedPythonToolsTestResult {
                    IsSuccess = false,
                    ExceptionType = ex.GetType().FullName,
                    ExceptionMessage = ex.Message,
                    ExceptionTraceback = ex.StackTrace
                });
            }

            return(new HostedPythonToolsTestResult {
                IsSuccess = true
            });
        }