예제 #1
0
        protected override void ShowHelp()
        {
            // Show argument only help first because what we do next might take a little while
            // and we want to make the program appear responsive.
            base.ShowHelp();

            // Print out options related to the currently available set of plugins.
            var setup = new RuntimeSetup();

            if (Arguments != null && Arguments.PluginDirectories != null)
            {
                GenericCollectionUtils.ForEach(Arguments.PluginDirectories, x => setup.AddPluginDirectory(x));
            }

            using (RuntimeBootstrap.Initialize(setup, CreateLogger()))
            {
                IReportManager reportManager = RuntimeAccessor.ServiceLocator.Resolve <IReportManager>();
                ShowRegisteredComponents("Supported report types:", reportManager.FormatterHandles,
                                         h => h.GetTraits().Name, h => h.GetTraits().Description);

                ITestRunnerManager runnerManager = RuntimeAccessor.ServiceLocator.Resolve <ITestRunnerManager>();
                ShowRegisteredComponents("Supported runner types:", runnerManager.TestRunnerFactoryHandles,
                                         h => h.GetTraits().Name, h => h.GetTraits().Description);
            }
        }
예제 #2
0
        /// <inheritdoc />
        protected override int RunImpl(string[] args)
        {
            if (!ParseArguments(args))
            {
                ShowHelp();
                return(1);
            }

            if (Arguments.Help)
            {
                ShowHelp();
                return(0);
            }

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            var runtimeSetup = new RuntimeSetup();

            GenericCollectionUtils.ForEach(Arguments.PluginDirectories, x => runtimeSetup.AddPluginDirectory(x));

            ILogger logger = new FilteredLogger(new RichConsoleLogger(Console), Verbosity.Normal);

            using (RuntimeBootstrap.Initialize(runtimeSetup, logger))
            {
                IControlPanelPresenter presenter = RuntimeAccessor.Instance.ServiceLocator.Resolve <IControlPanelPresenter>();
                presenter.Show(null);
            }

            return(0);
        }
예제 #3
0
        protected override int RunImpl(string[] args)
        {
            if (!ParseArguments(args))
            {
                ShowHelp();
                return(1);
            }

            if (Arguments.Help)
            {
                ShowHelp();
                return(0);
            }

            RuntimeSetup runtimeSetup = new RuntimeSetup();

            runtimeSetup.RuntimePath = runtimePath;
            foreach (string pluginDirectory in Arguments.PluginDirectories)
            {
                runtimeSetup.AddPluginDirectory(pluginDirectory);
            }

            RichConsoleLogger runtimeLogger  = new RichConsoleLogger(Console);
            FilteredLogger    filteredLogger = new FilteredLogger(runtimeLogger, Arguments.Verbosity);

            RuntimeBootstrap.Initialize(runtimeSetup, filteredLogger);

            runtimeLogger.Log(LogSeverity.Important, "This program is a stub...");
            return(0);
        }
예제 #4
0
 public void Initialize(RuntimeSetup runtimeSetup, ILogger logger)
 {
     if (!RuntimeAccessor.IsInitialized)
     {
         RuntimeBootstrap.Initialize(runtimeSetup, logger);
         initializedRuntime = true;
     }
 }
