enable passing config to dotnet-test

This commit is contained in:
Piotr Puszkiewicz 2016-02-05 13:26:12 -08:00
parent afc0d45e2e
commit f51b9fb337
3 changed files with 18 additions and 15 deletions

View file

@ -33,7 +33,7 @@ cp -rec -Force "$RepoRoot\test\TestProjects\*" "$TestBinRoot\TestProjects"
$TestProjects | foreach {
# This is a workaroudn for issue #1184, where dotnet test needs to be executed from the folder containing the project.json.
pushd "$RepoRoot\test\$($_.ProjectName)"
dotnet test -xml "$TestBinRoot\$($_.ProjectName)-testResults.xml" -notrait category=failing
dotnet test -c "$Configuration" -xml "$TestBinRoot\$($_.ProjectName)-testResults.xml" -notrait category=failing
popd
$exitCode = $LastExitCode

View file

@ -33,7 +33,7 @@ for project in $TestProjects
do
# This is a workaroudn for issue #1184, where dotnet test needs to be executed from the folder containing the project.json.
pushd "$REPOROOT/test/$project"
dotnet test -xml "$TEST_BIN_ROOT\$project-testResults.xml" -notrait category=failing
dotnet test -c "$CONFIGURATION" -xml "$TEST_BIN_ROOT\$project-testResults.xml" -notrait category=failing
popd
exitCode=$?

View file

@ -33,6 +33,7 @@ namespace Microsoft.DotNet.Tools.Test
var parentProcessIdOption = app.Option("--parentProcessId", "Used by IDEs to specify their process ID. Test will exit if the parent process does.", CommandOptionType.SingleValue);
var portOption = app.Option("--port", "Used by IDEs to specify a port number to listen for a connection.", CommandOptionType.SingleValue);
var configurationOption = app.Option("-c|--configuration <CONFIGURATION>", "Configuration under which to build", CommandOptionType.SingleValue);
var projectPath = app.Argument("<PROJECT>", "The project to test, defaults to the current directory. Can be a path to a project.json or a project directory.");
app.OnExecute(() =>
@ -58,6 +59,8 @@ namespace Microsoft.DotNet.Tools.Test
var testRunner = projectContext.ProjectFile.TestRunner;
var configuration = configurationOption.Value() ?? Constants.DefaultConfiguration;
if (portOption.HasValue())
{
int port;
@ -67,11 +70,11 @@ namespace Microsoft.DotNet.Tools.Test
throw new InvalidOperationException($"{portOption.Value()} is not a valid port number.");
}
return RunDesignTime(port, projectContext, testRunner);
return RunDesignTime(port, projectContext, testRunner, configuration);
}
else
{
return RunConsole(projectContext, app, testRunner);
return RunConsole(projectContext, app, testRunner, configuration);
}
}
catch (InvalidOperationException ex)
@ -90,9 +93,9 @@ namespace Microsoft.DotNet.Tools.Test
return app.Execute(args);
}
private static int RunConsole(ProjectContext projectContext, CommandLineApplication app, string testRunner)
private static int RunConsole(ProjectContext projectContext, CommandLineApplication app, string testRunner, string configuration)
{
var commandArgs = new List<string> { projectContext.GetOutputPathCalculator().GetAssemblyPath(Constants.DefaultConfiguration) };
var commandArgs = new List<string> { projectContext.GetOutputPathCalculator().GetAssemblyPath(configuration) };
commandArgs.AddRange(app.RemainingArguments);
return Command.CreateDotNet($"{GetCommandName(testRunner)}", commandArgs, projectContext.TargetFramework)
@ -102,20 +105,20 @@ namespace Microsoft.DotNet.Tools.Test
.ExitCode;
}
private static int RunDesignTime(int port, ProjectContext projectContext, string testRunner)
private static int RunDesignTime(int port, ProjectContext projectContext, string testRunner, string configuration)
{
Console.WriteLine("Listening on port {0}", port);
using (var channel = ReportingChannel.ListenOn(port))
{
Console.WriteLine("Client accepted {0}", channel.Socket.LocalEndPoint);
HandleDesignTimeMessages(projectContext, testRunner, channel);
HandleDesignTimeMessages(projectContext, testRunner, channel, configuration);
return 0;
}
}
private static void HandleDesignTimeMessages(ProjectContext projectContext, string testRunner, ReportingChannel channel)
private static void HandleDesignTimeMessages(ProjectContext projectContext, string testRunner, ReportingChannel channel, string configuration)
{
try
{
@ -131,11 +134,11 @@ namespace Microsoft.DotNet.Tools.Test
if (message.MessageType == "TestDiscovery.Start")
{
HandleTestDiscoveryStartMessage(testRunner, channel, projectContext);
HandleTestDiscoveryStartMessage(testRunner, channel, projectContext, configuration);
}
else if (message.MessageType == "TestExecution.Start")
{
HandleTestExecutionStartMessage(testRunner, message, channel, projectContext);
HandleTestExecutionStartMessage(testRunner, message, channel, projectContext, configuration);
}
else
{
@ -167,11 +170,11 @@ namespace Microsoft.DotNet.Tools.Test
});
}
private static void HandleTestDiscoveryStartMessage(string testRunner, ReportingChannel channel, ProjectContext projectContext)
private static void HandleTestDiscoveryStartMessage(string testRunner, ReportingChannel channel, ProjectContext projectContext, string configuration)
{
TestHostTracing.Source.TraceInformation("Starting Discovery");
var commandArgs = new List<string> { projectContext.GetOutputPathCalculator().GetAssemblyPath(Constants.DefaultConfiguration) };
var commandArgs = new List<string> { projectContext.GetOutputPathCalculator().GetAssemblyPath(configuration) };
commandArgs.AddRange(new[]
{
@ -189,11 +192,11 @@ namespace Microsoft.DotNet.Tools.Test
TestHostTracing.Source.TraceInformation("Completed Discovery");
}
private static void HandleTestExecutionStartMessage(string testRunner, Message message, ReportingChannel channel, ProjectContext projectContext)
private static void HandleTestExecutionStartMessage(string testRunner, Message message, ReportingChannel channel, ProjectContext projectContext, string configuration)
{
TestHostTracing.Source.TraceInformation("Starting Execution");
var commandArgs = new List<string> { projectContext.GetOutputPathCalculator().GetAssemblyPath(Constants.DefaultConfiguration) };
var commandArgs = new List<string> { projectContext.GetOutputPathCalculator().GetAssemblyPath(configuration) };
commandArgs.AddRange(new[]
{