示例#1
0
 public static new void DoDeployment(TestContext context)
 {
     AssertListener.Initialize();
     PythonTestData.Deploy();
 }
示例#2
0
 public static void DoDeployment(TestContext context)
 {
     AssertListener.Initialize();
     PythonTestData.Deploy(includeTestData: false);
 }
 public static void DoDeployment(TestContext context)
 {
     AssertListener.Initialize();
     NodejsTestData.Deploy();
 }
示例#4
0
 static BaseDebuggerTests()
 {
     AssertListener.Initialize();
     PythonTestData.Deploy();
 }
示例#5
0
 static DatabaseTest27()
 {
     AssertListener.Initialize();
 }
示例#6
0
 static BaseDebuggerTests()
 {
     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
            });
        }
示例#8
0
 static ReplWindowPythonSmokeTests()
 {
     AssertListener.Initialize();
     PythonTestData.Deploy();
 }