Skip to content

Commit

Permalink
Make tests unix friendly
Browse files Browse the repository at this point in the history
  • Loading branch information
cdmihai committed May 20, 2016
1 parent 83ea953 commit d4872ff
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 13 deletions.
8 changes: 3 additions & 5 deletions src/Utilities/UnitTests/ToolTask_Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ override protected int ExecuteTool(string pathToTool, string responseFileCommand
if (!NativeMethodsShared.IsWindows && string.IsNullOrEmpty(responseFileCommands) && string.IsNullOrEmpty(commandLineCommands))
{
// Unix makes sh interactive and it won't exit if there is nothing on the command line
commandLineCommands = "echo";
commandLineCommands = " -c \"echo\"";
}
int result = base.ExecuteTool(pathToTool, responseFileCommands, commandLineCommands);
StartInfo = base.GetProcessStartInfo(
Expand Down Expand Up @@ -196,7 +196,6 @@ public void Regress_Mutation_WarnIfCommandLineTooLong()
/// Exercise the code in ToolTask's default implementation of HandleExecutionErrors.
/// </summary>
[Fact]
[Trait("Category", "netcore-osx-failing")]
public void HandleExecutionErrorsWhenToolDoesntLogError()
{
using (MyTool t = new MyTool())
Expand Down Expand Up @@ -647,7 +646,6 @@ public void EnvironmentVariablesToToolTaskInvalid3()
/// Not set should not wipe out other env vars
/// </summary>
[Fact]
[Trait("Category", "netcore-osx-failing")]
[Trait("Category", "mono-osx-failing")]
public void EnvironmentVariablesToToolTaskNotSet()
{
Expand All @@ -661,9 +659,9 @@ public void EnvironmentVariablesToToolTaskNotSet()
Assert.Equal(
true,
#if FEATURE_PROCESSSTARTINFO_ENVIRONMENT
task.StartInfo.Environment[NativeMethodsShared.IsWindows ? "username" : "USER"].Length > 0);
task.StartInfo.Environment["PATH"].Length > 0);
#else
task.StartInfo.EnvironmentVariables[NativeMethodsShared.IsWindows ? "username" : "USER"].Length > 0);
task.StartInfo.EnvironmentVariables["PATH"].Length > 0);
#endif
}
}
Expand Down
17 changes: 9 additions & 8 deletions src/XMakeBuildEngine/UnitTests/ConsoleLogger_Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,10 @@ public class ConsoleLoggerTest
<Target Name='YYY' AfterTargets='XXX'>
</Target>
<Target Name='GGG' AfterTargets='XXX'>
<Exec Command='where.exe where'/>
<Exec Command='echo a'/>
</Target>
</Project>";


private class SimulatedConsole
{
private StringBuilder _simulatedConsole;
Expand Down Expand Up @@ -249,7 +248,7 @@ public void TestNoTargetNameOnMinimal()
/// </summary>
[Fact]
[Trait("Category", "mono-osx-failing")]
public void EmptyTargetsOnDetailedButNotNotmal()
public void EmptyTargetsOnDetailedButNotNormal()
{
SimulatedConsole sc = new SimulatedConsole();
ConsoleLogger logger = new ConsoleLogger(LoggerVerbosity.Normal, sc.Write, null, null);
Expand Down Expand Up @@ -300,44 +299,46 @@ public void EmptyTargetsOnDetailedButNotNotmal()
[Trait("Category", "mono-osx-failing")]
public void ShowCommandLineWithNormalVerbosity()
{
string command = "echo a";

SimulatedConsole sc = new SimulatedConsole();
ConsoleLogger logger = new ConsoleLogger(LoggerVerbosity.Normal, sc.Write, null, null);
logger.Parameters = "EnableMPLogging;ShowCommandLine";
ObjectModelHelpers.BuildProjectExpectSuccess(s_dummyProjectContents, logger);

string log = sc.ToString();
Assert.NotEqual(-1, log.IndexOf("where.exe where", StringComparison.OrdinalIgnoreCase));
Assert.NotEqual(-1, log.IndexOf(command, StringComparison.OrdinalIgnoreCase));

sc = new SimulatedConsole();
logger = new ConsoleLogger(LoggerVerbosity.Normal, sc.Write, null, null);
logger.Parameters = "EnableMPLogging;ShowCommandLine=true";
ObjectModelHelpers.BuildProjectExpectSuccess(s_dummyProjectContents, logger);

log = sc.ToString();
Assert.NotEqual(-1, log.IndexOf("where.exe where", StringComparison.OrdinalIgnoreCase));
Assert.NotEqual(-1, log.IndexOf(command, StringComparison.OrdinalIgnoreCase));

sc = new SimulatedConsole();
logger = new ConsoleLogger(LoggerVerbosity.Normal, sc.Write, null, null);
logger.Parameters = "EnableMPLogging;ShowCommandLine=false";
ObjectModelHelpers.BuildProjectExpectSuccess(s_dummyProjectContents, logger);

log = sc.ToString();
Assert.Equal(-1, log.IndexOf("where.exe where", StringComparison.OrdinalIgnoreCase));
Assert.Equal(-1, log.IndexOf(command, StringComparison.OrdinalIgnoreCase));

sc = new SimulatedConsole();
logger = new ConsoleLogger(LoggerVerbosity.Normal, sc.Write, null, null);
logger.Parameters = "EnableMPLogging;ShowCommandLine=NotAbool";
ObjectModelHelpers.BuildProjectExpectSuccess(s_dummyProjectContents, logger);
log = sc.ToString();
Assert.Equal(-1, log.IndexOf("where.exe where", StringComparison.OrdinalIgnoreCase));
Assert.Equal(-1, log.IndexOf(command, StringComparison.OrdinalIgnoreCase));

sc = new SimulatedConsole();
logger = new ConsoleLogger(LoggerVerbosity.Normal, sc.Write, null, null);
logger.Parameters = "EnableMPLogging";
ObjectModelHelpers.BuildProjectExpectSuccess(s_dummyProjectContents, logger);

log = sc.ToString();
Assert.NotEqual(-1, log.IndexOf("where.exe where", StringComparison.OrdinalIgnoreCase));
Assert.NotEqual(-1, log.IndexOf(command, StringComparison.OrdinalIgnoreCase));
}

/// <summary>
Expand Down

0 comments on commit d4872ff

Please sign in to comment.