private ProcessInfo NewCheckoutProcessInfo(IIntegrationResult result) { // CCNET-1796: work around a CVS limitation: the -d parameter only accepts limited relative paths // so the working directory is one level up of the checkout dir and // override checkout directory var wd = new DirectoryInfo(result.BaseFromWorkingDirectory(WorkingDirectory)); if (wd.Parent == null) { throw new ArgumentException( @"[CVS] Cannot checkout into working directory that denotes a root, such as '\' or 'C:\'."); } var checkoutWd = wd.Parent.FullName; var checkoutDir = wd.Name; Log.Debug("[CVS] Configured Working Directory: '{0}'", wd); Log.Debug("[CVS] Checkout Working Directory: '{0}'", checkoutWd); Log.Debug("[CVS] Checkout Directory: '{0}'", checkoutDir); ProcessArgumentBuilder builder = new ProcessArgumentBuilder(); AppendCvsRoot(builder); builder.AddArgument("-q"); builder.AddArgument("checkout"); builder.AddArgument("-R"); builder.AddArgument("-P"); builder.AddArgument("-r", Branch); builder.AddArgument("-d", StringUtil.AutoDoubleQuoteString(checkoutDir)); builder.AddArgument(Module); var pi = NewProcessInfoWithArgs(result, builder.ToString()); pi.WorkingDirectory = checkoutWd; return(pi); }
/// <summary> /// Ensures that a path is rooted. /// </summary> /// <param name="path"></param> /// <param name="doubleQuote"></param> /// <returns></returns> private string RootPath(string path, bool doubleQuote) { string actualPath; if (Path.IsPathRooted(path)) { actualPath = path; } else { var basePath = rootPath ?? this.BaseDirectory ?? string.Empty; if (string.IsNullOrEmpty(path)) { actualPath = Path.Combine(basePath, "NDependResults"); } else { actualPath = Path.Combine(basePath, path); } } if (doubleQuote) { actualPath = StringUtil.AutoDoubleQuoteString(actualPath); } return(actualPath); }
/// <summary> /// Gets the process arguments. /// </summary> /// <param name="result">The result.</param> /// <returns></returns> /// <remarks></remarks> protected override string GetProcessArguments(IIntegrationResult result) { ProcessArgumentBuilder b = new ProcessArgumentBuilder(); b.AddArgument("/nologo"); if (!string.IsNullOrEmpty(Targets)) { b.AddArgument("/t:"); string targets = string.Empty; foreach (string target in Targets.Split(';')) { if (!(targets != null && targets.Length == 0)) { targets = string.Format(System.Globalization.CultureInfo.CurrentCulture, "{0};{1}", targets, StringUtil.AutoDoubleQuoteString(target)); } else { targets = StringUtil.AutoDoubleQuoteString(target); } } b.Append(targets); } b.AppendArgument(GetPropertyArgs(result)); b.AppendArgument(BuildArgs); b.AddArgument(ProjectFile); b.AppendArgument(GetLoggerArgs(result)); return(b.ToString()); }
private static string CheckAndQuoteLoggerSetting(string logger) { if (logger.IndexOf(';') > -1) { Log.Error("The <logger> setting contains semicolons. Only commas are allowed."); throw new CruiseControlException("The <logger> setting contains semicolons. Only commas are allowed."); } bool spaceFound = false; StringBuilder b = new StringBuilder(); foreach (string part in logger.Split(',')) { if (part.IndexOf(' ') > -1) { if (spaceFound) { Log.Error("The <logger> setting contains multiple spaces. Only the assembly name is allowed to contain spaces."); throw new CruiseControlException("The <logger> setting contains multiple spaces. Only the assembly name is allowed to contain spaces."); } b.Append(StringUtil.AutoDoubleQuoteString(part)); spaceFound = true; } else { b.Append(part); } b.Append(","); } return(b.ToString().TrimEnd(',')); }
/// <summary> /// Ensures that a path is rooted. /// </summary> /// <param name="path"></param> /// <param name="doubleQuote"></param> /// <returns></returns> private string RootPath(string path, bool doubleQuote) { string actualPath; if (Path.IsPathRooted(path)) { actualPath = path; } else { if (string.IsNullOrEmpty(path)) { actualPath = Path.Combine(rootPath, "NCoverResults"); } else { actualPath = Path.Combine(rootPath, path); } } if (doubleQuote) { actualPath = StringUtil.AutoDoubleQuoteString(actualPath); } return(actualPath); }
private string GetLoggerArgs(IIntegrationResult result) { ProcessArgumentBuilder builder = new ProcessArgumentBuilder(); builder.Append("/l:"); if (string.IsNullOrEmpty(Logger)) { // Since hot-swapping shadow copies the files, we also need to move the logger over var loggerPath = shadowCopier.RetrieveFilePath("ThoughtWorks.CruiseControl.MsBuild.dll"); if (!string.IsNullOrEmpty(loggerPath)) { builder.Append(StringUtil.AutoDoubleQuoteString(loggerPath) + ";"); } } else { builder.Append(CheckAndQuoteLoggerSetting(Logger) + ";"); } builder.Append(StringUtil.AutoDoubleQuoteString(MsBuildOutputFile(result))); foreach (string parameter in LoggerParameters) { builder.Append(";" + parameter); } return(builder.ToString()); }
/// <summary> /// Gets the process arguments. /// </summary> /// <param name="result">The result.</param> /// <returns></returns> /// <remarks></remarks> protected override string GetProcessArguments(IIntegrationResult result) { var buffer = new ProcessArgumentBuilder(); buffer.AppendArgument(StringUtil.AutoDoubleQuoteString(BuildFile)); buffer.AppendArgument("logfile={0}", StringUtil.AutoDoubleQuoteString(GetFakeOutputFile(result))); AppendIntegrationResultProperties(buffer, result); return(buffer.ToString()); }
public void TestAutoDoubleQuoteString() { const string nonQuotedString = "foo"; const string nonQuotedStringWithSpaces = "f o o"; const string quotedString = "\"foo\""; const string quotedStringWithSpaces = "\"f o o\""; Assert.AreEqual(StringUtil.AutoDoubleQuoteString(nonQuotedString), nonQuotedString); Assert.AreEqual(StringUtil.AutoDoubleQuoteString(quotedString), quotedString); Assert.AreEqual(StringUtil.AutoDoubleQuoteString(nonQuotedStringWithSpaces), quotedStringWithSpaces); Assert.AreEqual(StringUtil.AutoDoubleQuoteString(quotedStringWithSpaces), quotedStringWithSpaces); }
/// <summary> /// Retrieve the arguments /// </summary> /// <param name="result"></param> /// <returns></returns> protected override string GetProcessArguments(IIntegrationResult result) { ProcessArgumentBuilder buffer = new ProcessArgumentBuilder(); buffer.Append(RootPath(ProgramToCover, true)); if (!string.IsNullOrEmpty(TestProject)) { string testProject; if (!string.IsNullOrEmpty(WorkingDirectory)) { testProject = Path.Combine(RootPath(WorkingDirectory, false), TestProject); testProject = StringUtil.AutoDoubleQuoteString(testProject); } else { testProject = RootPath(TestProject, true); } buffer.AppendArgument(testProject); } buffer.AppendArgument(ProgramParameters); // Add all the NCover arguments buffer.AppendIf(!string.IsNullOrEmpty(LogFile), "//l \"{0}\"", RootPath(LogFile, false)); buffer.AppendIf(LogLevel != NCoverLogLevel.Default, "//ll {0}", LogLevel.ToString()); buffer.AppendIf(!string.IsNullOrEmpty(ProjectName), "//p \"{0}\"", ProjectName); buffer.AppendIf(!string.IsNullOrEmpty(CoverageFile), "//x \"{0}\"", RootPath(CoverageFile, false)); buffer.AppendIf(string.IsNullOrEmpty(CoverageFile), "//x \"{0}\"", RootPath("Coverage.xml", false)); buffer.AppendIf(!string.IsNullOrEmpty(CoverageMetric), "//ct \"{0}\"", CoverageMetric); buffer.AppendIf(!string.IsNullOrEmpty(ExcludedAttributes), "//ea \"{0}\"", ExcludedAttributes); buffer.AppendIf(!string.IsNullOrEmpty(ExcludedAssemblies), "//eas \"{0}\"", ExcludedAssemblies); buffer.AppendIf(!string.IsNullOrEmpty(ExcludedFiles), "//ef \"{0}\"", ExcludedFiles); buffer.AppendIf(!string.IsNullOrEmpty(ExcludedMethods), "//em \"{0}\"", ExcludedMethods); buffer.AppendIf(!string.IsNullOrEmpty(ExcludedTypes), "//et \"{0}\"", ExcludedTypes); buffer.AppendIf(!string.IsNullOrEmpty(IncludedAttributes), "//ia \"{0}\"", IncludedAttributes); buffer.AppendIf(!string.IsNullOrEmpty(IncludedAssemblies), "//ias \"{0}\"", IncludedAssemblies); buffer.AppendIf(!string.IsNullOrEmpty(IncludedFiles), "//if \"{0}\"", IncludedFiles); buffer.AppendIf(!string.IsNullOrEmpty(IncludedTypes), "//it \"{0}\"", IncludedTypes); buffer.AppendIf(DisableAutoexclusion, "//na"); buffer.AppendIf(!string.IsNullOrEmpty(ProcessModule), "//pm \"{0}\"", ProcessModule); buffer.AppendIf(!string.IsNullOrEmpty(SymbolSearch), "//ssp \"{0}\"", SymbolSearch); buffer.AppendIf(!string.IsNullOrEmpty(TrendFile), "//at \"{0}\"", RootPath(TrendFile, false)); buffer.AppendArgument("//bi \"{0}\"", !string.IsNullOrEmpty(BuildId) ? BuildId : result.Label); buffer.AppendIf(!string.IsNullOrEmpty(SettingsFile), "//cr \"{0}\"", RootPath(SettingsFile, false)); buffer.AppendIf(Register, "//reg"); buffer.AppendIf(!string.IsNullOrEmpty(WorkingDirectory), "//w \"{0}\"", RootPath(WorkingDirectory, false)); buffer.AppendIf(ApplicationLoadWait > 0, "//wal {0}", ApplicationLoadWait.ToString(CultureInfo.CurrentCulture)); buffer.AppendIf(CoverIis, "//iis"); buffer.AppendIf(ServiceTimeout > 0, "//st {0}", ServiceTimeout.ToString(CultureInfo.CurrentCulture)); buffer.AppendIf(!string.IsNullOrEmpty(WindowsService), "//svc {0}", WindowsService); return(buffer.ToString()); }
public void ShouldCloneAndDeleteWorkingDirIfGitDirectoryDoesntExist() { mockFileSystem.ExpectAndReturn("DirectoryExists", true, DefaultWorkingDirectory); mockFileSystem.ExpectAndReturn("DirectoryExists", false, Path.Combine(DefaultWorkingDirectory, ".git")); ExpectToExecuteArguments(string.Concat(GIT_CLONE, " ", StringUtil.AutoDoubleQuoteString(DefaultWorkingDirectory)), Path.GetDirectoryName(DefaultWorkingDirectory.TrimEnd(Path.DirectorySeparatorChar))); ExpectToExecuteArguments("log origin/master --date-order -1 --pretty=format:\"%H\""); ExpectToExecuteArguments(GIT_REMOTE_COMMITS); git.GetModifications(IntegrationResult(from), IntegrationResult(to)); }
/// <summary> /// Gets the process arguments. /// </summary> /// <param name="result">The result.</param> /// <returns></returns> /// <remarks></remarks> protected override string GetProcessArguments(IIntegrationResult result) { ProcessArgumentBuilder buffer = new ProcessArgumentBuilder(); buffer.AppendIf(NoLogo, "-nologo"); buffer.AppendArgument(@"-buildfile:{0}", StringUtil.AutoDoubleQuoteString(BuildFile)); buffer.AppendArgument("-logger:{0}", Logger); buffer.AppendArgument("-logfile:{0}", StringUtil.AutoDoubleQuoteString(GetNantOutputFile(result))); buffer.AppendArgument("-listener:{0}", Listener); AppendBuildArguments(buffer); AppendIntegrationResultProperties(buffer, result); AppendTargets(buffer); return(buffer.ToString()); }
public void RebaseFromWorkingDirectory() { AddDefaultAssemblyToCheck(task); ProcessInfo info = NewProcessInfo( string.Format(System.Globalization.CultureInfo.CurrentCulture, "--xml {0} {1} {2}", StringUtil.AutoDoubleQuoteString(Path.Combine(result.ArtifactDirectory, "gendarme-results.xml")), StringUtil.AutoDoubleQuoteString("*.dll"), StringUtil.AutoDoubleQuoteString("*.exe")), Path.Combine(DefaultWorkingDirectory, "src")); info.WorkingDirectory = Path.Combine(DefaultWorkingDirectory, "src"); ExpectToExecute(info); task.ConfiguredBaseDirectory = "src"; task.VerifyTimeoutSeconds = 600; task.Run(result); }
public void ExecuteRunsFakeWithDefaults() { var workingDir = Path.Combine(DefaultWorkingDirectory, "WorkingDir"); var artefactDir = Path.Combine(DefaultWorkingDirectoryWithSpaces, "ArtifactsDir"); var buildFile = Path.Combine(DefaultWorkingDirectory, "ccnet.fsx"); var result = GenerateResultMock(workingDir, artefactDir); var task = new FakeTask(executor); task.BuildFile = buildFile; SetupExecutorMock(executor, "FAKE.exe", string.Concat(StringUtil.AutoDoubleQuoteString(buildFile), " ", "logfile=", StringUtil.AutoDoubleQuoteString(Path.Combine(artefactDir, string.Format(FakeTask.logFilename, task.LogFileId)))), workingDir, 600000); Mock.Get(result).SetupProperty(_result => _result.Status); result.Status = IntegrationStatus.Unknown; task.Run(result); mocks.Verify(); }
public void DoubleQuoteSpacesinPaths() { string expectedArgs = string.Concat("/P", StringUtil.AutoDoubleQuoteString(Path.Combine(DefaultWorkingDirectoryWithSpaces, "TestProject.fbz5"))); ExpectToExecuteArguments(expectedArgs, DefaultWorkingDirectoryWithSpaces); _mockRegistry.ExpectAndReturn("GetLocalMachineSubKeyValue", Path.Combine(DefaultWorkingDirectory, "FinalBuilder5.exe"), @"SOFTWARE\VSoft\FinalBuilder\5.0", "Location"); _task.ShowBanner = true; _task.ProjectFile = Path.Combine(DefaultWorkingDirectoryWithSpaces, "TestProject.fbz5"); _task.Timeout = 600; _task.Run(_result); Assert.AreEqual(1, _result.TaskResults.Count); Assert.AreEqual(IntegrationStatus.Success, _result.Status); Assert.AreEqual(ProcessResultOutput, _result.TaskOutput); }
protected new string GetWorkingFolderArguments() { StringBuilder args = new StringBuilder(200); args.Append(' '); if (!string.IsNullOrEmpty(vault.WorkingDirectory)) { args.Append(string.Concat(StringUtil.AutoDoubleQuoteString(DefaultWorkingDirectory), " ")); if (vault.UseVaultWorkingDirectory) { args.Append(@"-useworkingfolder "); } } args.Append(@"-merge overwrite -makewritable -backup no"); Log.Info(args.ToString()); return(args.ToString()); }
public void TemporaryLogFile() { string expectedArgs = @"/B /TL /P" + StringUtil.AutoDoubleQuoteString(Path.Combine(DefaultWorkingDirectory, "TestProject.fbz5")); ExpectToExecuteArguments(expectedArgs); _mockRegistry.Setup(registry => registry.GetLocalMachineSubKeyValue(@"SOFTWARE\VSoft\FinalBuilder\5.0", "Location")).Returns(Path.Combine(DefaultWorkingDirectory, "FinalBuilder5.exe")).Verifiable(); _task.ProjectFile = Path.Combine(DefaultWorkingDirectory, "TestProject.fbz5"); _task.UseTemporaryLogFile = true; _task.Timeout = 600; _task.Run(_result); Assert.AreEqual(1, _result.TaskResults.Count); Assert.AreEqual(IntegrationStatus.Success, _result.Status); Assert.AreEqual(ProcessResultOutput, _result.TaskOutput); }
public virtual void ArgumentsCorrectForGetSourceScenario16() { vault.Folder = "$"; vault.AutoGetSource = true; vault.ApplyLabel = false; vault.UseVaultWorkingDirectory = false; vault.WorkingDirectory = @""; vault.CleanCopy = false; this.ProcessResultOutput = string.Format(listFolderOutputWithWorkingFolderSet, DefaultWorkingDirectory); ExpectToExecuteArguments(@"listworkingfolders" + SetAndGetCommonOptionalArguments()); ExpectToExecuteArguments(@"get $ -destpath " + StringUtil.AutoDoubleQuoteString(DefaultWorkingDirectory) + GetWorkingFolderArguments() + GetFileTimeArgument() + SetAndGetCommonOptionalArguments()); vault.GetSource(result); VerifyAll(); }
public void ShouldEncloseDirectoriesInQuotesIfTheyContainSpaces() { result.ArtifactDirectory = DefaultWorkingDirectoryWithSpaces; result.WorkingDirectory = DefaultWorkingDirectoryWithSpaces; task.AssemblyListFile = Path.Combine(DefaultWorkingDirectoryWithSpaces, "gendarme assembly file.txt"); task.ConfigFile = Path.Combine(DefaultWorkingDirectoryWithSpaces, "gendarme rules.xml"); task.IgnoreFile = Path.Combine(DefaultWorkingDirectoryWithSpaces, "gendarme ignore file.txt"); ExpectToExecuteArguments(@"--config " + StringUtil.AutoDoubleQuoteString(task.ConfigFile) + " --ignore " + StringUtil.AutoDoubleQuoteString(task.IgnoreFile) + " --xml " + StringUtil.AutoDoubleQuoteString(Path.Combine(result.ArtifactDirectory, "gendarme-results.xml")) + " @" + StringUtil.AutoDoubleQuoteString(task.AssemblyListFile), DefaultWorkingDirectoryWithSpaces); task.ConfiguredBaseDirectory = DefaultWorkingDirectoryWithSpaces; task.VerifyTimeoutSeconds = 600; task.Run(result); }
public virtual void ArgumentsCorrectForGetSourceScenario2() { vault.Folder = "$"; vault.AutoGetSource = true; vault.ApplyLabel = true; vault.UseVaultWorkingDirectory = true; vault.WorkingDirectory = DefaultWorkingDirectory; vault.CleanCopy = false; ExpectToNotCleanFolder(); ExpectToExecuteArguments(@"label $ foo" + SetAndGetCommonOptionalArguments()); ExpectToExecuteArguments(@"getlabel $ foo -labelworkingfolder " + StringUtil.AutoDoubleQuoteString(DefaultWorkingDirectory) + GetWorkingFolderArguments() + GetFileTimeArgument() + SetAndGetCommonOptionalArguments()); vault.GetSource(result); VerifyAll(); }
public virtual void ShouldSetAndRemoveLabelOnFailure() { ExpectToExecuteArguments(@"label $ foo"); ExpectToExecuteArguments(@"getlabel $ foo -destpath " + StringUtil.AutoDoubleQuoteString(DefaultWorkingDirectory) + " -merge overwrite -makewritable -setfiletime checkin"); ExpectToExecuteArguments(@"deletelabel $ foo"); vault.ApplyLabel = true; vault.UseVaultWorkingDirectory = false; vault.WorkingDirectory = DefaultWorkingDirectory; vault.AutoGetSource = true; vault.Folder = "$"; vault.GetSource(result); IntegrationResult failed = IntegrationResultMother.CreateFailed(); failed.Label = result.Label; failed.WorkingDirectory = result.WorkingDirectory; vault.LabelSourceControl(failed); VerifyAll(); }
public void ShouldCreateWorkingDirectoryIfItDoesntExistOrIsNotARepository() { hg = new Mercurial((IHistoryParser)mockHistoryParser.MockInstance, (ProcessExecutor)mockProcessExecutor.MockInstance, (IFileSystem)mockFileSystem.MockInstance, (IFileDirectoryDeleter)mockFileDirectoryDeleter.MockInstance); hg.WorkingDirectory = tempWorkDir; hg.Repository = @"C:\foo"; mockFileSystem.Expect("EnsureFolderExists", tempWorkDir); mockFileSystem.Expect("EnsureFolderExists", tempHgDir); mockFileSystem.ExpectAndReturn("DirectoryExists", true, tempWorkDir); mockFileSystem.ExpectAndReturn("DirectoryExists", false, tempHgDir); mockFileDirectoryDeleter.Expect("DeleteIncludingReadOnlyObjects", new object[] { tempWorkDir }); mockFileSystem.ExpectAndReturn("DirectoryExists", false, tempWorkDir); ExpectToExecuteArguments(@"init " + StringUtil.AutoDoubleQuoteString(tempWorkDir), Directory.GetParent(Path.GetFullPath(tempWorkDir)).FullName); ExpectToExecuteArguments(@"pull C:\foo", tempWorkDir); hg.GetModifications(IntegrationResult(from), IntegrationResult(to)); }
private void CreateAssemblyList(ProcessArgumentBuilder buffer) { if (string.IsNullOrEmpty(AssemblyListFile) && (Assemblies == null || Assemblies.Length == 0)) { throw new ConfigurationException("[GendarmeTask] Neither 'assemblyListFile' nor 'assemblies' are specified. Please specify one of them."); } // append the assembly list file if set if (!string.IsNullOrEmpty(AssemblyListFile)) { buffer.AppendArgument(string.Concat("@", StringUtil.AutoDoubleQuoteString(AssemblyListFile))); } // build the assembly list by the assembly match collection foreach (AssemblyMatch asm in Assemblies) { buffer.AppendArgument(asm.Expression); } }
public void ShouldCheckoutInsteadOfUpdateIfCVSFoldersDoNotExist() { var lastDirectorySeparatorIndex = DefaultWorkingDirectory.TrimEnd().TrimEnd(Path.DirectorySeparatorChar).LastIndexOf(Path.DirectorySeparatorChar); var checkoutWd = DefaultWorkingDirectory.Substring(0, lastDirectorySeparatorIndex); var checkoutDir = DefaultWorkingDirectory.Substring(lastDirectorySeparatorIndex).Trim(Path.DirectorySeparatorChar); ExpectToExecuteArguments( string.Format( @"-d :pserver:[email protected]:/cvsroot/ccnet -q checkout -R -P -d {0} ccnet", StringUtil.AutoDoubleQuoteString(checkoutDir)), checkoutWd); ExpectCvsDirectoryExists(false); cvs.CvsRoot = ":pserver:[email protected]:/cvsroot/ccnet"; cvs.Module = "ccnet"; cvs.AutoGetSource = true; cvs.WorkingDirectory = DefaultWorkingDirectory; cvs.GetSource(IntegrationResult()); }
public virtual void ShouldStripNonXmlFromWorkingFolderList() { vault.Folder = "$"; vault.AutoGetSource = true; vault.ApplyLabel = true; vault.UseVaultWorkingDirectory = true; vault.WorkingDirectory = null; vault.CleanCopy = false; this.ProcessResultOutput = string.Format(listFolderOutputWithNonXml, DefaultWorkingDirectory); ExpectToExecuteArguments(@"listworkingfolders" + SetAndGetCommonOptionalArguments()); ExpectToExecuteArguments(@"label $ foo" + SetAndGetCommonOptionalArguments()); ExpectToExecuteArguments(@"getlabel $ foo -labelworkingfolder " + StringUtil.AutoDoubleQuoteString(DefaultWorkingDirectory) + GetWorkingFolderArguments() + GetFileTimeArgument() + SetAndGetCommonOptionalArguments()); vault.GetSource(result); VerifyAll(); }
// Returns arguments to FBCMD.EXE private string GetFBArgs() { StringBuilder args = new StringBuilder(); if (!ShowBanner) { args.Append("/B "); } if (UseTemporaryLogFile) { args.Append("/TL "); } else if (DontWriteToLog) { args.Append("/S "); } if (FBVariables != null && FBVariables.Length > 0) { args.Append("/V"); for (int j = 0; j < FBVariables.Length; j++) { args.Append(FBVariables[j].Name); args.Append("="); args.Append(StringUtil.AutoDoubleQuoteString(FBVariables[j].Value)); if (j < FBVariables.Length - 1) { args.Append(";"); } else { args.Append(" "); } } } args.Append("/P"); args.Append(StringUtil.AutoDoubleQuoteString(ProjectFile)); return(args.ToString()); }
public void ShouldCreateWorkingDirectoryIfItDoesntExistOrIsNotARepository() { hg = new Mercurial((IHistoryParser)mockHistoryParser.Object, (ProcessExecutor)mockProcessExecutor.Object, (IFileSystem)mockFileSystem.Object, (IFileDirectoryDeleter)mockFileDirectoryDeleter.Object); hg.WorkingDirectory = tempWorkDir; hg.Repository = @"C:\foo"; MockSequence sequence = new MockSequence(); mockFileSystem.Setup(fileSystem => fileSystem.EnsureFolderExists(tempWorkDir)).Verifiable(); mockFileSystem.Setup(fileSystem => fileSystem.EnsureFolderExists(tempHgDir)).Verifiable(); mockFileSystem.InSequence(sequence).Setup(fileSystem => fileSystem.DirectoryExists(tempWorkDir)).Returns(true).Verifiable(); mockFileSystem.Setup(fileSystem => fileSystem.DirectoryExists(tempHgDir)).Returns(false).Verifiable(); mockFileDirectoryDeleter.Setup(deleter => deleter.DeleteIncludingReadOnlyObjects(tempWorkDir)).Verifiable(); mockFileSystem.InSequence(sequence).Setup(fileSystem => fileSystem.DirectoryExists(tempWorkDir)).Returns(false).Verifiable(); ExpectToExecuteArguments(sequence, @"init " + StringUtil.AutoDoubleQuoteString(tempWorkDir), Directory.GetParent(Path.GetFullPath(tempWorkDir)).FullName); ExpectToExecuteArguments(sequence, @"pull C:\foo", tempWorkDir); hg.GetModifications(IntegrationResult(from), IntegrationResult(to)); }
public void ShouldCheckoutOnWorkingDictionaryWithSpaces() { var lastDirectorySeparatorIndex = DefaultWorkingDirectoryWithSpaces.TrimEnd().TrimEnd(Path.DirectorySeparatorChar).LastIndexOf(Path.DirectorySeparatorChar); var checkoutWd = DefaultWorkingDirectoryWithSpaces.Substring(0, lastDirectorySeparatorIndex); var checkoutDir = DefaultWorkingDirectoryWithSpaces.Substring(lastDirectorySeparatorIndex).Trim(Path.DirectorySeparatorChar); ExpectToExecuteArguments( string.Format( @"-d :pserver:[email protected]:/cvsroot/ccnet -q checkout -R -P -r branch -d {0} ccnet", StringUtil.AutoDoubleQuoteString(checkoutDir)), checkoutWd); mockFileSystem.Setup(fileSystem => fileSystem.DirectoryExists(Path.Combine(DefaultWorkingDirectoryWithSpaces, "CVS"))).Returns(false).Verifiable(); cvs.CvsRoot = ":pserver:[email protected]:/cvsroot/ccnet"; cvs.Module = "ccnet"; cvs.AutoGetSource = true; cvs.Branch = "branch"; cvs.WorkingDirectory = DefaultWorkingDirectoryWithSpaces; cvs.GetSource(IntegrationResult()); }
public void BuildCommandLine() { string expectedArgs = @"/B /S /Vvar1=value1;var2=""value 2"" /P" + StringUtil.AutoDoubleQuoteString(Path.Combine(DefaultWorkingDirectory, "TestProject.fbz5")); ExpectToExecuteArguments(expectedArgs); _mockRegistry.ExpectAndReturn("GetLocalMachineSubKeyValue", Path.Combine(DefaultWorkingDirectory, "FinalBuilder5.exe"), @"SOFTWARE\VSoft\FinalBuilder\5.0", "Location"); _task.FBVariables = new FBVariable[2]; _task.FBVariables[0] = new FBVariable("var1", "value1"); _task.FBVariables[1] = new FBVariable("var2", "value 2"); _task.ProjectFile = Path.Combine(DefaultWorkingDirectory, "TestProject.fbz5"); _task.ShowBanner = false; _task.DontWriteToLog = true; _task.Timeout = 600; _task.Run(_result); Assert.AreEqual(1, _result.TaskResults.Count); Assert.AreEqual(IntegrationStatus.Success, _result.Status); Assert.AreEqual(ProcessResultOutput, _result.TaskOutput); }
/// <summary> /// Gets the process arguments. /// </summary> /// <param name="result">The result.</param> /// <returns></returns> /// <remarks></remarks> protected override string GetProcessArguments(IIntegrationResult result) { ProcessArgumentBuilder buffer = new ProcessArgumentBuilder(); buffer.AppendIf(!string.IsNullOrEmpty(ConfigFile), "--config {0}", StringUtil.AutoDoubleQuoteString(ConfigFile)); buffer.AppendIf(!string.IsNullOrEmpty(RuleSet), "--set {0}", RuleSet); buffer.AppendIf(!string.IsNullOrEmpty(IgnoreFile), "--ignore {0}", StringUtil.AutoDoubleQuoteString(IgnoreFile)); buffer.AppendIf(Limit > 0, "--limit {0}", Limit.ToString(CultureInfo.CurrentCulture)); buffer.AppendIf(!string.IsNullOrEmpty(Severity), "--severity {0}", Severity); buffer.AppendIf(!string.IsNullOrEmpty(Confidence), "--confidence {0}", Confidence); buffer.AppendIf(Quiet, "--quiet"); buffer.AppendIf(Verbose, "--verbose"); // append output xml file buffer.AppendArgument("--xml {0}", StringUtil.AutoDoubleQuoteString(GetGendarmeOutputFile(result))); // append assembly list or list file CreateAssemblyList(buffer); return(buffer.ToString()); }
private ProcessInfo NewProcessInfoFrom(IIntegrationResult result) { ProcessInfo info = new ProcessInfo(GetFBPath(), GetFBArgs()); info.TimeOut = Timeout * 1000; int idx = ProjectFile.LastIndexOf('\\'); if (idx > -1) { info.WorkingDirectory = ProjectFile.Remove(idx, ProjectFile.Length - idx); // Trim down proj. file to get working dir. } // Add IntegrationProperties as environment variables foreach (string varName in result.IntegrationProperties.Keys) { object obj1 = result.IntegrationProperties[varName]; if ((obj1 != null) && !info.EnvironmentVariables.ContainsKey(varName)) { info.EnvironmentVariables.Add(varName, StringUtil.AutoDoubleQuoteString(StringUtil.RemoveTrailingPathDelimeter(StringUtil.IntegrationPropertyToString(obj1)))); } } return(info); }