/// <summary>
		/// Flags Unity projects for debugging with this addin
		/// </summary>
		protected override bool CanExecute (SolutionEntityItem item, ExecutionContext context, ConfigurationSelector configuration)
		{
			if (CanExecuteProject (item as Project, context)) {
				return context.ExecutionHandler.CanExecute (new UnityExecutionCommand (item.BaseDirectory.FullPath));
			}
			return base.CanExecute (item, context, configuration);
		}
    protected override Task OnExecute(ProgressMonitor monitor, ExecutionContext context, ConfigurationSelector configuration)
    {
      if (base.OnGetCanExecute(context, configuration))
      {
        return base.OnExecute(monitor, context, configuration);
      }

      try
      {
        var project = Project as DotNetProject;
        if (project != null && IsSupportedProject)
        {
          const string SoftDebuggerName = RhinoSoftDebuggerEngine.DebuggerName;
          var config = project.GetConfiguration(configuration) as DotNetProjectConfiguration;
          var cmd = new RhinoCommonExecutionCommand(project.GetOutputFileName(configuration), project);
          cmd.Arguments = config.CommandLineParameters;
          cmd.WorkingDirectory = Path.GetDirectoryName(config.CompiledOutputName);
          cmd.EnvironmentVariables = config.GetParsedEnvironmentVariables();
          cmd.TargetRuntime = project.TargetRuntime;
          cmd.UserAssemblyPaths = project.GetUserAssemblyPaths(configuration);

          var executionModes = Runtime.ProcessService.GetExecutionModes();
          var executionMode = executionModes.SelectMany(r => r.ExecutionModes).FirstOrDefault(r => r.Id == SoftDebuggerName);
          var console = context.ConsoleFactory.CreateConsole(new OperationConsoleFactory.CreateConsoleOptions(true));
          var operation = executionMode.ExecutionHandler.Execute(cmd, console);
          monitor.CancellationToken.Register(() => operation.Cancel());
          return operation.Task;
        }
      }
      catch (Exception ex)
      {
        monitor.ReportError($"An error occurred starting Rhino.\n{ex}", ex);
      }
      return null;
    }
Esempio n. 3
0
        /// <summary>
        /// Determines whether this solution item can be executed using the specified context and configuration.
        /// </summary>
        /// <param name="context">Context.</param>
        /// <param name="solutionConfiguration">Solution configuration.</param>
        protected override bool OnGetCanExecute(MonoDevelop.Projects.ExecutionContext context, ConfigurationSelector solutionConfiguration)
        {
            var conf             = (CProjectConfiguration)GetConfiguration(solutionConfiguration);
            ExecutionCommand cmd = CreateExecutionCommand(conf);

            return((target == CompileTarget.Exe) && context.ExecutionHandler.CanExecute(cmd));
        }
Esempio n. 4
0
        public static AsyncOperation RunTests(IEnumerable <UnitTest> tests, MonoDevelop.Projects.ExecutionContext context)
        {
            var result = RunTests(tests, context, IdeApp.Preferences.BuildBeforeRunningTests);

            result.Task.ContinueWith(t => OnTestSessionCompleted(), TaskScheduler.FromCurrentSynchronizationContext());
            return(result);
        }
		internal protected virtual Task Execute (ProgressMonitor monitor, ExecutionContext context, ConfigurationSelector configuration, SolutionRunConfiguration runConfiguration)
		{
			context.RunConfiguration = runConfiguration;
#pragma warning disable 618 // Type or member is obsolete
			return Execute (monitor, context, configuration);
#pragma warning restore 618 // Type or member is obsolete
		}
Esempio n. 6
0
        public static AsyncOperation RunTest(UnitTest test, MonoDevelop.Projects.ExecutionContext context)
        {
            var result = RunTest(test, context, true);

            result.Task.ContinueWith(t => OnTestSessionCompleted(), TaskScheduler.FromCurrentSynchronizationContext());
            return(result);
        }
        protected override bool OnGetCanExecute(MonoDevelop.Projects.ExecutionContext context, ConfigurationSelector config)
        {
            var configuration = (AspNetAppProjectConfiguration)GetConfiguration(config);
            var cmd           = CreateExecutionCommand(config, configuration);

            return(context.ExecutionHandler.CanExecute(cmd));
        }
