Skip to content

Commit

Permalink
Move TATF based tests to MSTest (#4348)
Browse files Browse the repository at this point in the history
  • Loading branch information
Evangelink authored Dec 17, 2024
1 parent 09af447 commit e733620
Show file tree
Hide file tree
Showing 194 changed files with 3,338 additions and 2,817 deletions.
6 changes: 4 additions & 2 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
</PropertyGroup>
<PropertyGroup Label="Test dependencies">
<MicrosoftCodeAnalysisAnalyzerTestingVersion>1.1.3-beta1.24423.1</MicrosoftCodeAnalysisAnalyzerTestingVersion>
<MSTestVersion>3.8.0-preview.24616.6</MSTestVersion>
</PropertyGroup>
<ItemGroup Label="Analyzers">
<PackageVersion Include="Microsoft.CodeAnalysis.BannedApiAnalyzers" Version="$(MicrosoftCodeAnalysisBannedApiAnalyzersVersion)" />
Expand Down Expand Up @@ -65,12 +66,13 @@
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp.CodeFix.Testing" Version="$(MicrosoftCodeAnalysisAnalyzerTestingVersion)" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp.CodeRefactoring.Testing" Version="$(MicrosoftCodeAnalysisAnalyzerTestingVersion)" />
<PackageVersion Include="Microsoft.Extensions.FileSystemGlobbing" Version="9.0.0" />
<PackageVersion Include="Microsoft.Testing.Internal.Framework" Version="$(MicrosoftTestingInternalFrameworkVersion)" />
<PackageVersion Include="Microsoft.Testing.Internal.Framework.SourceGeneration" Version="$(MicrosoftTestingInternalFrameworkVersion)" />
<PackageVersion Include="Microsoft.TestPlatform" Version="$(MicrosoftNETTestSdkVersion)" />
<!-- Pinned to 4.18.4 for security -->
<PackageVersion Include="Moq" Version="4.18.4" />
<PackageVersion Include="MSBuild.StructuredLogger" Version="2.2.386" />
<PackageVersion Include="MSTest.Analyzers" Version="$(MSTestVersion)" />
<PackageVersion Include="MSTest.TestAdapter" Version="$(MSTestVersion)" />
<PackageVersion Include="MSTest.TestFramework" Version="$(MSTestVersion)" />
<PackageVersion Include="Newtonsoft.Json" Version="13.0.3" />
<!-- CVE-2024-0057 / Transitive deps of code analysis testing packages -->
<PackageVersion Include="NuGet.Packaging" Version="6.12.1" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,11 @@

using Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.Data;
using Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.Extensions;
using Microsoft.VisualStudio.TestTools.UnitTesting;
#endif
using Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.Interface;
using Microsoft.VisualStudio.TestTools.UnitTesting;

using ITestDataSource = Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.Interface.ITestDataSource;
using UTF = Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices;

Expand All @@ -36,9 +35,9 @@ namespace Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices;
public class TestDataSource : ITestDataSource
{
#if NETFRAMEWORK
public IEnumerable<object>? GetData(UTF.ITestMethod testMethodInfo, ITestContext testContext)
public IEnumerable<object>? GetData(ITestMethod testMethodInfo, ITestContext testContext)
#else
IEnumerable<object>? ITestDataSource.GetData(UTF.ITestMethod testMethodInfo, ITestContext testContext)
IEnumerable<object>? ITestDataSource.GetData(ITestMethod testMethodInfo, ITestContext testContext)
#endif
{
#if NETFRAMEWORK
Expand All @@ -49,12 +48,12 @@ public class TestDataSource : ITestDataSource
Path.GetDirectoryName(new Uri(testMethodInfo.MethodInfo.Module.Assembly.CodeBase).LocalPath),
];

List<UTF.TestResult> dataRowResults = [];
List<TestResult> dataRowResults = [];

// Connect to data source.
TestDataConnectionFactory factory = new();

GetConnectionProperties(testMethodInfo.GetAttributes<UTF.DataSourceAttribute>(false)[0], out string providerNameInvariant, out string? connectionString, out string? tableName, out UTF.DataAccessMethod dataAccessMethod);
GetConnectionProperties(testMethodInfo.GetAttributes<DataSourceAttribute>(false)[0], out string providerNameInvariant, out string? connectionString, out string? tableName, out DataAccessMethod dataAccessMethod);

try
{
Expand Down Expand Up @@ -103,7 +102,7 @@ public class TestDataSource : ITestDataSource
/// <param name="dataAccessMethod">The data access method.</param>
/// <param name="length">Number of permutations.</param>
/// <returns>Permutations.</returns>
private static IEnumerable<int> GetPermutation(UTF.DataAccessMethod dataAccessMethod, int length)
private static IEnumerable<int> GetPermutation(DataAccessMethod dataAccessMethod, int length)
{
switch (dataAccessMethod)
{
Expand All @@ -127,8 +126,8 @@ private static IEnumerable<int> GetPermutation(UTF.DataAccessMethod dataAccessMe
/// <param name="connectionString">The connection string.</param>
/// <param name="tableName">The table name.</param>
/// <param name="dataAccessMethod">The data access method.</param>
private static void GetConnectionProperties(UTF.DataSourceAttribute dataSourceAttribute, out string providerNameInvariant,
out string? connectionString, out string? tableName, out UTF.DataAccessMethod dataAccessMethod)
private static void GetConnectionProperties(DataSourceAttribute dataSourceAttribute, out string providerNameInvariant,
out string? connectionString, out string? tableName, out DataAccessMethod dataAccessMethod)
{
if (StringEx.IsNullOrEmpty(dataSourceAttribute.DataSourceSettingName))
{
Expand All @@ -139,7 +138,7 @@ private static void GetConnectionProperties(UTF.DataSourceAttribute dataSourceAt
return;
}

UTF.DataSourceElement element = TestConfiguration.ConfigurationSection.DataSources[dataSourceAttribute.DataSourceSettingName]
DataSourceElement element = TestConfiguration.ConfigurationSection.DataSources[dataSourceAttribute.DataSourceSettingName]
#pragma warning disable CA2201 // Do not raise reserved exception types
?? throw new Exception(string.Format(CultureInfo.CurrentCulture, Resource.UTA_DataSourceConfigurationSectionMissing, dataSourceAttribute.DataSourceSettingName));
#pragma warning restore CA2201 // Do not raise reserved exception types
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public virtual string GetNextIterationDirectoryName(string parentDirectoryName,
/// Returns empty string on error when specified to continue the run on error,
/// throw on error when specified to abort the run on error.
/// </returns>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes", Justification = "Requirement is to handle all kinds of user exceptions and message appropriately.")]
[SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes", Justification = "Requirement is to handle all kinds of user exceptions and message appropriately.")]
public virtual string CopyFileOverwrite(string source, string destination, out string? warning)
{
DebugEx.Assert(!StringEx.IsNullOrEmpty(source), "source should not be null.");
Expand Down Expand Up @@ -224,7 +224,7 @@ public static string TryConvertPathToRelative(string path, string rootDir)
/// them.
/// </summary>
/// <param name="filePath">The root directory to clear.</param>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes", Justification = "Requirement is to handle all kinds of user exceptions and message appropriately.")]
[SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes", Justification = "Requirement is to handle all kinds of user exceptions and message appropriately.")]
public virtual void DeleteDirectories(string filePath)
{
Guard.NotNullOrWhiteSpace(filePath);
Expand Down Expand Up @@ -255,7 +255,7 @@ public virtual void DeleteDirectories(string filePath)
/// </summary>
/// <param name="path">path to symbols file.</param>
/// <returns>Pdb file name or null if non-existent.</returns>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes", Justification = "Requirement is to handle all kinds of user exceptions and message appropriately.")]
[SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes", Justification = "Requirement is to handle all kinds of user exceptions and message appropriately.")]
private static string? GetSymbolsFileName(string? path)
{
if (StringEx.IsNullOrEmpty(path) || path.IndexOfAny(Path.GetInvalidPathChars()) != -1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,12 +171,12 @@ private bool TryGetOrCreateTypeByMetadataNameSlow(
}

/// <summary>
/// Determines if <paramref name="typeSymbol"/> is a <see cref="System.Threading.Tasks.Task{TResult}"/> with its type
/// Determines if <paramref name="typeSymbol"/> is a <see cref="Task{TResult}"/> with its type
/// argument satisfying <paramref name="typeArgumentPredicate"/>.
/// </summary>
/// <param name="typeSymbol">Type potentially representing a <see cref="System.Threading.Tasks.Task{TResult}"/>.</param>
/// <param name="typeSymbol">Type potentially representing a <see cref="Task{TResult}"/>.</param>
/// <param name="typeArgumentPredicate">Predicate to check the <paramref name="typeSymbol"/>'s type argument.</param>
/// <returns>True if <paramref name="typeSymbol"/> is a <see cref="System.Threading.Tasks.Task{TResult}"/> with its
/// <returns>True if <paramref name="typeSymbol"/> is a <see cref="Task{TResult}"/> with its
/// type argument satisfying <paramref name="typeArgumentPredicate"/>, false otherwise.</returns>
internal bool IsTaskOfType([NotNullWhen(returnValue: true)] ITypeSymbol? typeSymbol, Func<ITypeSymbol, bool> typeArgumentPredicate)
=> typeSymbol != null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ This package extends Microsoft Testing Platform to provide a crash dump function

<ItemGroup>
<InternalsVisibleTo Include="Microsoft.Testing.Extensions.VSTestBridge" Key="$(VsPublicKey)" />
<InternalsVisibleTo Include="Microsoft.Testing.Internal.Framework" Key="$(VsPublicKey)" />
<InternalsVisibleTo Include="Microsoft.Testing.Extensions.HangDump" Key="$(VsPublicKey)" />
<InternalsVisibleTo Include="Microsoft.Testing.Extensions.UnitTests" Key="$(VsPublicKey)" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ This package extends Microsoft Testing Platform to provide TRX test reports.]]>
<ItemGroup>
<InternalsVisibleTo Include="Microsoft.Testing.Extensions.UnitTests" Key="$(VsPublicKey)" />
<InternalsVisibleTo Include="Microsoft.Testing.Extensions.VSTestBridge" Key="$(VsPublicKey)" />
<InternalsVisibleTo Include="Microsoft.Testing.Internal.Framework" Key="$(VsPublicKey)" />
<InternalsVisibleTo Include="Microsoft.Testing.Extensions.HangDump" Key="$(VsPublicKey)" />
<InternalsVisibleTo Include="Microsoft.Testing.Extensions.UnitTests" Key="$(VsPublicKey)" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
</PropertyGroup>

<ItemGroup>
<InternalsVisibleTo Include="Microsoft.Testing.Internal.Framework" Key="$(VsPublicKey)" />
<InternalsVisibleTo Include="Microsoft.Testing.Internal.Framework.UnitTests" Key="$(VsPublicKey)" />
<InternalsVisibleTo Include="MSTest.TestAnywhereAdapter" Key="$(VsPublicKey)" />
<InternalsVisibleTo Include="Microsoft.Testing.Extensions.VSTestBridge.UnitTests" Key="$(VsPublicKey)" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,14 +195,15 @@ private void AddProperty(string name, string value)
{
if (!_filterDictionaryBuilder.TryGetValue(name, out ImmutableHashSet<string>.Builder? values))
{
values = ImmutableHashSet.CreateBuilder<string>(StringComparer.OrdinalIgnoreCase);
values = ImmutableHashSet.CreateBuilder(StringComparer.OrdinalIgnoreCase)!;
_filterDictionaryBuilder.Add(name, values);
}

values.Add(value);
}

internal FastFilter? ToFastFilter() => ContainsValidFilter
internal FastFilter? ToFastFilter()
=> ContainsValidFilter
? new FastFilter(
_filterDictionaryBuilder.ToImmutableDictionary(kvp => kvp.Key, kvp => (ISet<string>)_filterDictionaryBuilder[kvp.Key].ToImmutable()),
_fastFilterOperation,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,6 @@ This package provides the core platform and the .NET implementation of the proto
<InternalsVisibleTo Include="Microsoft.Testing.Extensions.VSTestBridge" Key="$(VsPublicKey)" />
<InternalsVisibleTo Include="Microsoft.Testing.Extensions.VSTestBridge.TestAdapter" Key="$(VsPublicKey)" />
<InternalsVisibleTo Include="Microsoft.Testing.Extensions.VSTestBridge.UnitTests" Key="$(VsPublicKey)" />
<InternalsVisibleTo Include="Microsoft.Testing.Internal.Framework" Key="$(VsPublicKey)" />
<InternalsVisibleTo Include="Microsoft.Testing.Internal.Framework.UnitTests" Key="$(VsPublicKey)" />
<InternalsVisibleTo Include="Microsoft.Testing.Platform.Acceptance.IntegrationTests" Key="$(VsPublicKey)" />
<InternalsVisibleTo Include="Microsoft.Testing.Platform.MSBuild" Key="$(VsPublicKey)" />
<InternalsVisibleTo Include="Microsoft.Testing.Platform.UnitTests" Key="$(VsPublicKey)" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,10 +218,10 @@ static SerializerUtilities()
#if NETCOREAPP
properties[namedKvpStringProperty.Name] = namedKvpStringProperty.Pairs;
#else
Jsonite.JsonArray collection = [];
JsonArray collection = [];
foreach (KeyValuePair<string, string> item in namedKvpStringProperty.Pairs)
{
Jsonite.JsonObject o = new()
JsonObject o = new()
{
{ item.Key, item.Value },
};
Expand Down Expand Up @@ -419,10 +419,10 @@ static SerializerUtilities()
#if NETCOREAPP
values[JsonRpcStrings.EnvironmentVariables] = ev.EnvironmentVariables;
#else
Jsonite.JsonArray collection = [];
JsonArray collection = [];
foreach (KeyValuePair<string, string?> item in ev.EnvironmentVariables)
{
Jsonite.JsonObject o = new()
JsonObject o = new()
{
{ item.Key, item.Value },
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public sealed class TestConfigurationSection : ConfigurationSection
/// Gets the collection of properties.
/// </summary>
/// <returns>
/// The <see cref="System.Configuration.ConfigurationPropertyCollection"/> of properties for the element.
/// The <see cref="ConfigurationPropertyCollection"/> of properties for the element.
/// </returns>
protected override ConfigurationPropertyCollection Properties { get; } = [DataSourcesValue];
}
Expand Down
Loading

0 comments on commit e733620

Please sign in to comment.