Example #1
0
        /// <summary>
        /// Initialize the working directory with the hg init command
        /// </summary>
        /// <param name="result">The integration result.</param>
        /// <returns>The process result.</returns>
        /// <remarks>Uses the file system to ensure the working directory exists before calling hg init.</remarks>
        private ProcessResult HgInit(IIntegrationResult result)
        {
            string wd = BaseWorkingDirectory(result);

            _fileSystem.EnsureFolderExists(wd);

            ProcessArgumentBuilder buffer = new ProcessArgumentBuilder();

            buffer.AddArgument("init");
            buffer.AddArgument(wd);

            var bpi = GetBuildProgressInformation(result);

            bpi.SignalStartRunTask(string.Concat("hg ", buffer.ToString()));

            ProcessExecutor.ProcessOutput += ProcessExecutor_ProcessOutput;

            ProcessInfo pi = NewProcessInfo(buffer.ToString(), result);

            pi.WorkingDirectory = Path.GetDirectoryName(wd.Trim().TrimEnd(Path.DirectorySeparatorChar));
            ProcessResult processResult = Execute(pi);

            ProcessExecutor.ProcessOutput -= ProcessExecutor_ProcessOutput;

            return(processResult);
        }
Example #2
0
        public void LoadShouldThrowExceptionIfStateFileDoesNotExist()
        {
            Expect.Call(executionEnvironment.GetDefaultProgramDataFolder(ApplicationType.Server)).IgnoreArguments().Constraints(Rhino.Mocks.Constraints.Is.NotNull()).Return(applicationDataPath);
            Expect.Call(delegate { fileSystem.EnsureFolderExists(applicationDataPath); });
            Expect.Call(fileSystem.Load(null)).IgnoreArguments().Constraints(Rhino.Mocks.Constraints.Is.NotNull()).Throw(new FileNotFoundException());
            mocks.ReplayAll();

            state              = new FileStateManager(fileSystem, executionEnvironment);
            result             = IntegrationResultMother.CreateSuccessful();
            result.ProjectName = ProjectName;

            Assert.That(delegate { state.LoadState(ProjectName); },
                        Throws.TypeOf <CruiseControlException>().With.Property("InnerException").TypeOf <FileNotFoundException>());
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="FileBasedSessionCache" /> class.	
        /// </summary>
        /// <param name="fileSystem">The file system.</param>
        /// <param name="executionEnvironment">The execution environment.</param>
        /// <param name="clock">The clock.</param>
        /// <remarks></remarks>
		public FileBasedSessionCache(IFileSystem fileSystem, IExecutionEnvironment executionEnvironment, IClock clock) : base(clock)
		{
			this.fileSystem = fileSystem;
			this.executionEnvironment = executionEnvironment;

			storeLocation = Path.Combine(this.executionEnvironment.GetDefaultProgramDataFolder(ApplicationType.Server), "sessions");
			fileSystem.EnsureFolderExists(storeLocation);
		}
        /// <summary>
        /// Initializes a new instance of the <see cref="FileStateManager"/> class.
        /// </summary>
        /// <param name="fileSystem">The file system.</param>
        /// <param name="executionEnvironment">The execution environment.</param>
		public FileStateManager(IFileSystem fileSystem, IExecutionEnvironment executionEnvironment)
		{
			this.fileSystem = fileSystem;
			this.executionEnvironment = executionEnvironment;

			stateFileDirectory = this.executionEnvironment.GetDefaultProgramDataFolder(ApplicationType.Server);
			fileSystem.EnsureFolderExists(stateFileDirectory);
		}
        /// <summary>
        /// Initializes a new instance of the <see cref="XmlProjectStateManager" /> class.
        /// </summary>
        /// <param name="fileSystem">The file system.</param>
        /// <param name="executionEnvironment">The execution environment.</param>
        /// <remarks></remarks>
        public XmlProjectStateManager(IFileSystem fileSystem, IExecutionEnvironment executionEnvironment)
        {
            this.fileSystem           = fileSystem;
            this.executionEnvironment = executionEnvironment;

            persistanceFileName = Path.Combine(this.executionEnvironment.GetDefaultProgramDataFolder(ApplicationType.Server), "ProjectsState.xml");
            fileSystem.EnsureFolderExists(persistanceFileName);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="FileStateManager"/> class.
        /// </summary>
        /// <param name="fileSystem">The file system.</param>
        /// <param name="executionEnvironment">The execution environment.</param>
        public FileStateManager(IFileSystem fileSystem, IExecutionEnvironment executionEnvironment)
        {
            this.fileSystem           = fileSystem;
            this.executionEnvironment = executionEnvironment;

            stateFileDirectory = this.executionEnvironment.GetDefaultProgramDataFolder(ApplicationType.Server);
            fileSystem.EnsureFolderExists(stateFileDirectory);
        }
        internal ConfigPreprocessor(IFileSystem fileSystem, IExecutionEnvironment executionEnvironment)
        {
            this.fileSystem = fileSystem;
            this.executionEnvironment = executionEnvironment;

            programDataFolder = this.executionEnvironment.GetDefaultProgramDataFolder(ApplicationType.Server);
            fileSystem.EnsureFolderExists(programDataFolder);
        }
Example #8
0
        /// <summary>
        /// Initializes a new instance of the <see cref="FileBasedSessionCache" /> class.
        /// </summary>
        /// <param name="fileSystem">The file system.</param>
        /// <param name="executionEnvironment">The execution environment.</param>
        /// <param name="clock">The clock.</param>
        /// <remarks></remarks>
        public FileBasedSessionCache(IFileSystem fileSystem, IExecutionEnvironment executionEnvironment, IClock clock) : base(clock)
        {
            this.fileSystem           = fileSystem;
            this.executionEnvironment = executionEnvironment;

            storeLocation = Path.Combine(this.executionEnvironment.GetDefaultProgramDataFolder(ApplicationType.Server), "sessions");
            fileSystem.EnsureFolderExists(storeLocation);
        }
        public XmlProjectStateManager(IFileSystem fileSystem, IExecutionEnvironment executionEnvironment)
        {
            this.fileSystem = fileSystem;
            this.executionEnvironment = executionEnvironment;

            persistanceFileName = Path.Combine(this.executionEnvironment.GetDefaultProgramDataFolder(ApplicationType.Server), "ProjectsState.xml");
            fileSystem.EnsureFolderExists(persistanceFileName);
        }
Example #10
0
        private ProcessInfo NewProcessInfoWithArgs(IIntegrationResult result, string args)
        {
            var wd = result.BaseFromWorkingDirectory(WorkingDirectory);

            // ensure working directory exists
            fileSystem.EnsureFolderExists(wd);

            var pi = new ProcessInfo(Executable, args, wd);

            SetEnvironmentVariables(pi, result);
            return(pi);
        }
Example #11
0
        /// <summary>
        /// Executes the specified result.
        /// </summary>
        /// <param name="result">The result.</param>
        /// <returns></returns>
        /// <remarks></remarks>
        protected override bool Execute(IIntegrationResult result)
        {
            result.BuildProgressInformation.SignalStartRunTask(!string.IsNullOrEmpty(Description) ? Description : "Writing Modifications");

            XmlSerializer serializer = new XmlSerializer(typeof(Modification[]));
            StringWriter  writer     = new Utf8StringWriter();

            serializer.Serialize(writer, result.Modifications);
            string filename = ModificationFile(result);

            fileSystem.EnsureFolderExists(filename);
            fileSystem.Save(filename, writer.ToString());

            return(true);
        }
        public void DefaultConstructorSetsPersistanceLocation()
        {
            // This is an indirect test - if the correct location is set, then the FileExists call
            // will be valid
            Expect.Call(executionEnvironment.GetDefaultProgramDataFolder(ApplicationType.Server)).IgnoreArguments().Constraints(Rhino.Mocks.Constraints.Is.NotNull()).Return(applicationDataPath);
            Expect.Call(delegate { fileSystem.EnsureFolderExists(applicationDataPath); }).IgnoreArguments().Constraints(Rhino.Mocks.Constraints.Is.NotNull());
            Expect.Call(fileSystem.FileExists(persistanceFilePath)).Return(false);
            mocks.ReplayAll();

            stateManager = new XmlProjectStateManager(fileSystem, executionEnvironment);
            stateManager.CheckIfProjectCanStart("Project");
            mocks.VerifyAll();
        }