Esempio n. 8
0
        protected override void DoExecute(IProgressMonitor monitor, ExecutionContext context, ConfigurationSelector configuration)
        {
            IodineConfiguration config = (IodineConfiguration)GetConfiguration (configuration);
            IConsole console = config.ExternalConsole ?
                context.ExternalConsoleFactory.CreateConsole (!config.PauseConsoleOutput) :
                context.ConsoleFactory.CreateConsole (!config.PauseConsoleOutput);

            AggregatedOperationMonitor aggregatedMonitor = new AggregatedOperationMonitor (monitor);
            try {
                string param = string.Format ("\"{0}\" {1}", config.MainFile, config.CommandLineParameters);

                IProcessAsyncOperation op = Runtime.ProcessService.StartConsoleProcess ("iodine",
                        param, BaseDirectory,
                        config.EnvironmentVariables, console, null);

                monitor.CancelRequested += delegate {
                    op.Cancel ();
                };

                aggregatedMonitor.AddOperation (op);
                op.WaitForCompleted ();
                monitor.Log.WriteLine ("Iodine exited with code: " + op.ExitCode);

            } catch (Exception e) {
                monitor.ReportError (GettextCatalog.GetString ("Cannot execute \"{0}\"", config.MainFile), e);
            } finally {
                console.Dispose ();
                aggregatedMonitor.Dispose ();
            }
        }
        internal static async Task RunTests(IEnumerable <UnitTest> tests, MonoDevelop.Projects.ExecutionContext context, bool buildOwnerObject, bool checkCurrentRunOperation, CancellationTokenSource cs)
        {
            if (buildOwnerObject)
            {
                var build_targets = new HashSet <IBuildTarget> ();
                foreach (var t in tests)
                {
                    if (t.OwnerObject is IBuildTarget bt)
                    {
                        build_targets.Add(bt);
                    }
                }
                var res = await IdeApp.ProjectOperations.CheckAndBuildForExecute(
                    build_targets, IdeApp.Workspace.ActiveConfiguration, buildWithoutPrompting : !IdeApp.Preferences.BuildBeforeRunningTests,
                    false, null, cs.Token);

                if (!res)
                {
                    return;
                }

                var test_names = new HashSet <string> (tests.Select((v) => v.FullName));

                await RefreshTests(cs.Token);

                tests = test_names.Select((fullName) => SearchTest(fullName)).Where((t) => t != null).ToList();

                if (tests.Any())
                {
                    await RunTests(tests, context, false, checkCurrentRunOperation, cs);
                }
                return;
            }

            if (checkCurrentRunOperation && !IdeApp.ProjectOperations.ConfirmExecutionOperation())
            {
                return;
            }

            Pad resultsPad = GetTestResultsPad();

            var         test    = tests.Count() == 1 ? tests.First() : new UnitTestSelection(tests, tests.First().OwnerObject);
            TestSession session = new TestSession(test, context, (TestResultsPad)resultsPad.Content, cs);

            OnTestSessionStarting(new TestSessionEventArgs {
                Session = session, Test = test
            });

            if (checkCurrentRunOperation)
            {
                IdeApp.ProjectOperations.AddRunOperation(session);
            }

            try {
                await session.Start();
            } finally {
                resultsPad.Sticky = false;
            }
        }
Esempio n. 10
0
        protected override bool OnGetCanExecute(MonoDevelop.Projects.ExecutionContext context, ConfigurationSelector solutionConfiguration)
        {
            ValaProjectConfiguration conf = (ValaProjectConfiguration)GetConfiguration(solutionConfiguration);
            ExecutionCommand         cmd  = CreateExecutionCommand(conf);

            return((conf.CompileTarget == ValaBinding.CompileTarget.Bin) &&
                   context.ExecutionHandler.CanExecute(cmd));
        }
 public TestSession(UnitTest test, MonoDevelop.Projects.ExecutionContext context, TestResultsPad resultsPad, CancellationTokenSource cs)
 {
     this.test               = test;
     this.context            = new Projects.ExecutionContext(context.ExecutionHandler, new CustomConsoleFactory(context.ConsoleFactory, cs), context.ExecutionTarget);
     CancellationTokenSource = cs;
     this.monitor            = new TestMonitor(resultsPad, CancellationTokenSource);
     this.resultsPad         = resultsPad;
     resultsPad.InitializeTestRun(test, cs);
 }
Esempio n. 12
0
		internal TestContext (ITestProgressMonitor monitor, TestResultsPad resultsPad, MonoDevelop.Projects.ExecutionContext executionContext, DateTime testDate)
		{
			this.monitor = monitor;
			if (executionContext == null)
				executionContext = new ExecutionContext (Runtime.ProcessService.DefaultExecutionHandler, IdeApp.Workbench.ProgressMonitors.ConsoleFactory, null);
			this.executionContext = executionContext;
			// Round to seconds
			this.testDate = new DateTime ((testDate.Ticks / TimeSpan.TicksPerSecond) * TimeSpan.TicksPerSecond);
		}
 public static bool CanRun(OpenFLProject project, OpenFLProjectConfiguration configuration, ExecutionContext context)
 {
     ExecutionCommand cmd = (NativeExecutionCommand)CreateExecutionCommand (project, configuration);
     if (cmd == null)
     {
         return false;
     }
     return context.ExecutionHandler.CanExecute (cmd);
 }
 protected override bool OnGetCanExecute(MonoDevelop.Projects.ExecutionContext context, ConfigurationSelector configuration, SolutionItemRunConfiguration runConfiguration)
 {
     if (runConfiguration == unitTestingRunConfigurationInstance)
     {
         UnitTest test = FindRootTest();
         return((test != null) && test.CanRun(context.ExecutionHandler));
     }
     return(base.OnGetCanExecute(context, configuration, runConfiguration));
 }
