private static void InvokeTask(ITargetBuilderBounce bounce, IBounceCommand command, string name, IObsoleteTask task) { using (var targetScope = bounce.TaskScope(task, command, name)) { bounce.Invoke(command, task); targetScope.TaskSucceeded(); } }
public void BeginTask(IObsoleteTask task, IBounceCommand command) { if (logOptions.ReportTaskStart && task.IsLogged && command.IsLogged) { StdOut.WriteLine("{0} task: {1}", command.PresentTense, task); } }
public void BeginTarget(IObsoleteTask task, string name, IBounceCommand command) { if (logOptions.ReportTargetStart) { StdOut.WriteLine("{0} target: {1}", command.PresentTense, name); } }
public void BuildTargets(ITargetBuilderBounce bounce, IEnumerable<Target> targets, IBounceCommand command) { foreach (var target in targets) { if (target.Task != null) { InvokeTask(bounce, command, target.Name, target.Task); } } }
private static void InvokeTask(ITargetBuilderBounce bounce, IBounceCommand command, string name, ITask task) { using (var targetScope = bounce.TaskScope(task, command, name)) { bounce.Invoke(command, task); targetScope.TaskSucceeded(); } }
public void EnsureInvokedAtLeastOnce(IObsoleteTask task, IBounceCommand command) { if (!InvokedTasks.Contains(task)) { Invoke(task, command); InvokedTasks.Add(task); } }
public void CleanAfterBuild(IBounceCommand command) { IBounceCommand cleanAfterBuildCommand = command.CleanAfterBuildCommand; if (cleanAfterBuildCommand != null) { foreach (var taskToClean in CleanAfterBuildRegister.TasksToBeCleaned) { Clean(taskToClean, cleanAfterBuildCommand); } } }
public override void InvokeTask(IBounceCommand command, IBounce bounce) { _value = GetTasks(bounce); foreach (var task in _value) { bounce.Invoke(command, task); } }
public void EndTarget(IObsoleteTask task, string name, IBounceCommand command, TaskResult result) { if (logOptions.ReportTargetEnd) { if (result == TaskResult.Success) { StdOut.WriteLine("{0} target: {1}", command.PastTense, name); } else { StdErr.WriteLine("failed to {0} target: {1}", command.InfinitiveTense, name); } } }
public void EndTask(IObsoleteTask task, IBounceCommand command, TaskResult result) { if (logOptions.ReportTaskEnd && task.IsLogged && command.IsLogged) { if (result == TaskResult.Success) { StdOut.WriteLine("{0} task: {1}", command.PastTense, task); } else { StdErr.WriteLine("failed to {0} task: {1}", command.InfinitiveTense, task); } } }
private void AssertBuildCommandProperties(IBounceCommand command) { Assert.That(command.PastTense, Is.EqualTo("built")); Assert.That(command.PresentTense, Is.EqualTo("building")); Assert.That(command.InfinitiveTense, Is.EqualTo("build")); bool built = false; command.InvokeCommand(() => built = true, () => Assert.Fail("didn't expect this to be invoked"), () => Assert.Fail("didn't expect this to be invoked")); Assert.That(built); }
private void AssertDescribeCommandProperties(IBounceCommand command) { Assert.That(command.CommandLineCommand, Is.EqualTo("describe")); Assert.That(command.PastTense, Is.EqualTo("described")); Assert.That(command.PresentTense, Is.EqualTo("describing")); Assert.That(command.InfinitiveTense, Is.EqualTo("describe")); bool described = false; command.InvokeCommand(() => Assert.Fail("didn't expect this to be invoked"), () => Assert.Fail("didn't expect this to be invoked"), () => described = true); Assert.That(described); }
private void AssertCleanCommandProperties(IBounceCommand command) { Assert.That(command.CommandLineCommand, Is.EqualTo("clean")); Assert.That(command.PastTense, Is.EqualTo("cleaned")); Assert.That(command.PresentTense, Is.EqualTo("cleaning")); Assert.That(command.InfinitiveTense, Is.EqualTo("clean")); bool cleaned = false; command.InvokeCommand(() => Assert.Fail("didn't expect this to be invoked"), () => cleaned = true, () => Assert.Fail("didn't expect this to be invoked")); Assert.That(cleaned); }
public override void InvokeTask(IBounceCommand command, IBounce bounce) { if (IsDebug) { bounce.Log.Debug("{0}: {1}", Message.Value, Value.Value); } else { bounce.Log.Info("{0}: {1}", Message.Value, Value.Value); } }
private bool TryParseCommand(string commandString, ref IBounceCommand bounceCommand) { var command = BounceCommandParser.Parse(commandString); if (command != null) { bounceCommand = command; return true; } else { return false; } }
private void EndTaskLog(IObsoleteTask task, IBounceCommand command, TaskResult result, string targetName, ILog outerLogger) { if (targetName != null) { Log.TaskLog.EndTarget(task, targetName, command, result); } else { Log.TaskLog.EndTask(task, command, result); } Log = outerLogger; }
private string GetBounceArguments(IBounce bounce, IBounceCommand command) { var args = new List <string>(); args.Add(LogOptionCommandLineTranslator.GenerateCommandLine(bounce)); args.Add(command.CommandLineCommand); args.AddRange(Targets); args.Add(CommandLineTasksParametersGenerator.GenerateCommandLineParametersForTasks(bounce.ParametersGiven, Parameters)); return(String.Join(" ", args.ToArray())); }
public override void Invoke(IBounceCommand command, IBounce bounce) { IObsoleteTask action; if (Cases.TryGetValue(Condition.Value, out action)) { bounce.Invoke(command, action); } else { throw new ConfigurationException(String.Format("no such case for `{0}'", Condition.Value)); } }
private bool TryParseCommand(string commandString, ref IBounceCommand bounceCommand) { var command = BounceCommandParser.Parse(commandString); if (command != null) { bounceCommand = command; return(true); } else { return(false); } }
private void InvokeAndLog(IObsoleteTask task, IBounceCommand command) { using (var taskScope = Bounce.TaskScope(task, command, null)) { try { task.Describe(Bounce.DescriptionOutput); task.Invoke(command, Bounce); taskScope.TaskSucceeded(); } catch (BounceException) { throw; } catch (Exception e) { throw new TaskException(task, e); } } }
private ITaskScope CreateTaskScope(IObsoleteTask task, IBounceCommand command, string targetName) { ILog previousLogger = Log; Log = LogFactory.CreateLogForTask(task, LogOptions.StdOut, LogOptions.StdErr, LogOptions); if (targetName != null) { Log.TaskLog.BeginTarget(task, targetName, command); } else { Log.TaskLog.BeginTask(task, command); } return(new TaskScope( outerLogger => EndTaskLog(task, command, TaskResult.Success, targetName, outerLogger), outerLogger => EndTaskLog(task, command, TaskResult.Failure, targetName, outerLogger), previousLogger)); }
private void AssertCommandAndTargetsParsed(IBounceCommand bounceCommand, string[] buildArguments) { var parser = new CommandAndTargetParser(BounceCommandParser); var targets = new Dictionary <string, IObsoleteTask>(); var target1 = new Mock <IObsoleteTask>().Object; targets.Add("Target1", target1); var target2 = new Mock <IObsoleteTask>().Object; targets.Add("Target2", target2); var commandAndTargetNames = parser.ParseCommandAndTargetNames(buildArguments, targets); Assert.That(commandAndTargetNames.Command, Is.EqualTo(bounceCommand)); Assert.That(commandAndTargetNames.Targets.ElementAt(0).Name, Is.EqualTo("Target1")); Assert.That(commandAndTargetNames.Targets.ElementAt(0).Task, Is.SameAs(target1)); Assert.That(commandAndTargetNames.Targets.ElementAt(1).Name, Is.EqualTo("Target2")); Assert.That(commandAndTargetNames.Targets.ElementAt(1).Task, Is.SameAs(target2)); }
public CommandAndTargets ParseCommandAndTargetNames(string[] buildArguments, IDictionary <string, IObsoleteTask> allTargets) { IBounceCommand command = BounceCommandParser.Build; int targetNamesIndex; if (buildArguments.Length > 0 && TryParseCommand(buildArguments[0], ref command)) { targetNamesIndex = 1; } else { targetNamesIndex = 0; } var targets = ParseTargets(buildArguments, targetNamesIndex); return(new CommandAndTargets { Command = command, Targets = TargetsToBuild(allTargets, targets), }); }
public void EndTask(IObsoleteTask task, IBounceCommand command, TaskResult result) { }
public void Invoke(IBounceCommand command, IObsoleteTask task) { command.InvokeCommand(() => Build(task, command), () => Clean(task, command), () => Describe(task, command)); }
private void BuildIfNotAlreadyBuilt(TaskDependency dep, IBounceCommand command) { OnceOnlyBuilder.EnsureInvokedAtLeastOnce(dep.Task, command); }
public void BeginTask(ITask task, IBounceCommand command) { if (logOptions.ReportTaskStart && task.IsLogged && command.IsLogged) { StdOut.WriteLine("{0} task: {1}", command.PresentTense, task); } }
public void BeginTarget(IObsoleteTask task, string name, IBounceCommand command) { output.WriteLine(TeamCityFormatter.FormatTeamCityMessage("progressStart", name)); }
public void EndTarget(IObsoleteTask task, string name, IBounceCommand command, TaskResult result) { }
public override void Invoke(IBounceCommand command, IBounce bounce) { base.Invoke(command, bounce); Invoked = true; }
public BounceCommandBuild(IBounceCommand cleanAfterBuildCommand, string commandLineCommand) { CleanAfterBuildCommand = cleanAfterBuildCommand; CommandLineCommand = commandLineCommand; }
private void Clean(IObsoleteTask task, IBounceCommand command) { Walker.Walk(new TaskDependency(task), dep => CleanIfNotAlreadyCleaned(dep, command), null); }
private void DescribeIfNotDescribed(TaskDependency dep, IBounceCommand command) { OnceOnlyDescriber.EnsureInvokedAtLeastOnce(dep.Task, command); }
private void Build(IObsoleteTask task, IBounceCommand command) { Walker.Walk(new TaskDependency(task), null, dep => BuildIfNotAlreadyBuilt(dep, command)); RegisterCleanupAfterBuild(task); }
public void BuildTargets(ITargetBuilderBounce bounce, IEnumerable <Target> targets, IBounceCommand command) { foreach (var target in targets) { if (target.Task != null) { InvokeTask(bounce, command, target.Name, target.Task); } } }
private void AssertCommandAndTargetsParsed(IBounceCommand bounceCommand, string[] buildArguments) { var parser = new CommandAndTargetParser(BounceCommandParser); var targets = new Dictionary<string, IObsoleteTask>(); var target1 = new Mock<IObsoleteTask>().Object; targets.Add("Target1", target1); var target2 = new Mock<IObsoleteTask>().Object; targets.Add("Target2", target2); var commandAndTargetNames = parser.ParseCommandAndTargetNames(buildArguments, targets); Assert.That(commandAndTargetNames.Command, Is.EqualTo(bounceCommand)); Assert.That(commandAndTargetNames.Targets.ElementAt(0).Name, Is.EqualTo("Target1")); Assert.That(commandAndTargetNames.Targets.ElementAt(0).Task, Is.SameAs(target1)); Assert.That(commandAndTargetNames.Targets.ElementAt(1).Name, Is.EqualTo("Target2")); Assert.That(commandAndTargetNames.Targets.ElementAt(1).Task, Is.SameAs(target2)); }
public void BeginTask(IObsoleteTask task, IBounceCommand command) { output.WriteLine(TeamCityFormatter.FormatTeamCityMessage("progressStart", task.SmallDescription)); }
private void Describe(IObsoleteTask task, IBounceCommand command) { Walker.Walk(new TaskDependency(task), null, dep => DescribeIfNotDescribed(dep, command)); }
private void CleanIfNotAlreadyCleaned(TaskDependency dep, IBounceCommand command) { OnceOnlyCleaner.EnsureInvokedAtLeastOnce(dep.Task, command); }
public void BeginTask(IObsoleteTask task, IBounceCommand command) { }
public virtual void Invoke(IBounceCommand command, IObsoleteTask task) { task.Invoke(command, this); }
public void EndTask(IObsoleteTask task, IBounceCommand command, TaskResult result) { output.WriteLine(TeamCityFormatter.FormatTeamCityMessage("progressFinish", task.SmallDescription)); }
public void BeginTarget(ITask task, string name, IBounceCommand command) { if (logOptions.ReportTargetStart) { StdOut.WriteLine("{0} target: {1}", command.PresentTense, name); } }
public void EndTarget(IObsoleteTask task, string name, IBounceCommand command, TaskResult result) { output.WriteLine(TeamCityFormatter.FormatTeamCityMessageWithFields("buildStatus", "status", result == TaskResult.Success? "SUCCESS": "FAILURE")); output.WriteLine(TeamCityFormatter.FormatTeamCityMessage("progressFinish", name)); }