예제 #5
0
        /// <inheritdoc />
        protected override int RunImpl(string[] args)
        {
            if (!ParseArguments(args))
            {
                ShowHelp();
                return(1);
            }

            if (Arguments.Help)
            {
                ShowHelp();
                return(0);
            }

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            UnhandledErrorPolicy();

            var runtimeSetup = new RuntimeSetup
            {
                RuntimePath = Path.GetDirectoryName(AssemblyUtils.GetFriendlyAssemblyLocation(
                                                        typeof(IcarusProgram).Assembly))
            };

            var runtimeLogger = new RuntimeLogger();

            GenericCollectionUtils.ForEach(Arguments.PluginDirectories, runtimeSetup.AddPluginDirectory);

            using (RuntimeBootstrap.Initialize(runtimeSetup, runtimeLogger))
            {
                // wire up services & components
                var scanner = new DefaultConventionScanner(RuntimeAccessor.Registry);
                scanner.Scan("Gallio.Icarus", Assembly.GetExecutingAssembly());

                LoadPackages();

                var optionsController = RuntimeAccessor.ServiceLocator.Resolve <IOptionsController>();

                // create & initialize a test runner whenever the test runner factory is changed
                optionsController.TestRunnerFactory.PropertyChanged += (s, e) =>
                                                                       ConfigureTestRunnerFactory(optionsController.TestRunnerFactory);

                ConfigureTestRunnerFactory(optionsController.TestRunnerFactory);

                var runtimeLogController = RuntimeAccessor.ServiceLocator.Resolve <IRuntimeLogController>();
                runtimeLogController.SetLogger(runtimeLogger);

                var applicationController = RuntimeAccessor.ServiceLocator.Resolve <IApplicationController>();
                applicationController.Arguments = Arguments;

                ErrorDialogUnhandledExceptionHandler.RunApplicationWithHandler(new Main(applicationController));

                UnloadPackages();
            }

            return(ResultCode.Success);
        }
 public static void Main()
 {
     using (TextWriter tw = new StreamWriter("RunTests.log"))
     {
         var logger = new TextLogger(tw);
         RuntimeBootstrap.Initialize(new RuntimeSetup(), logger);
         TestLauncher launcher = new TestLauncher();
         launcher.AddFilePattern("RunTests.exe");
         TestLauncherResult result = launcher.Run();
         Console.WriteLine(result.ResultSummary);
     }
 }
예제 #7
0
        public static void SetupRuntime(string runtimePath)
        {
            if (runtimePath == null)
            {
                throw new ArgumentNullException("runtimePath");
            }

            if (!RuntimeAccessor.IsInitialized)
            {
                var setup = new RuntimeSetup();
                setup.RuntimePath = runtimePath;
                RuntimeBootstrap.Initialize(setup, null);
            }
        }
예제 #8
0
        private IDisposable InitializeRuntimeIfNeeded(ref bool canceled)
        {
            IDisposable result = null;

            if (RuntimeSetup != null && !RuntimeAccessor.IsInitialized)
            {
                RunWithProgress(progressMonitor =>
                {
                    progressMonitor.BeginTask("Initializing the runtime and loading plugins.", 1);
                    result = RuntimeBootstrap.Initialize(RuntimeSetup, logger);
                }, ref canceled);
            }

            return(result);
        }
예제 #9
0
        protected override void ShowHelp()
        {
            // Show argument only help first because what we do next might take a little while
            // and we want to make the program appear responsive.
            base.ShowHelp();

            // Print out options related to the currently available set of plugins.
            var setup = new RuntimeSetup();

            using (RuntimeAccessor.IsInitialized ? null : RuntimeBootstrap.Initialize(setup, CreateLogger()))
            {
                IUtilityCommandManager utilityCommandManager = RuntimeAccessor.ServiceLocator.Resolve <IUtilityCommandManager>();
                ShowRegisteredComponents("Supported utility commands:", utilityCommandManager.CommandHandles, h => h.GetTraits().Name, h => h.GetTraits().Description);
            }
        }
예제 #10
0
        public Runner()
        {
            // Create a runtime setup.
            // There are a few things you can tweak here if you need.
            _setup = new Gallio.Runtime.RuntimeSetup();
            //_setup.RuntimePath = @"C:\Users\ack\bin\GallioBundle-3.2.750.0\bin"; // @"C:\Users\ack\bin\Gallio2"; //Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); //@"C:\Users\ack\bin\GallioBundle-3.2.750.0\bin";
            var binPath = new BinPathLocator().Locate();

            _isInitialized = File.Exists(Path.Combine(binPath, "Gallio.dll"));
            if (!_isInitialized)
            {
                return;
            }
            _setup.RuntimePath = binPath; //@"C:\Users\ack\src\AutoTest.Net\lib\Gallio";

            // Create a logger.
            // You can use the NullLogger but you will probably want a wrapper around your own ILogger thingy.
            _logger = Gallio.Runtime.Logging.NullLogger.Instance;

            // Initialize the runtime.
            // You only do this once.
            lock (_gallioLock)
            {
                if (!_runtimeInitialized)
                {
                    RuntimeBootstrap.Initialize(_setup, _logger);
                    _runtimeInitialized = true;
                }
            }

            // Create a test framework selector.
            // This is used by Gallio to filter the set of frameworks it will support.
            // You can set a predicate Filter here.  I've hardcoded MbUnit here but you could leave the filter out and set it to null.
            // The fallback mode tells Gallio what to do if it does not recognize the test framework associated with the test assembly.
            // Strict means don't do anything.  You might want to use Default or Approximate.  See docs.
            // You can also set options, probably don't care.
            var testFrameworkSelector = new TestFrameworkSelector()
            {
                Filter       = testFrameworkHandle => testFrameworkHandle.Id == "MbUnit.TestFramework",
                FallbackMode = TestFrameworkFallbackMode.Strict
            };

            // Now we need to get a suitably configured ITestDriver...
            var testFrameworkManager = RuntimeAccessor.ServiceLocator.Resolve <ITestFrameworkManager>();

            _testDriver = testFrameworkManager.GetTestDriver(testFrameworkSelector, _logger);
        }