Esempio n. 15
0
		public static IAsyncOperation Debug (this ProjectOperations opers, IBuildTarget entry)
		{
			if (opers.CurrentRunOperation != null && !opers.CurrentRunOperation.IsCompleted)
				return opers.CurrentRunOperation;

			ExecutionContext context = new ExecutionContext (DebuggingService.GetExecutionHandler (), IdeApp.Workbench.ProgressMonitors, IdeApp.Workspace.ActiveExecutionTarget);

			IAsyncOperation op = opers.Execute (entry, context);
			return op;
		}
		public override bool CanExecute (IBuildTarget item, ExecutionContext context, ConfigurationSelector configuration)
		{
			var retval = false;
			if(item is DotNetProject)
			{
				var p = item as DotNetProject;
				retval = p.References.Any(y=>y.Reference.Contains("manos"));
			}
			return retval || base.CanExecute(item,context, configuration);
		}
Esempio n. 17
0
		public static IAsyncOperation ProfileFile (IProfiler profiler, string fileName)
		{
			if (IdeApp.ProjectOperations.CurrentRunOperation != null
			       && !IdeApp.ProjectOperations.CurrentRunOperation.IsCompleted)
			       return IdeApp.ProjectOperations.CurrentRunOperation;
			
			SwitchWorkbenchContext (ProfileWorkbenchContext);
			ExecutionContext context = new ExecutionContext (profiler.GetDefaultExecutionHandlerFactory (), IdeApp.Workbench.ProgressMonitors);

			return IdeApp.ProjectOperations.ExecuteFile (fileName, context);
		}
		public override bool CanExecute (IBuildTarget item, ExecutionContext context, ConfigurationSelector configuration)
		{
			// We check for DefaultExecutionHandlerFactory because the tests can't run using any other execution mode
			
			bool res = base.CanExecute (item, context, configuration);
			if (!res && (item is IWorkspaceObject)) {
				UnitTest test = NUnitService.Instance.FindRootTest ((IWorkspaceObject)item);
				return (test != null) && test.CanRun (context.ExecutionHandler);
			} else
				return res;
		}
		protected override bool OnGetCanExecute(ExecutionContext context, ConfigurationSelector configuration)
		{
			if(IdeApp.Workspace.GetAllSolutions().Any((s) => s.StartupItem == this))
			{
				return context.ExecutionTarget is MicroFrameworkExecutionTarget && base.OnGetCanExecute(context, configuration);
			}
			else
			{
				return base.OnGetCanExecute(context, configuration);
			}
		}
		/// <summary>
		/// Launch Unity project
		/// </summary>
		public override void Execute (MonoDevelop.Core.IProgressMonitor monitor, IBuildTarget item, ExecutionContext context, ConfigurationSelector configuration)
		{
			if (CanExecuteProject (item as Project, context)) {
				DispatchService.GuiDispatch (delegate {
					IdeApp.Workbench.CurrentLayout = "Debug";
					IdeApp.ProjectOperations.CurrentRunOperation = context.ExecutionHandler.Execute (new UnityExecutionCommand (item.BaseDirectory.FullPath), context.ConsoleFactory.CreateConsole (true));
				});
			} else {
				base.Execute (monitor, item, context, configuration);
			}
		}
Esempio n. 21
0
 internal TestContext(ITestProgressMonitor monitor, MonoDevelop.Projects.ExecutionContext executionContext, DateTime testDate)
 {
     this.monitor = monitor;
     if (executionContext == null)
     {
         executionContext = new ExecutionContext(Runtime.ProcessService.DefaultExecutionHandler, IdeApp.Workbench.ProgressMonitors.ConsoleFactory, null);
     }
     this.executionContext = executionContext;
     // Round to seconds
     this.testDate = new DateTime((testDate.Ticks / TimeSpan.TicksPerSecond) * TimeSpan.TicksPerSecond);
 }
Esempio n. 22
0
        async Task RunTests(IEnumerable <ProjectFileEventArgs> l)
        {
            if (l.Count() == 1 && l.First().First().ProjectFile.FilePath.FileName.ToLower().StartsWith("resource.designer"))
            {
                return;
            }

            var commonProject = l.Select(r => r.CommonProject).Distinct().First();

            var rootTest = UnitTestService.FindRootTest(commonProject.ParentSolution.RootFolder);

            HashSet <UnitTest> tests = new HashSet <UnitTest>();
            var rootGroup            = rootTest as UnitTestGroup;

            foreach (var e in l)
            {
                foreach (var file in e)
                {
                    foreach (var testGroup in rootGroup.Tests)
                    {
                        if (AddInPreferences.ProjectTestMap.Any(p => p.Project == file.Project.Name && p.Test == testGroup.Name))
                        {
                            tests.Add(testGroup);
                        }
                    }
                }
            }

            var coll = new CustomTestGroup(
                "Specified tests",
                rootTest.OwnerObject
                );

            var context = new MonoDevelop.Projects.ExecutionContext(
                Runtime.ProcessService.DefaultExecutionHandler, IdeApp.Workbench.ProgressMonitors.ConsoleFactory, IdeApp.Workspace.ActiveExecutionTarget);

            foreach (var test in tests)
            {
                var tmp = new CustomTestGroup("this isnt a real test", test.OwnerObject);

                // We're only calling this so that the owner object gets built properly.
                // This will fail to run the tests because it tries to find the test
                // by name again after building the project, in case it was removed.
                // Since this is a temporary test group, it won't find it and will just return.

                await UnitTestService.RunTest(tmp, context).Task;

                coll.Tests.Add(test);
            }

            // To get around this, run the tests again but don't build the owner object:
            UnitTestService.RunTest(coll, context, false);
        }
