-
Notifications
You must be signed in to change notification settings - Fork 568
[TrimmableTypeMap] Integration parity tests #10827
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
simonrozsival
wants to merge
7
commits into
dotnet:main
Choose a base branch
from
simonrozsival:dev/simonrozsival/ttm-slice-integration
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
6e32d8d
[TrimmableTypeMap] Integration parity test slice
simonrozsival 947cb54
[TrimmableTypeMap] Wire integration tests into solution and CI
simonrozsival c25d830
Update build-tools/automation/yaml-templates/build-windows-steps.yaml
jonathanpeppers 42d36ad
[TrimmableTypeMap] Expose scanner internals to integration tests
simonrozsival 1592d1f
[TrimmableTypeMap][Tests] Simplify scanner comparison tests
simonrozsival 29e2659
[TrimmableTypeMap][Tests] Move diffing out of facts
simonrozsival 5d7b928
[TrimmableTypeMap][Tests] Split test helpers into separate files
simonrozsival File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
src/Microsoft.Android.Sdk.TrimmableTypeMap/Properties/AssemblyInfo.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| using System.Runtime.CompilerServices; | ||
|
|
||
| [assembly: InternalsVisibleTo ("Microsoft.Android.Sdk.TrimmableTypeMap.IntegrationTests, PublicKey=0024000004800000940000000602000000240000525341310004000011000000438ac2a5acfbf16cbd2b2b47a62762f273df9cb2795ceccdf77d10bf508e69e7a362ea7a45455bbf3ac955e1f2e2814f144e5d817efc4c6502cc012df310783348304e3ae38573c6d658c234025821fda87a0be8a0d504df564e2c93b2b878925f42503e9d54dfef9f9586d9e6f38a305769587b1de01f6c0410328b2c9733db")] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
173 changes: 173 additions & 0 deletions
173
tests/Microsoft.Android.Sdk.TrimmableTypeMap.IntegrationTests/ComparisonDiffHelper.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,173 @@ | ||
| using System.Collections.Generic; | ||
| using System.Linq; | ||
|
|
||
| namespace Microsoft.Android.Sdk.TrimmableTypeMap.IntegrationTests; | ||
|
|
||
| static class ComparisonDiffHelper | ||
| { | ||
| public static List<string> CompareBaseJavaNames ( | ||
| Dictionary<string, TypeComparisonData> legacyData, | ||
| Dictionary<string, TypeComparisonData> newData) | ||
| { | ||
| var allManagedNames = new HashSet<string> (legacyData.Keys); | ||
| allManagedNames.IntersectWith (newData.Keys); | ||
|
|
||
| var mismatches = new List<string> (); | ||
|
|
||
| foreach (var managedName in allManagedNames.OrderBy (n => n, System.StringComparer.Ordinal)) { | ||
| var legacy = legacyData [managedName]; | ||
| var newInfo = newData [managedName]; | ||
|
|
||
| if (legacy.BaseJavaName == newInfo.BaseJavaName) { | ||
| continue; | ||
| } | ||
|
|
||
| if (legacy.BaseJavaName == null && newInfo.BaseJavaName != null && managedName.Contains ('`')) { | ||
| continue; | ||
| } | ||
|
|
||
| if (legacy.BaseJavaName == null && newInfo.BaseJavaName != null && newInfo.DoNotGenerateAcw) { | ||
| continue; | ||
| } | ||
|
|
||
| if (legacy.BaseJavaName != null && newInfo.BaseJavaName == null && | ||
| legacy.BaseJavaName == legacy.JavaName) { | ||
| continue; | ||
| } | ||
|
|
||
| mismatches.Add ($"{managedName}: legacy='{legacy.BaseJavaName ?? "(null)"}' new='{newInfo.BaseJavaName ?? "(null)"}'"); | ||
| } | ||
|
|
||
| return mismatches; | ||
| } | ||
|
|
||
| public static (List<string> missingInterfaces, List<string> extraInterfaces) CompareImplementedInterfaces ( | ||
| Dictionary<string, TypeComparisonData> legacyData, | ||
| Dictionary<string, TypeComparisonData> newData) | ||
| { | ||
| var allManagedNames = new HashSet<string> (legacyData.Keys); | ||
| allManagedNames.IntersectWith (newData.Keys); | ||
|
|
||
| var missingInterfaces = new List<string> (); | ||
| var extraInterfaces = new List<string> (); | ||
|
|
||
| foreach (var managedName in allManagedNames.OrderBy (n => n, System.StringComparer.Ordinal)) { | ||
| var legacy = legacyData [managedName]; | ||
| var newInfo = newData [managedName]; | ||
|
|
||
| var legacySet = new HashSet<string> (legacy.ImplementedInterfaces, System.StringComparer.Ordinal); | ||
| var newSet = new HashSet<string> (newInfo.ImplementedInterfaces, System.StringComparer.Ordinal); | ||
|
|
||
| foreach (var iface in legacySet.Except (newSet)) { | ||
| missingInterfaces.Add ($"{managedName}: missing '{iface}'"); | ||
| } | ||
|
|
||
| foreach (var iface in newSet.Except (legacySet)) { | ||
| extraInterfaces.Add ($"{managedName}: extra '{iface}'"); | ||
| } | ||
| } | ||
|
|
||
| return (missingInterfaces, extraInterfaces); | ||
| } | ||
|
|
||
| public static (List<string> presenceMismatches, List<string> declaringTypeMismatches, List<string> styleMismatches) CompareActivationCtors ( | ||
| Dictionary<string, TypeComparisonData> legacyData, | ||
| Dictionary<string, TypeComparisonData> newData) | ||
| { | ||
| var allManagedNames = new HashSet<string> (legacyData.Keys); | ||
| allManagedNames.IntersectWith (newData.Keys); | ||
|
|
||
| var presenceMismatches = new List<string> (); | ||
| var declaringTypeMismatches = new List<string> (); | ||
| var styleMismatches = new List<string> (); | ||
|
|
||
| foreach (var managedName in allManagedNames.OrderBy (n => n, System.StringComparer.Ordinal)) { | ||
| var legacy = legacyData [managedName]; | ||
| var newInfo = newData [managedName]; | ||
|
|
||
| if (legacy.HasActivationCtor != newInfo.HasActivationCtor) { | ||
| presenceMismatches.Add ($"{managedName}: legacy.has={legacy.HasActivationCtor} new.has={newInfo.HasActivationCtor}"); | ||
| continue; | ||
| } | ||
|
|
||
| if (!legacy.HasActivationCtor) { | ||
| continue; | ||
| } | ||
|
|
||
| if (legacy.ActivationCtorDeclaringType != newInfo.ActivationCtorDeclaringType) { | ||
| declaringTypeMismatches.Add ($"{managedName}: legacy='{legacy.ActivationCtorDeclaringType}' new='{newInfo.ActivationCtorDeclaringType}'"); | ||
| } | ||
|
|
||
| if (legacy.ActivationCtorStyle != newInfo.ActivationCtorStyle) { | ||
| styleMismatches.Add ($"{managedName}: legacy='{legacy.ActivationCtorStyle}' new='{newInfo.ActivationCtorStyle}'"); | ||
| } | ||
| } | ||
|
|
||
| return (presenceMismatches, declaringTypeMismatches, styleMismatches); | ||
| } | ||
|
|
||
| public static (List<string> missingCtors, List<string> extraCtors) CompareJavaConstructors ( | ||
| Dictionary<string, TypeComparisonData> legacyData, | ||
| Dictionary<string, TypeComparisonData> newData) | ||
| { | ||
| var allManagedNames = new HashSet<string> (legacyData.Keys); | ||
| allManagedNames.IntersectWith (newData.Keys); | ||
|
|
||
| var missingCtors = new List<string> (); | ||
| var extraCtors = new List<string> (); | ||
|
|
||
| foreach (var managedName in allManagedNames.OrderBy (n => n, System.StringComparer.Ordinal)) { | ||
| var legacy = legacyData [managedName]; | ||
| var newInfo = newData [managedName]; | ||
|
|
||
| var legacySet = new HashSet<string> (legacy.JavaConstructorSignatures, System.StringComparer.Ordinal); | ||
| var newSet = new HashSet<string> (newInfo.JavaConstructorSignatures, System.StringComparer.Ordinal); | ||
|
|
||
| foreach (var sig in legacySet.Except (newSet)) { | ||
| missingCtors.Add ($"{managedName}: missing '<init>{sig}'"); | ||
| } | ||
|
|
||
| foreach (var sig in newSet.Except (legacySet)) { | ||
| extraCtors.Add ($"{managedName}: extra '<init>{sig}'"); | ||
| } | ||
| } | ||
|
|
||
| return (missingCtors, extraCtors); | ||
| } | ||
|
|
||
| public static (List<string> interfaceMismatches, List<string> abstractMismatches, List<string> genericMismatches, List<string> acwMismatches) CompareTypeFlags ( | ||
| Dictionary<string, TypeComparisonData> legacyData, | ||
| Dictionary<string, TypeComparisonData> newData) | ||
| { | ||
| var allManagedNames = new HashSet<string> (legacyData.Keys); | ||
| allManagedNames.IntersectWith (newData.Keys); | ||
|
|
||
| var interfaceMismatches = new List<string> (); | ||
| var abstractMismatches = new List<string> (); | ||
| var genericMismatches = new List<string> (); | ||
| var acwMismatches = new List<string> (); | ||
|
|
||
| foreach (var managedName in allManagedNames.OrderBy (n => n, System.StringComparer.Ordinal)) { | ||
| var legacy = legacyData [managedName]; | ||
| var newInfo = newData [managedName]; | ||
|
|
||
| if (legacy.IsInterface != newInfo.IsInterface) { | ||
| interfaceMismatches.Add ($"{managedName}: legacy={legacy.IsInterface} new={newInfo.IsInterface}"); | ||
| } | ||
|
|
||
| if (legacy.IsAbstract != newInfo.IsAbstract) { | ||
| abstractMismatches.Add ($"{managedName}: legacy={legacy.IsAbstract} new={newInfo.IsAbstract}"); | ||
| } | ||
|
|
||
| if (legacy.IsGenericDefinition != newInfo.IsGenericDefinition) { | ||
| genericMismatches.Add ($"{managedName}: legacy={legacy.IsGenericDefinition} new={newInfo.IsGenericDefinition}"); | ||
| } | ||
|
|
||
| if (legacy.DoNotGenerateAcw != newInfo.DoNotGenerateAcw) { | ||
| acwMismatches.Add ($"{managedName}: legacy={legacy.DoNotGenerateAcw} new={newInfo.DoNotGenerateAcw}"); | ||
| } | ||
| } | ||
|
|
||
| return (interfaceMismatches, abstractMismatches, genericMismatches, acwMismatches); | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.