Skip to content

Commit

Permalink
Fix escaping regression on coverage converter
Browse files Browse the repository at this point in the history
  • Loading branch information
dbolkensteyn committed May 23, 2016
1 parent 47cef9c commit 8fcf6f8
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 3 deletions.
2 changes: 1 addition & 1 deletion SonarQube.TeamBuild.Integration/CoverageReportConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ public static bool ConvertBinaryToXml(string converterExeFilePath, string inputB

List<string> args = new List<string>();
args.Add("analyze");
args.Add(string.Format(System.Globalization.CultureInfo.InvariantCulture, @"/output:""{0}""", outputXmlFilePath));
args.Add(string.Format(System.Globalization.CultureInfo.InvariantCulture, @"/output:{0}", outputXmlFilePath));
args.Add(inputBinaryFilePath);

ProcessRunnerArguments runnerArgs = new ProcessRunnerArguments(converterExeFilePath, false, logger)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public void Conv_OutputIsCaptured()

string inputFilePath = Path.Combine(testDir, "input.txt");
File.WriteAllText(inputFilePath, "dummy input file");

string converterFilePath = Path.Combine(testDir, "converter.bat");
File.WriteAllText(converterFilePath,
@"
Expand All @@ -41,7 +41,7 @@ echo Error output...>&2

// Act
bool success = CoverageReportConverter.ConvertBinaryToXml(converterFilePath, inputFilePath, outputFilePath, logger);

// Assert
Assert.IsTrue(success, "Expecting the process to succeed");

Expand Down Expand Up @@ -106,6 +106,36 @@ public void Conv_FailsIfFileConverterReturnsAnErrorCode()
Assert.IsFalse(File.Exists(outputFilePath), "Not expecting the output file to exist");
}

[TestMethod]
public void Conv_HasThreeArguments()
{
// Arrange
TestLogger logger = new TestLogger();
string testDir = TestUtils.CreateTestSpecificFolder(this.TestContext);

string outputFilePath = Path.Combine(testDir, "output.txt");

string inputFilePath = Path.Combine(testDir, "input.txt");
File.WriteAllText(inputFilePath, "dummy input file");

string converterFilePath = Path.Combine(testDir, "converter.bat");
File.WriteAllText(converterFilePath,
@"
set argC=0
for %%x in (%*) do Set /A argC+=1
echo Converter called with %argC% args
echo success > """ + outputFilePath + @"""");

// Act
bool success = CoverageReportConverter.ConvertBinaryToXml(converterFilePath, inputFilePath, outputFilePath, logger);

// Assert
Assert.IsTrue(success, "Expecting the process to succeed");

logger.AssertMessageLogged("Converter called with 3 args");
}

#endregion
}
}

0 comments on commit 8fcf6f8

Please sign in to comment.