Esempio n. 23
0
		public static IAsyncOperation ProfileApplication (IProfiler profiler, string executable, string workingDirectory, string args)
		{
			if (IdeApp.ProjectOperations.CurrentRunOperation != null
			       && !IdeApp.ProjectOperations.CurrentRunOperation.IsCompleted)
			       return IdeApp.ProjectOperations.CurrentRunOperation;
			
			SwitchWorkbenchContext (ProfileWorkbenchContext);
			ExecutionContext context = new ExecutionContext (profiler.GetDefaultExecutionHandlerFactory (), IdeApp.Workbench.ProgressMonitors);

			//TODO: 
			return NullAsyncOperation.Failure;
		}
Esempio n. 24
0
        protected override bool OnGetCanExecute(MonoDevelop.Projects.ExecutionContext context, ConfigurationSelector config)
        {
            var cfg = GetConfiguration(config);

            if (cfg == null)
            {
                return(false);
            }
            var cmd = CreateExecutionCommand(config, cfg);

            return(context.ExecutionHandler.CanExecute(cmd));
        }
Esempio n. 25
0
		public static void ExecuteProject(DubProject prj,IProgressMonitor monitor, ExecutionContext context, ConfigurationSelector configuration, string dubVerb = "run")
		{
			bool isDebug = context.ExecutionHandler.GetType ().Name.StartsWith ("Debug");

			var conf = prj.GetConfiguration(configuration) as DubProjectConfiguration;
			IConsole console;
			if (conf.ExternalConsole)
				console = context.ExternalConsoleFactory.CreateConsole(!conf.PauseConsoleOutput);
			else
				console = context.ConsoleFactory.CreateConsole(true);
			
			var operationMonitor = new AggregatedOperationMonitor(monitor);

			var sr = new StringBuilder();
			if (!isDebug) {
				sr.Append (dubVerb);
				BuildCommonArgAppendix (sr, prj, configuration);
			}

			try
			{
				var cmd = isDebug ? prj.CreateExecutionCommand(configuration) : new NativeExecutionCommand(DubSettings.Instance.DubCommand, sr.ToString(), prj.BaseDirectory.ToString());
				if (!context.ExecutionHandler.CanExecute(cmd))
				{
					monitor.ReportError("Cannot execute \"" + cmd.Command + " " + cmd.Arguments + "\". The selected execution mode is not supported for Dub projects.", null);
					return;
				}

				var op = context.ExecutionHandler.Execute(cmd, console);

				operationMonitor.AddOperation(op);
				op.WaitForCompleted();

				if(op.ExitCode != 0)
					monitor.ReportError(cmd.Command+" exited with code: "+op.ExitCode.ToString(), null);
				else
					monitor.Log.WriteLine(cmd.Command+" exited with code: {0}", op.ExitCode);
			}
			catch (Exception ex)
			{
				monitor.ReportError("Cannot execute \"" + sr.ToString() + "\"", ex);
			}
			finally
			{
				operationMonitor.Dispose();
				console.Dispose();
			}
		}
		protected override void Execute (IProgressMonitor monitor, SolutionEntityItem entry, ExecutionContext context, ConfigurationSelector configuration)
		{
			SolutionItemConfiguration conf = entry.GetConfiguration (configuration) as SolutionItemConfiguration;
			if (conf != null) {
				ExecutionContext localContext = new ExecutionContext (Runtime.ProcessService.DefaultExecutionHandler, context.ConsoleFactory);
				conf.CustomCommands.ExecuteCommand (monitor, entry, CustomCommandType.BeforeExecute, localContext, configuration);
				if (monitor.IsCancelRequested)
					return;
			}
			
			base.Execute (monitor, entry, context, configuration);
			
			if (conf != null && !monitor.IsCancelRequested) {
				ExecutionContext localContext = new ExecutionContext (Runtime.ProcessService.DefaultExecutionHandler, context.ConsoleFactory);
				conf.CustomCommands.ExecuteCommand (monitor, entry, CustomCommandType.AfterExecute, localContext, configuration);
			}
		}
		public static IAsyncOperation Debug (this ProjectOperations opers, IBuildTarget entry)
		{
			if (opers.CurrentRunOperation != null && !opers.CurrentRunOperation.IsCompleted)
				return opers.CurrentRunOperation;

			string oldLayout = IdeApp.Workbench.CurrentLayout;
			IdeApp.Workbench.CurrentLayout = "Debug";

			ExecutionContext context = new ExecutionContext (DebuggingService.GetExecutionHandler (), IdeApp.Workbench.ProgressMonitors, IdeApp.Workspace.ActiveExecutionTarget);

			IAsyncOperation op = opers.Execute (entry, context);
			op.Completed += delegate {
				Gtk.Application.Invoke (delegate {
					IdeApp.Workbench.CurrentLayout = oldLayout;
				});
			};
			return op;
		}
