Skip to content

Commit 84c8ad4

Browse files
committed
Added test folder identifier for ItDoesNotIncludeWindowsOnlyProjectTemplates and ItCanCreateItemTemplateWithProjectRestriction. Reverted GetTestDestinationDirectoryPath's hash algorithm. Skipped It_does_not_download_desktop_targeting_packs_on_unix with link to associated issue.
1 parent e063be9 commit 84c8ad4

File tree

4 files changed

+5
-23
lines changed

4 files changed

+5
-23
lines changed

test/EndToEnd.Tests/GivenUnixPlatform.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ public class GivenUnixPlatform(ITestOutputHelper log) : SdkTest(log)
1010
[InlineData("winforms")]
1111
public void ItDoesNotIncludeWindowsOnlyProjectTemplates(string template)
1212
{
13-
var directory = _testAssetsManager.CreateTestDirectory();
13+
var directory = _testAssetsManager.CreateTestDirectory(identifier: template);
1414

1515
new DotnetNewCommand(Log)
1616
.WithWorkingDirectory(directory.Path)

test/EndToEnd.Tests/GivenWeWantToRequireWindowsForDesktopApps.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ namespace EndToEnd.Tests
77
{
88
public class GivenWeWantToRequireWindowsForDesktopApps(ITestOutputHelper log) : SdkTest(log)
99
{
10-
[PlatformSpecificFact(TestPlatforms.Linux | TestPlatforms.OSX | TestPlatforms.FreeBSD)]
10+
[PlatformSpecificFact(TestPlatforms.Linux | TestPlatforms.OSX | TestPlatforms.FreeBSD, Skip = "https://github.com/dotnet/sdk/issues/42230")]
1111
public void It_does_not_download_desktop_targeting_packs_on_unix()
1212
{
1313
var testProjectCreator = new TestProjectCreator()

test/EndToEnd.Tests/ProjectBuildTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ public void ItCanCreateItemTemplateWithProjectRestriction(string templateName, s
263263
{ "VB", ".vb" }
264264
};
265265

266-
var directory = InstantiateProjectTemplate("classlib", language, withNoRestore: false);
266+
var directory = InstantiateProjectTemplate(templateName, language, withNoRestore: false);
267267
string projectDirectory = directory.Path;
268268
string expectedItemName = $"TestItem_{templateName}";
269269

test/Microsoft.NET.TestFramework/TestAssetsManager.cs

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,8 @@ public static string GetTestDestinationDirectoryPath(
187187
// We need to ensure the directory name isn't over 24 characters in length
188188
if (directoryName.Length > 24)
189189
{
190-
var hash = GetTruncatedHash(directoryName.ToString(), HashAlgorithmName.SHA256);
190+
using var sha256 = SHA256.Create();
191+
var hash = sha256.ComputeHash(Encoding.UTF8.GetBytes(directoryName.ToString()));
191192

192193
directoryName = directoryName.Remove(13, directoryName.Length - 13)
193194
.Append("---");
@@ -212,25 +213,6 @@ public static string GetTestDestinationDirectoryPath(
212213
#endif
213214

214215
return directoryPath;
215-
216-
// From: https://github.com/dotnet/arcade/blob/3b7e3a1a6d626eb51c5528987c1af484a98e4b5c/src/Microsoft.DotNet.Build.Tasks.Workloads/src/Utils.cs#L22
217-
static string GetTruncatedHash(string value, HashAlgorithmName hashName)
218-
{
219-
byte[] bytes = Encoding.UTF8.GetBytes(value);
220-
#pragma warning disable SYSLIB0045 // Cryptographic factory methods accepting an algorithm name are obsolete. Use the parameterless Create factory method on the algorithm type instead.
221-
HashAlgorithm algorithm = HashAlgorithm.Create(hashName.Name);
222-
#pragma warning restore SYSLIB0045
223-
StringBuilder sb = new();
224-
225-
foreach (byte b in algorithm.ComputeHash(bytes))
226-
{
227-
sb.Append(b.ToString("x2"));
228-
}
229-
230-
string result = sb.ToString();
231-
232-
return result.Substring(0, 32);
233-
}
234216
}
235217
}
236218
}

0 commit comments

Comments
 (0)