Ejemplo n.º 1
0
 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();
     }
 }
Ejemplo n.º 2
0
 public void BeginTask(IObsoleteTask task, IBounceCommand command)
 {
     if (logOptions.ReportTaskStart && task.IsLogged && command.IsLogged)
     {
         StdOut.WriteLine("{0} task: {1}", command.PresentTense, task);
     }
 }
Ejemplo n.º 3
0
 public void BeginTarget(IObsoleteTask task, string name, IBounceCommand command)
 {
     if (logOptions.ReportTargetStart)
     {
         StdOut.WriteLine("{0} target: {1}", command.PresentTense, name);
     }
 }
Ejemplo n.º 4
0
 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);
         }
     }
 }
Ejemplo n.º 5
0
 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();
     }
 }
Ejemplo n.º 6
0
 public void EnsureInvokedAtLeastOnce(IObsoleteTask task, IBounceCommand command)
 {
     if (!InvokedTasks.Contains(task))
     {
         Invoke(task, command);
         InvokedTasks.Add(task);
     }
 }
Ejemplo n.º 7
0
 public void CleanAfterBuild(IBounceCommand command)
 {
     IBounceCommand cleanAfterBuildCommand = command.CleanAfterBuildCommand;
     if (cleanAfterBuildCommand != null) {
         foreach (var taskToClean in CleanAfterBuildRegister.TasksToBeCleaned) {
             Clean(taskToClean, cleanAfterBuildCommand);
         }
     }
 }
Ejemplo n.º 8
0
        public override void InvokeTask(IBounceCommand command, IBounce bounce)
        {
            _value = GetTasks(bounce);

            foreach (var task in _value)
            {
                bounce.Invoke(command, task);
            }
        }
Ejemplo n.º 9
0
 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);
         }
     }
 }
Ejemplo n.º 10
0
 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);
         }
     }
 }
Ejemplo n.º 11
0
        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);
        }
Ejemplo n.º 12
0
        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);
        }
Ejemplo n.º 13
0
        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);
        }
Ejemplo n.º 14
0
 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);
     }
 }
Ejemplo n.º 15
0
        private bool TryParseCommand(string commandString, ref IBounceCommand bounceCommand)
        {
            var command = BounceCommandParser.Parse(commandString);

            if (command != null) {
                bounceCommand = command;
                return true;
            } else {
                return false;
            }
        }
Ejemplo n.º 16
0
        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);
        }
Ejemplo n.º 17
0
        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);
        }
Ejemplo n.º 18
0
        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);
        }
Ejemplo n.º 19
0
 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;
 }
Ejemplo n.º 20
0
        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()));
        }
Ejemplo n.º 21
0
        public void CleanAfterBuild(IBounceCommand command)
        {
            IBounceCommand cleanAfterBuildCommand = command.CleanAfterBuildCommand;

            if (cleanAfterBuildCommand != null)
            {
                foreach (var taskToClean in CleanAfterBuildRegister.TasksToBeCleaned)
                {
                    Clean(taskToClean, cleanAfterBuildCommand);
                }
            }
        }
Ejemplo n.º 22
0
        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));
            }
        }
Ejemplo n.º 23
0
        private bool TryParseCommand(string commandString, ref IBounceCommand bounceCommand)
        {
            var command = BounceCommandParser.Parse(commandString);

            if (command != null)
            {
                bounceCommand = command;
                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 24
0
 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);
         }
     }
 }
Ejemplo n.º 25
0
 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);
         }
     }
 }
Ejemplo n.º 26
0
 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);
         }
     }
 }
Ejemplo n.º 27
0
 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);
         }
     }
 }
Ejemplo n.º 28
0
        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));
        }
Ejemplo n.º 29
0
        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));
        }
Ejemplo n.º 30
0
        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),
            });
        }
Ejemplo n.º 31
0
 public void EndTask(IObsoleteTask task, IBounceCommand command, TaskResult result)
 {
 }
Ejemplo n.º 32
0
 public void Invoke(IBounceCommand command, IObsoleteTask task)
 {
     command.InvokeCommand(() => Build(task, command), () => Clean(task, command), () => Describe(task, command));
 }
Ejemplo n.º 33
0
 private void BuildIfNotAlreadyBuilt(TaskDependency dep, IBounceCommand command)
 {
     OnceOnlyBuilder.EnsureInvokedAtLeastOnce(dep.Task, command);
 }
Ejemplo n.º 34
0
 public void BeginTask(ITask task, IBounceCommand command)
 {
     if (logOptions.ReportTaskStart && task.IsLogged && command.IsLogged) {
         StdOut.WriteLine("{0} task: {1}", command.PresentTense, task);
     }
 }
Ejemplo n.º 35
0
 public void BeginTarget(IObsoleteTask task, string name, IBounceCommand command) {
     output.WriteLine(TeamCityFormatter.FormatTeamCityMessage("progressStart", name));
 }
Ejemplo n.º 36
0
 public void EndTarget(IObsoleteTask task, string name, IBounceCommand command, TaskResult result)
 {
 }