Esempio n. 28
0
        public static bool CanRun(HaxeProject project, HaxeProjectConfiguration configuration, ExecutionContext context)
        {
            // need to optimize so this caches the result

            ExecutionCommand cmd = CreateExecutionCommand (project, configuration);
            if (cmd == null)
            {
                return false;
            }
            else if (cmd is NativeExecutionCommand)
            {
                return context.ExecutionHandler.CanExecute (cmd);
            }
            else
            {
                return true;
            }
        }
Esempio n. 29
0
        /// <summary>
        /// Executes the project
        /// </summary>
        /// <param name="monitor">Progress monitor.</param>
        /// <param name="context">Execution context.</param>
        /// <param name="configuration">Configuration to execute.</param>
        /// <returns>The execute.</returns>
        protected async override Task DoExecute(ProgressMonitor monitor, MonoDevelop.Projects.ExecutionContext context, ConfigurationSelector configuration)
        {
            var              conf  = (CProjectConfiguration)GetConfiguration(configuration);
            bool             pause = conf.PauseConsoleOutput;
            OperationConsole console;

            if (conf.CompileTarget != CompileTarget.Exe)
            {
                MessageService.ShowMessage("Compile target is not an executable!");
                return;
            }

            monitor.Log.WriteLine("Running project...");

            if (conf.ExternalConsole)
            {
                console = context.ExternalConsoleFactory.CreateConsole(!pause, monitor.CancellationToken);
            }
            else
            {
                console = context.ConsoleFactory.CreateConsole(monitor.CancellationToken);
            }

            try {
                ExecutionCommand cmd = CreateExecutionCommand(conf);
                if (!context.ExecutionHandler.CanExecute(cmd))
                {
                    monitor.ReportError("Cannot execute \"" + conf.Output + "\". The selected execution mode is not supported for C projects.", null);
                    return;
                }

                ProcessAsyncOperation op = context.ExecutionHandler.Execute(cmd, console);
                using (var t = monitor.CancellationToken.Register(op.Cancel))
                    await op.Task;

                monitor.Log.WriteLine("The operation exited with code: {0}", op.ExitCode);
            } catch (Exception ex) {
                LoggingService.LogError(string.Format("Cannot execute \"{0}\"", conf.Output), ex);
                monitor.ReportError("Cannot execute \"" + conf.Output + "\"", ex);
            } finally {
                console.Dispose();
            }
        }
        protected override bool OnGetCanExecute(MonoDevelop.Projects.ExecutionContext context, ConfigurationSelector configuration)
        {
            // We check for DefaultExecutionHandlerFactory because the tests can't run using any other execution mode

            var res = base.OnGetCanExecute(context, configuration);

            lock (canExecuteCheckLock) {
                if (checkingCanExecute)
                {
                    return(res);
                }
            }
            if (res)
            {
                return(true);
            }
            UnitTest test = FindRootTest();

            return((test != null) && test.CanRun(context.ExecutionHandler));
        }
Esempio n. 31
0
        internal static void ExecuteProject(DubProject prj,IProgressMonitor monitor, ExecutionContext context, ConfigurationSelector configuration)
        {
            var conf = prj.GetConfiguration(configuration) as DubProjectConfiguration;
            IConsole console;
            if (conf.ExternalConsole)
                console = context.ExternalConsoleFactory.CreateConsole(!conf.PauseConsoleOutput);
            else
                console = context.ConsoleFactory.CreateConsole(true);

            var operationMonitor = new AggregatedOperationMonitor(monitor);

            var sr = new StringBuilder("run");
            Instance.BuildCommonArgAppendix(sr, prj, configuration);

            try
            {
                var cmd = new NativeExecutionCommand(Instance.DubExecutable, sr.ToString(), prj.BaseDirectory.ToString());
                if (!context.ExecutionHandler.CanExecute(cmd))
                {
                    monitor.ReportError("Cannot execute \""  + "\". The selected execution mode is not supported for Dub projects.", null);
                    return;
                }

                var op = context.ExecutionHandler.Execute(cmd, console);

                operationMonitor.AddOperation(op);
                op.WaitForCompleted();

                monitor.Log.WriteLine(Instance.DubExecutable+" exited with code: {0}", op.ExitCode);

            }
            catch (Exception ex)
            {
                monitor.ReportError("Cannot execute \"" + sr.ToString() + "\"", ex);
            }
            finally
            {
                operationMonitor.Dispose();
                console.Dispose();
            }
        }
		/// <summary>
		/// Launch project
		/// </summary>
		public override void Execute (MonoDevelop.Core.IProgressMonitor monitor, IBuildTarget item, ExecutionContext context, ConfigurationSelector configuration)
		{
			if (CanExecuteProject (item as Project, context)) {
				DispatchService.GuiDispatch (delegate {

					foreach(var file in ((Project)item).Files)
					{
						string filePath = file.FilePath.ToString();
						if(filePath.Contains(@"Game\Scripts"))
						{
							WorkingDir = Path.Combine(filePath.Remove(filePath.LastIndexOf(@"Game\Scripts")), "Bin32");
							break;
						}
					}
					IdeApp.Workbench.CurrentLayout = "Debug";
					IdeApp.ProjectOperations.CurrentRunOperation = context.ExecutionHandler.Execute (new CryEngineExecutionCommand (item.BaseDirectory.FullPath), context.ConsoleFactory.CreateConsole (true));
				});
			} else {
				base.Execute (monitor, item, context, configuration);
			}
		}
		public override void Execute (MonoDevelop.Core.IProgressMonitor monitor, IBuildTarget item, ExecutionContext context, ConfigurationSelector configuration)
		{
			if (base.CanExecute (item, context, configuration)) {
				// It is executable by default
				base.Execute(monitor, item, context, configuration);
				return;
			} else if (item is IWorkspaceObject) {
				UnitTest test = NUnitService.Instance.FindRootTest ((IWorkspaceObject)item);
				if (test != null) {
					IAsyncOperation oper = null;
					DispatchService.GuiSyncDispatch (delegate {
						oper = NUnitService.Instance.RunTest (test, context.ExecutionHandler, false);
					});
//					if (oper != null) {
//						monitor.CancelRequested += delegate {
//							oper.Cancel ();
//						};
//						oper.WaitForCompleted ();
//					}
				}
			}
		}
