Skip to content
Browse files

Backport from trunk rev 7383:

CCNET-1906: NDepend Task - Configuration - Executable Node - Directory names with spaces

 * path to ndepend executable was double-quoted before the BaseExecutableTask has validated it -> failed validation
 * double quote only command line parameters
  • Loading branch information...
1 parent 04ed9f8 commit 248310128d1629b652c78ee7abe216020aeefabb @dnauck dnauck committed Jun 23, 2010
Showing with 39 additions and 7 deletions.
  1. +36 −3 project/UnitTests/Core/Tasks/NDependTaskTests.cs
  2. +3 −4 project/core/tasks/NDependTask.cs
View
39 project/UnitTests/Core/Tasks/NDependTaskTests.cs
@@ -84,6 +84,34 @@ public void CanOverrideExecutable()
}
[Test]
+ public void CanUsePathsWithSpaces()
+ {
+ var workingDir = "working Dir\\NDependResults";
+ var result = GenerateResultMock("working Dir", "artefact Dir");
+ var executor = GenerateExecutorMock("working Dir\\ndepend-app.exe", "\"working Dir\\NDependResults\" /OutDir \"working Dir\\NDependResults\"", "working Dir", 600000);
+ var fileSystem = mocks.StrictMock<IFileSystem>();
+ Expect.Call(fileSystem.DirectoryExists(workingDir)).Return(true).Repeat.Times(2);
+ Expect.Call(fileSystem.GetFilesInDirectory(workingDir)).Return(new string[0]);
+ Expect.Call(fileSystem.GetFilesInDirectory(workingDir)).Return(new string[] {
+ "working Dir\\file1.txt",
+ "working Dir\\file2.xml"
+ });
+ Expect.Call(() => fileSystem.EnsureFolderExists("artefact Dir\\1\\NDepend"));
+ Expect.Call(() => fileSystem.Copy("working Dir\\file1.txt", "artefact Dir\\1\\NDepend\\file1.txt"));
+ Expect.Call(() => fileSystem.Copy("working Dir\\file2.xml", "artefact Dir\\1\\NDepend\\file2.xml"));
+ Expect.Call(fileSystem.GenerateTaskResultFromFile("working Dir\\file2.xml")).Return(mocks.DynamicMock<ITaskResult>());
+ var logger = mocks.DynamicMock<ILogger>();
+ var task = new NDependTask(executor, fileSystem, logger);
+ task.Executable = "ndepend-app.exe";
+
+ Expect.Call(result.Status).PropertyBehavior();
+ mocks.ReplayAll();
+ result.Status = IntegrationStatus.Unknown;
+ task.Run(result);
+ mocks.VerifyAll();
+ }
+
+ [Test]
public void CanOverrideBaseDirectory()
{
var workingDir = "somewhere-else\\NDependResults";
@@ -194,15 +222,20 @@ public void DefaultConstructorSetsFileSystemAndLogger()
#region Private methods
private IIntegrationResult GenerateResultMock()
{
+ return GenerateResultMock("workingDir", "artefactDir");
+ }
+
+ private IIntegrationResult GenerateResultMock(string workingDir, string artefactDir)
+ {
var buildInfo = mocks.DynamicMock<BuildProgressInformation>(string.Empty, string.Empty);
var result = mocks.StrictMock<IIntegrationResult>();
SetupResult.For(result.BuildProgressInformation).Return(buildInfo);
- SetupResult.For(result.WorkingDirectory).Return("workingDir");
- SetupResult.For(result.ArtifactDirectory).Return("artefactDir");
+ SetupResult.For(result.WorkingDirectory).Return(workingDir);
+ SetupResult.For(result.ArtifactDirectory).Return(artefactDir);
SetupResult.For(result.IntegrationProperties).Return(new Dictionary<string, string>());
SetupResult.For(result.Label).Return("1");
Expect.Call(() => result.AddTaskResult(mocks.DynamicMock<ITaskResult>())).IgnoreArguments().Repeat.Any();
- SetupResult.For(result.BaseFromArtifactsDirectory("1")).Return("artefactDir\\1");
+ SetupResult.For(result.BaseFromArtifactsDirectory("1")).Return(string.Concat(artefactDir, "\\1"));
return result;
}
View
7 project/core/tasks/NDependTask.cs
@@ -311,11 +311,11 @@ protected override string GetProcessFilename()
string path;
if (string.IsNullOrEmpty(Executable))
{
- path = RootPath(defaultExecutable, true);
+ path = RootPath(defaultExecutable, false);
}
else
{
- path = RootPath(Executable, true);
+ path = RootPath(Executable, false);
}
return path;
}
@@ -329,8 +329,7 @@ protected override string GetProcessFilename()
/// <returns></returns>
protected override string GetProcessBaseDirectory(IIntegrationResult result)
{
- string path = StringUtil.AutoDoubleQuoteString(rootPath);
- return path;
+ return rootPath;
}
#endregion

0 comments on commit 2483101

Please sign in to comment.
Something went wrong with that request. Please try again.