예제 #11
0
        /// <inheritdoc />
        protected override int RunImpl(string[] args)
        {
            if (!ParseArguments(args))
            {
                ShowHelp();
                return(1);
            }

            if (Arguments.Help)
            {
                ShowHelp();
                return(0);
            }

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            UnhandledErrorPolicy();

            var runtimeSetup = CreateRuntimeSetup();

            var logger = new FilteredLogger(new RichConsoleLogger(Console), Verbosity.Normal);

            using (RuntimeBootstrap.Initialize(runtimeSetup, logger))
            {
                var scanner = new ComponentScanner(RuntimeAccessor.Registry);
                scanner.Scan();

                var copyController     = RuntimeAccessor.ServiceLocator.Resolve <ICopyController>();
                var progressController = RuntimeAccessor.ServiceLocator.Resolve <IProgressController>();
                var copyForm           = new CopyForm(copyController, progressController);

                ErrorDialogUnhandledExceptionHandler.RunApplicationWithHandler(copyForm);
            }

            return(ResultCode.Success);
        }
예제 #12
0
 public void Initialize(RuntimeSetup runtimeSetup, ILogger logger)
 {
     RuntimeBootstrap.Initialize(runtimeSetup, logger);
 }
예제 #13
0
        /// <inheritdoc />
        protected override int RunImpl(string[] args)
        {
            ShowBanner();
            InstallCancelHandler();

            if (!ParseArguments(args) || Arguments.CommandAndArguments.Length == 0)
            {
                ShowHelp();
                return(Arguments.Help ? 0 : 1);
            }

            ILogger logger = CreateLogger();
            IProgressMonitorProvider progressMonitorProvider = Arguments.NoProgress
                ? (IProgressMonitorProvider)NullProgressMonitorProvider.Instance
                : new RichConsoleProgressMonitorProvider(Console);

            string commandName = Arguments.CommandAndArguments[0];

            string[] commandRawArguments = new string[Arguments.CommandAndArguments.Length - 1];
            Array.Copy(Arguments.CommandAndArguments, 1, commandRawArguments, 0, commandRawArguments.Length);
            IUtilityCommand command          = GetSpecialCommand(commandName);
            bool            isSpecialCommand = command != null;
            var             runtimeSetup     = new RuntimeSetup();

            GenericCollectionUtils.ForEach(Arguments.PluginDirectories, x => runtimeSetup.AddPluginDirectory(x));

            using (isSpecialCommand ? null : RuntimeBootstrap.Initialize(runtimeSetup, logger))
            {
                if (command == null)
                {
                    var commandManager = RuntimeAccessor.ServiceLocator.Resolve <IUtilityCommandManager>();
                    command = commandManager.GetCommand(commandName);

                    if (command == null)
                    {
                        ShowErrorMessage(string.Format("Unrecognized utility command name: '{0}'.", commandName));
                        ShowHelp();
                        return(1);
                    }
                }

                Type commandArgumentsClass = command.GetArgumentClass();
                var  commandArgumentParser = new CommandLineArgumentParser(commandArgumentsClass, null);

                if (Arguments.Help)
                {
                    ShowHelpForParticularCommand(commandName, commandArgumentParser);
                    return(0);
                }

                object commandArguments = Activator.CreateInstance(commandArgumentsClass);

                if (!commandArgumentParser.Parse(commandRawArguments, commandArguments, ShowErrorMessage) || !command.ValidateArguments(commandArguments, ShowErrorMessage))
                {
                    ShowHelpForParticularCommand(commandName, commandArgumentParser);
                    return(1);
                }

                var commandContext = new UtilityCommandContext(commandArguments, Console, logger, progressMonitorProvider, Arguments.Verbosity);
                return(command.Execute(commandContext));
            }
        }