Esempio n. 34
0
 /*protected virtual*/ Task OnPrepareExecution(ProgressMonitor monitor, ExecutionContext context, ConfigurationSelector configuration)
 {
     return(Task.FromResult(0));
 }
 internal protected virtual bool OnGetCanExecute(ExecutionContext context, ConfigurationSelector configuration)
 {
     return(next.OnGetCanExecute(context, configuration));
 }
Esempio n. 36
0
		public IAsyncOperation Execute (IBuildTarget entry, ExecutionContext context)
		{
			if (currentRunOperation != null && !currentRunOperation.IsCompleted) return currentRunOperation;

			NullProgressMonitor monitor = new NullProgressMonitor ();

			DispatchService.ThreadDispatch (delegate {
				ExecuteSolutionItemAsync (monitor, entry, context);
			});
			currentRunOperation = monitor.AsyncOperation;
			currentRunOperationOwner = entry;
			currentRunOperation.Completed += delegate {
			 	DispatchService.GuiDispatch (() => {
					var error = monitor.Errors.FirstOrDefault ();
					if (error != null)
						IdeApp.Workbench.StatusBar.ShowError (error.Message);
					currentRunOperationOwner = null;
				});
			};
			return currentRunOperation;
		}
Esempio n. 37
0
		public bool CanExecuteFile (string file, IExecutionHandler handler)
		{
			ExecutionContext context = new ExecutionContext (handler, IdeApp.Workbench.ProgressMonitors);
			return CanExecuteFile (file, context);
		}
Esempio n. 38
0
		public bool CanExecute (IBuildTarget entry)
		{
			ExecutionContext context = new ExecutionContext (Runtime.ProcessService.DefaultExecutionHandler, IdeApp.Workbench.ProgressMonitors);
			return CanExecute (entry, context);
		}
Esempio n. 39
0
		public bool CanExecute (IBuildTarget entry, ExecutionContext context)
		{
			return entry.CanExecute (context, IdeApp.Workspace.ActiveConfiguration);
		}
Esempio n. 40
0
 public Task PrepareExecution(ProgressMonitor monitor, ExecutionContext context, ConfigurationSelector configuration)
 {
     return(SolutionExtension.PrepareExecution(monitor, context, configuration));
 }
Esempio n. 41
0
		public bool CanExecuteFile (string file, ExecutionContext context)
		{
			Project tempProject = MonoDevelop.Projects.Services.ProjectService.CreateSingleFileProject (file);
			if (tempProject != null) {
				bool res = CanExecute (tempProject, context);
				tempProject.Dispose ();
				return res;
			}
			else
				return false;
		}
Esempio n. 42
0
 internal static Task RunTest(UnitTest test, MonoDevelop.Projects.ExecutionContext context, bool buildOwnerObject, bool checkCurrentRunOperation, CancellationTokenSource cs)
 {
     return(RunTests(new UnitTest [] { test }, context, buildOwnerObject, checkCurrentRunOperation, cs));
 }
