Skip to content

Commit

Permalink
Address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Evangelink committed Aug 22, 2022
1 parent d006ddc commit e5e076d
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/vstest.console/Internal/ConsoleLogger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -765,7 +765,7 @@ private void TestRunCompleteHandler(object? sender, TestRunCompleteEventArgs e)
: $"({_targetFramework})";

var duration = GetFormattedDurationString(sourceSummary.Duration);
var sourceName = sd.Key.Split(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar).Last();
var sourceName = Path.GetFileName(sd.Key);

var outputLine = string.Format(CultureInfo.CurrentCulture, CommandLineResources.TestRunSummary,
resultString,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -624,7 +624,7 @@ public virtual string GetConsoleRunnerPath()
}
else if (IsNetCoreRunner())
{
var executablePath = TestUtils.IsWindows ? @"dotnet\dotnet.exe" : @"dotnet-linux/dotnet";
var executablePath = OSUtils.IsWindows ? @"dotnet\dotnet.exe" : @"dotnet-linux/dotnet";
consoleRunnerPath = Path.Combine(_testEnvironment.ToolsDirectory, executablePath);
}
else
Expand Down Expand Up @@ -676,7 +676,7 @@ public IVsTestConsoleWrapper GetVsTestConsoleWrapper(Dictionary<string, string?>
var consoleRunnerPath = IsNetCoreRunner()
? GetDotnetRunnerPath()
: GetConsoleRunnerPath();
var executablePath = TestUtils.IsWindows ? @"dotnet\dotnet.exe" : @"dotnet-linux/dotnet";
var executablePath = OSUtils.IsWindows ? @"dotnet\dotnet.exe" : @"dotnet-linux/dotnet";
var dotnetPath = Path.Combine(_testEnvironment.ToolsDirectory, executablePath);

if (!File.Exists(dotnetPath))
Expand Down Expand Up @@ -768,7 +768,7 @@ private void ExecutePatchedDotnet(string command, string args, out string stdOut

environmentVariables["DOTNET_MULTILEVEL_LOOKUP"] = "0";

var executablePath = TestUtils.IsWindows ? @"dotnet\dotnet.exe" : @"dotnet-linux/dotnet";
var executablePath = OSUtils.IsWindows ? @"dotnet\dotnet.exe" : @"dotnet-linux/dotnet";
var patchedDotnetPath = Path.Combine(_testEnvironment.TestArtifactsDirectory, executablePath);
ExecuteApplication(patchedDotnetPath, string.Join(" ", command, args), out stdOut, out stdError, out exitCode, environmentVariables);
}
Expand Down Expand Up @@ -952,7 +952,7 @@ protected static string GetDownloadedDotnetMuxerFromTools(string architecture)
architecture == "X86" ?
"dotnet_x86" :
$"dotnet",
$"dotnet{(TestUtils.IsWindows ? ".exe" : "")}");
$"dotnet{(OSUtils.IsWindows ? ".exe" : "")}");

Assert.IsTrue(File.Exists(path));

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

using System;

namespace Microsoft.TestPlatform.TestUtilities;

public static class TestUtils
public static class OSUtils
{
public static bool IsWindows { get; } = Environment.OSVersion.Platform.ToString().StartsWith("Win");
public static bool IsWindows { get; } = System.Environment.OSVersion.Platform.ToString().StartsWith("Win");
}
7 changes: 5 additions & 2 deletions test/vstest.console.UnitTests/Internal/ConsoleLoggerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -849,6 +849,8 @@ public void TestRunCompleteHandlerCorrectlySplitPathsForSourceName()
loggerEvents.RaiseTestResult(new(new(new("FQN4", new Uri("some://uri"), "C:\\\\MyApp4\\\\Tests\\\\MyApp4.Tests\\\\MyApp4.Tests.dll"))));
// Mix backslashes and forward slashes path
loggerEvents.RaiseTestResult(new(new(new("FQN5", new Uri("some://uri"), "C:\\MyApp5/Tests\\\\MyApp5.Tests///MyApp5.Tests.dll"))));
// UNC path
loggerEvents.RaiseTestResult(new(new(new("FQN6", new Uri("some://uri"), @"\\MyApp6\Tests\MyApp6.Tests\MyApp6.Tests.dll"))));

// Act
loggerEvents.CompleteTestRun(null, false, false, null, null, null, new TimeSpan(1, 0, 0, 0));
Expand All @@ -857,10 +859,11 @@ public void TestRunCompleteHandlerCorrectlySplitPathsForSourceName()
_mockOutput.Verify(o => o.WriteLine(string.Format(CultureInfo.CurrentCulture, CommandLineResources.TestRunSummaryAssemblyAndFramework, "MyApp1.Tests.dll", ""), OutputLevel.Information), Times.Once());
_mockOutput.Verify(o => o.WriteLine(string.Format(CultureInfo.CurrentCulture, CommandLineResources.TestRunSummaryAssemblyAndFramework, "MyApp2.Tests.dll", ""), OutputLevel.Information), Times.Once());
// On Linux and MAC we don't support backslash for path so source name will contain backslashes.
_mockOutput.Verify(o => o.WriteLine(string.Format(CultureInfo.CurrentCulture, CommandLineResources.TestRunSummaryAssemblyAndFramework, TestUtils.IsWindows ? "MyApp3.Tests.dll" : "MyApp3.Tests\\MyApp3.Tests.dll", ""), OutputLevel.Information), Times.Once());
_mockOutput.Verify(o => o.WriteLine(string.Format(CultureInfo.CurrentCulture, CommandLineResources.TestRunSummaryAssemblyAndFramework, OSUtils.IsWindows ? "MyApp3.Tests.dll" : "MyApp3.Tests\\MyApp3.Tests.dll", ""), OutputLevel.Information), Times.Once());
// On Linux and MAC we don't support backslash for path so source name will contain backslashes.
_mockOutput.Verify(o => o.WriteLine(string.Format(CultureInfo.CurrentCulture, CommandLineResources.TestRunSummaryAssemblyAndFramework, TestUtils.IsWindows ? "MyApp4.Tests.dll" : "C:\\MyApp4\\Tests\\MyApp4.Tests\\MyApp4.Tests.dll", ""), OutputLevel.Information), Times.Once());
_mockOutput.Verify(o => o.WriteLine(string.Format(CultureInfo.CurrentCulture, CommandLineResources.TestRunSummaryAssemblyAndFramework, OSUtils.IsWindows ? "MyApp4.Tests.dll" : "C:\\MyApp4\\Tests\\MyApp4.Tests\\MyApp4.Tests.dll", ""), OutputLevel.Information), Times.Once());
_mockOutput.Verify(o => o.WriteLine(string.Format(CultureInfo.CurrentCulture, CommandLineResources.TestRunSummaryAssemblyAndFramework, "MyApp5.Tests.dll", ""), OutputLevel.Information), Times.Once());
_mockOutput.Verify(o => o.WriteLine(string.Format(CultureInfo.CurrentCulture, CommandLineResources.TestRunSummaryAssemblyAndFramework, "MyApp6.Tests.dll", ""), OutputLevel.Information), Times.Once());
}

[TestMethod]
Expand Down

0 comments on commit e5e076d

Please sign in to comment.