Ejemplo n.º 37
0
 public override void Invoke(IBounceCommand command, IBounce bounce)
 {
     base.Invoke(command, bounce);
     Invoked = true;
 }
Ejemplo n.º 38
0
 public override void Invoke(IBounceCommand command, IBounce bounce)
 {
     base.Invoke(command, bounce);
     Invoked = true;
 }
Ejemplo n.º 39
0
 public void Invoke(IBounceCommand command, IObsoleteTask task)
 {
     command.InvokeCommand(() => Build(task, command), () => Clean(task, command), () => Describe(task, command));
 }
Ejemplo n.º 40
0
 public BounceCommandBuild(IBounceCommand cleanAfterBuildCommand, string commandLineCommand)
 {
     CleanAfterBuildCommand = cleanAfterBuildCommand;
     CommandLineCommand     = commandLineCommand;
 }
Ejemplo n.º 41
0
 private void Clean(IObsoleteTask task, IBounceCommand command)
 {
     Walker.Walk(new TaskDependency(task), dep => CleanIfNotAlreadyCleaned(dep, command), null);
 }
Ejemplo n.º 42
0
 private void DescribeIfNotDescribed(TaskDependency dep, IBounceCommand command)
 {
     OnceOnlyDescriber.EnsureInvokedAtLeastOnce(dep.Task, command);
 }
Ejemplo n.º 43
0
 private void Build(IObsoleteTask task, IBounceCommand command)
 {
     Walker.Walk(new TaskDependency(task), null, dep => BuildIfNotAlreadyBuilt(dep, command));
     RegisterCleanupAfterBuild(task);
 }
Ejemplo n.º 44
0
 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));
        }
Ejemplo n.º 46
0
 public void BeginTask(IObsoleteTask task, IBounceCommand command) {
     output.WriteLine(TeamCityFormatter.FormatTeamCityMessage("progressStart", task.SmallDescription));
 }
Ejemplo n.º 47
0
 private void Describe(IObsoleteTask task, IBounceCommand command)
 {
     Walker.Walk(new TaskDependency(task), null, dep => DescribeIfNotDescribed(dep, command));
 }
Ejemplo n.º 48
0
 private void CleanIfNotAlreadyCleaned(TaskDependency dep, IBounceCommand command)
 {
     OnceOnlyCleaner.EnsureInvokedAtLeastOnce(dep.Task, command);
 }
Ejemplo n.º 49
0
 public void BeginTask(IObsoleteTask task, IBounceCommand command)
 {
 }
Ejemplo n.º 50
0
 private void DescribeIfNotDescribed(TaskDependency dep, IBounceCommand command)
 {
     OnceOnlyDescriber.EnsureInvokedAtLeastOnce(dep.Task, command);
 }
Ejemplo n.º 51
0
 public virtual void Invoke(IBounceCommand command, IObsoleteTask task)
 {
     task.Invoke(command, this);
 }
Ejemplo n.º 52
0
 private void Build(IObsoleteTask task, IBounceCommand command)
 {
     Walker.Walk(new TaskDependency(task), null, dep => BuildIfNotAlreadyBuilt(dep, command));
     RegisterCleanupAfterBuild(task);
 }
Ejemplo n.º 53
0
 public void EndTask(IObsoleteTask task, IBounceCommand command, TaskResult result) {
     output.WriteLine(TeamCityFormatter.FormatTeamCityMessage("progressFinish", task.SmallDescription));
 }
Ejemplo n.º 54
0
 public void BeginTarget(ITask task, string name, IBounceCommand command)
 {
     if (logOptions.ReportTargetStart) {
         StdOut.WriteLine("{0} target: {1}", command.PresentTense, name);
     }
 }
Ejemplo n.º 55
0
 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));
 }
Ejemplo n.º 56
0
 private void BuildIfNotAlreadyBuilt(TaskDependency dep, IBounceCommand command)
 {
     OnceOnlyBuilder.EnsureInvokedAtLeastOnce(dep.Task, command);
 }
Ejemplo n.º 57
0
 private void Clean(IObsoleteTask task, IBounceCommand command)
 {
     Walker.Walk(new TaskDependency(task), dep => CleanIfNotAlreadyCleaned(dep, command), null);
 }
Ejemplo n.º 58
0
 private void CleanIfNotAlreadyCleaned(TaskDependency dep, IBounceCommand command)
 {
     OnceOnlyCleaner.EnsureInvokedAtLeastOnce(dep.Task, command);
 }
Ejemplo n.º 59
0
 private void Describe(IObsoleteTask task, IBounceCommand command)
 {
     Walker.Walk(new TaskDependency(task), null, dep => DescribeIfNotDescribed(dep, command));
 }
Ejemplo n.º 60
0
 public void EnsureInvokedAtLeastOnce(IObsoleteTask task, IBounceCommand command)
 {
     if (!InvokedTasks.Contains(task)) {
         Invoke(task, command);
         InvokedTasks.Add(task);
     }
 }