Esempio n. 43
0
        internal static async Task RunTests(IEnumerable <UnitTest> tests, MonoDevelop.Projects.ExecutionContext context, bool buildOwnerObject, bool checkCurrentRunOperation, CancellationTokenSource cs)
        {
            if (buildOwnerObject)
            {
                var build_targets = new HashSet <IBuildTarget> ();
                foreach (var t in tests)
                {
                    IBuildTarget bt = t.OwnerObject as IBuildTarget;
                    if (bt != null)
                    {
                        build_targets.Add(bt);
                    }
                }
                if (build_targets.Count > 0)
                {
                    if (!IdeApp.ProjectOperations.CurrentRunOperation.IsCompleted)
                    {
                        MonoDevelop.Ide.Commands.StopHandler.StopBuildOperations();
                        await IdeApp.ProjectOperations.CurrentRunOperation.Task;
                    }

                    foreach (var bt in build_targets)
                    {
                        var res = await IdeApp.ProjectOperations.Build(bt, cs.Token).Task;

                        if (res.HasErrors)
                        {
                            return;
                        }
                    }

                    var test_names = new HashSet <string> (tests.Select((v) => v.FullName));

                    await RefreshTests(cs.Token);

                    tests = test_names.Select((fullName) => SearchTest(fullName)).Where((t) => t != null).ToList();

                    if (tests.Any())
                    {
                        await RunTests(tests, context, false, checkCurrentRunOperation, cs);
                    }
                    return;
                }
            }

            if (checkCurrentRunOperation && !IdeApp.ProjectOperations.ConfirmExecutionOperation())
            {
                return;
            }

            Pad resultsPad = GetTestResultsPad();

            var         test    = tests.Count() == 1 ? tests.First() : new UnitTestSelection(tests, tests.First().OwnerObject);
            TestSession session = new TestSession(test, context, (TestResultsPad)resultsPad.Content, cs);

            OnTestSessionStarting(new TestSessionEventArgs {
                Session = session, Test = test
            });

            if (checkCurrentRunOperation)
            {
                IdeApp.ProjectOperations.AddRunOperation(session);
            }

            try {
                await session.Start();
            } finally {
                resultsPad.Sticky = false;
            }
        }
        protected override async Task OnExecute(MonoDevelop.Core.ProgressMonitor monitor, MonoDevelop.Projects.ExecutionContext context, ConfigurationSelector configuration)
        {
            bool defaultCanExecute;

            lock (canExecuteCheckLock) {
                try {
                    checkingCanExecute = true;
                    defaultCanExecute  = Project.CanExecute(context, configuration);
                } finally {
                    checkingCanExecute = false;
                }
            }
            if (defaultCanExecute)
            {
                // It is executable by default
                await base.OnExecute(monitor, context, configuration);

                return;
            }
            UnitTest test = FindRootTest();

            if (test != null)
            {
                var cs = new CancellationTokenSource();
                using (monitor.CancellationToken.Register(cs.Cancel))
                    await NUnitService.Instance.RunTest(test, context.ExecutionHandler, false, false, cs);
            }
        }
Esempio n. 45
0
 public bool CanExecute(ExecutionContext context, string configuration)
 {
     return(CanExecute(context, (SolutionConfigurationSelector)configuration));
 }
Esempio n. 46
0
 public bool CanExecute(ExecutionContext context, ConfigurationSelector configuration)
 {
     return(SolutionExtension.CanExecute(context, configuration));
 }
 protected override async Task OnExecute(MonoDevelop.Core.ProgressMonitor monitor, MonoDevelop.Projects.ExecutionContext context, ConfigurationSelector configuration, SolutionItemRunConfiguration runConfiguration)
 {
     if (runConfiguration == unitTestingRunConfigurationInstance)
     {
         // The user selected to run the tests
         UnitTest test = FindRootTest();
         if (test != null)
         {
             var cs = new CancellationTokenSource();
             using (monitor.CancellationToken.Register(cs.Cancel))
                 await UnitTestService.RunTest(test, context, false, false, cs);
         }
     }
     else
     {
         await base.OnExecute(monitor, context, configuration, runConfiguration);
     }
 }
Esempio n. 48
0
 public Task Execute(ProgressMonitor monitor, ExecutionContext context, string configuration)
 {
     return(Execute(monitor, context, (SolutionConfigurationSelector)configuration));
 }
 internal protected virtual Task OnExecute(ProgressMonitor monitor, ExecutionContext context, ConfigurationSelector configuration)
 {
     return(next.OnExecute(monitor, context, configuration));
 }
        public static AsyncOperation RunTest(UnitTest test, MonoDevelop.Projects.ExecutionContext context, bool buildOwnerObject)
        {
            var cs = new CancellationTokenSource();

            return(new AsyncOperation(RunTest(test, context, buildOwnerObject, true, cs), cs));
        }
