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

            foreach (var task in _value)
            {
                bounce.Invoke(command, task);
            }
        }
Beispiel #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);
         }
     }
 }
Beispiel #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);
         }
     }
 }
Beispiel #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);
        }
Beispiel #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);
        }
Beispiel #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);
        }
Beispiel #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);
     }
 }
        private bool TryParseCommand(string commandString, ref IBounceCommand bounceCommand)
        {
            var command = BounceCommandParser.Parse(commandString);

            if (command != null) {
                bounceCommand = command;
                return true;
            } else {
                return false;
            }
        }
Beispiel #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);
        }
Beispiel #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);
        }
Beispiel #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);
        }
Beispiel #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;
 }
Beispiel #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()));
        }
Beispiel #21
0
        public void CleanAfterBuild(IBounceCommand command)
        {
            IBounceCommand cleanAfterBuildCommand = command.CleanAfterBuildCommand;

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