Esempio n. 51
0
		public IAsyncOperation ExecuteFile (string file, ExecutionContext context)
		{
			Project tempProject = MonoDevelop.Projects.Services.ProjectService.CreateSingleFileProject (file);
			if (tempProject != null) {
				IAsyncOperation aop = Execute (tempProject, context);
				aop.Completed += delegate { tempProject.Dispose (); };
				return aop;
			} else {
				MessageService.ShowError(GettextCatalog.GetString ("No runnable executable found."));
				return NullAsyncOperation.Failure;
			}
		}
        internal static async Task RunTest(UnitTest test, MonoDevelop.Projects.ExecutionContext context, bool buildOwnerObject, bool checkCurrentRunOperation, CancellationTokenSource cs)
        {
            string testName = test.FullName;

            if (buildOwnerObject)
            {
                IBuildTarget bt = test.OwnerObject as IBuildTarget;
                if (bt != null)
                {
                    if (!IdeApp.ProjectOperations.CurrentRunOperation.IsCompleted)
                    {
                        MonoDevelop.Ide.Commands.StopHandler.StopBuildOperations();
                        await IdeApp.ProjectOperations.CurrentRunOperation.Task;
                    }

                    var res = await IdeApp.ProjectOperations.Build(bt, cs.Token).Task;

                    if (res.HasErrors)
                    {
                        return;
                    }

                    await RefreshTests(cs.Token);

                    test = SearchTest(testName);
                    if (test != null)
                    {
                        await RunTest(test, context, false, checkCurrentRunOperation, cs);
                    }
                    return;
                }
            }

            if (checkCurrentRunOperation && !IdeApp.ProjectOperations.ConfirmExecutionOperation())
            {
                return;
            }

            Pad resultsPad = IdeApp.Workbench.GetPad <TestResultsPad>();

            if (resultsPad == null)
            {
                resultsPad = IdeApp.Workbench.ShowPad(new TestResultsPad(), "MonoDevelop.UnitTesting.TestResultsPad", GettextCatalog.GetString("Test results"), "Bottom", "md-solution");
            }

            // Make the pad sticky while the tests are runnig, so the results pad is always visible (even if minimized)
            // That's required since when running in debug mode, the layout is automatically switched to debug.

            resultsPad.Sticky = true;
            resultsPad.BringToFront();

            TestSession session = new TestSession(test, context, (TestResultsPad)resultsPad.Content, cs);

            OnTestSessionStarting(new TestSessionEventArgs {
                Session = session, Test = test
            });

            if (checkCurrentRunOperation)
            {
                IdeApp.ProjectOperations.CurrentRunOperation = session;
            }

            try {
                await session.Start();
            } finally {
                resultsPad.Sticky = false;
            }
        }
Esempio n. 53
0
		public bool CanExecute (IBuildTarget entry, IExecutionHandler handler)
		{
			ExecutionContext context = new ExecutionContext (handler, IdeApp.Workbench.ProgressMonitors);
			return entry.CanExecute (context, IdeApp.Workspace.ActiveConfiguration);
		}
Esempio n. 54
0
 internal protected override bool CanExecute(ExecutionContext context, ConfigurationSelector configuration)
 {
     return(Solution.OnGetCanExecute(context, configuration));
 }
Esempio n. 55
0
		public IAsyncOperation Execute (IBuildTarget entry, IExecutionHandler handler)
		{
			ExecutionContext context = new ExecutionContext (handler, IdeApp.Workbench.ProgressMonitors);
			return Execute (entry, context);
		}
Esempio n. 56
0
 internal protected override Task PrepareExecution(ProgressMonitor monitor, ExecutionContext context, ConfigurationSelector configuration)
 {
     return(Solution.OnPrepareExecution(monitor, context, configuration));
 }
Esempio n. 57
0
		void ExecuteSolutionItemAsync (IProgressMonitor monitor, IBuildTarget entry, ExecutionContext context)
		{
			try {
				OnBeforeStartProject ();
				entry.Execute (monitor, context, IdeApp.Workspace.ActiveConfiguration);
			} catch (Exception ex) {
				monitor.ReportError (GettextCatalog.GetString ("Execution failed."), ex);
				LoggingService.LogError ("Execution failed", ex);
			} finally {
				monitor.Dispose ();
			}
		}
        protected override void Execute(IProgressMonitor monitor, SolutionEntityItem entry, ExecutionContext context, ConfigurationSelector configuration)
        {
            SolutionItemConfiguration conf = entry.GetConfiguration(configuration) as SolutionItemConfiguration;

            if (conf != null)
            {
                ExecutionContext localContext = new ExecutionContext(Runtime.ProcessService.DefaultExecutionHandler, context.ConsoleFactory);

                if (conf.CustomCommands.CanExecute(entry, CustomCommandType.BeforeExecute, localContext, configuration))
                {
                    conf.CustomCommands.ExecuteCommand(monitor, entry, CustomCommandType.BeforeExecute, localContext, configuration);
                }

                if (monitor.IsCancelRequested)
                {
                    return;
                }
            }

            base.Execute(monitor, entry, context, configuration);

            if (conf != null && !monitor.IsCancelRequested)
            {
                ExecutionContext localContext = new ExecutionContext(Runtime.ProcessService.DefaultExecutionHandler, context.ConsoleFactory);

                if (conf.CustomCommands.CanExecute(entry, CustomCommandType.AfterExecute, localContext, configuration))
                {
                    conf.CustomCommands.ExecuteCommand(monitor, entry, CustomCommandType.AfterExecute, localContext, configuration);
                }
            }
        }
Esempio n. 59
0
		public static DebuggerFeatures GetSupportedFeatures (IBuildTarget target)
		{
			FeatureCheckerHandlerFactory fc = new FeatureCheckerHandlerFactory ();
			ExecutionContext ctx = new ExecutionContext (fc, null);
			target.CanExecute (ctx, IdeApp.Workspace.ActiveConfiguration);
			return fc.SupportedFeatures;
		}
 protected override void OnExecute(IProgressMonitor monitor, MonoDevelop.Projects.ExecutionContext context, ConfigurationSelector configuration)
 {
 }