-
Notifications
You must be signed in to change notification settings - Fork 564
[tests] Be more flexible when parsing build-tools versions #4354
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
Conversation
Context: https://devdiv.visualstudio.com/DevDiv/_build/results?buildId=3520928&view=ms.vss-test-web.build-test-results-tab&runId=11613622&resultId=100500&paneView=debug Xamarin.Android.Build.Task tests which attempt to look up the path to aapt/aapt2 recently started failing on the Azure Pipelines hosted macOS machine pool [0]. I suspect this is caused by a preview version of tools ending up on the machine. I think we can be a bit more lenient when locating the latest version of build-tools by instead using a string comparison. This will also allow the relevant tests to use a preview version of build-tools if they exist. Additional logging has also been added to confirm this hypothesis. [0]: System.FormatException : Input string was not in a correct format. at System.Number.ThrowOverflowOrFormatException (System.Boolean overflow, System.String overflowResourceKey) [0x0001a] in <8855e4c75b1445438dde4104dd4134bb>:0 at System.Number.ParseInt32 (System.ReadOnlySpan`1[T] value, System.Globalization.NumberStyles styles, System.Globalization.NumberFormatInfo info) [0x00016] in <8855e4c75b1445438dde4104dd4134bb>:0 at System.Int32.Parse (System.ReadOnlySpan`1[T] s, System.Globalization.NumberStyles style, System.IFormatProvider provider) [0x0000e] in <8855e4c75b1445438dde4104dd4134bb>:0 at System.Version.TryParseComponent (System.ReadOnlySpan`1[T] component, System.String componentName, System.Boolean throwOnFailure, System.Int32& parsedComponent) [0x0000b] in <8855e4c75b1445438dde4104dd4134bb>:0 at System.Version.ParseVersion (System.ReadOnlySpan`1[T] input, System.Boolean throwOnFailure) [0x0011a] in <8855e4c75b1445438dde4104dd4134bb>:0 at System.Version.Parse (System.String input) [0x00014] in <8855e4c75b1445438dde4104dd4134bb>:0 at System.Version..ctor (System.String version) [0x00014] in <8855e4c75b1445438dde4104dd4134bb>:0 at Xamarin.Android.Build.Tests.BaseTest+<>c.<GetPathToLatestBuildTools>b__48_0 (System.String x) [0x00006] in <e6ad3936767d47cea783c180acfe7cf6>:0 at System.Linq.EnumerableSorter`2[TElement,TKey].ComputeKeys (TElement[] elements, System.Int32 count) [0x00010] in <89222f8e94f04b5cb12f2328985a10a8>:0 at System.Linq.EnumerableSorter`1[TElement].ComputeMap (TElement[] elements, System.Int32 count) [0x00000] in <89222f8e94f04b5cb12f2328985a10a8>:0 at System.Linq.EnumerableSorter`1[TElement].Sort (TElement[] elements, System.Int32 count) [0x00000] in <89222f8e94f04b5cb12f2328985a10a8>:0 at System.Linq.OrderedEnumerable`1[TElement].SortedMap (System.Linq.Buffer`1[TElement] buffer) [0x00006] in <89222f8e94f04b5cb12f2328985a10a8>:0 at System.Linq.OrderedEnumerable`1+<GetEnumerator>d__3[TElement].MoveNext () [0x0003d] in <89222f8e94f04b5cb12f2328985a10a8>:0 at Xamarin.Android.Build.Tests.BaseTest.GetPathToLatestBuildTools (System.String exe) [0x00061] in <e6ad3936767d47cea783c180acfe7cf6>:0 at Xamarin.Android.Build.Tests.BaseTest.GetPathToAapt () [0x00015] in <e6ad3936767d47cea783c180acfe7cf6>:0 at Xamarin.Android.Build.Tests.ManagedResourceParserTests.CompareAaptAndManagedParserOutputWithCustomIds () [0x000d2] in <e6ad3936767d47cea783c180acfe7cf6>:0
| { | ||
| var path = Path.Combine (AndroidSdkPath, "build-tools"); | ||
| foreach (var dir in Directory.GetDirectories (path, "*", SearchOption.TopDirectoryOnly).OrderByDescending (x => new Version (Path.GetFileName (x)))) { | ||
| foreach (var dir in Directory.GetDirectories (path, "*", SearchOption.TopDirectoryOnly).OrderByDescending (x => Path.GetFileName (x))) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pity this will fails when sorting { "2", "10" }, because it sorts "stringly", not numerically.
Fortunately this is unlikely to be a problem now, because we're likely to always have two digit numbers. (But when we start hitting Build-tools 100, watch out!)
Unfortunately, this also sorts { "29.0.0-rc2", "29.0.0-rc1", "29.0.0" } in that order, such that the -rc2 will be preferred first, over the "stable" 29.0.0 version.
| var path = Path.Combine (AndroidSdkPath, "build-tools"); | ||
| foreach (var dir in Directory.GetDirectories (path, "*", SearchOption.TopDirectoryOnly).OrderByDescending (x => new Version (Path.GetFileName (x)))) { | ||
| foreach (var dir in Directory.GetDirectories (path, "*", SearchOption.TopDirectoryOnly).OrderByDescending (x => Path.GetFileName (x))) { | ||
| TestContext.Out.WriteLine ($"Found build tools version: {dir}."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed!
Found build tools version: /Users/runner/Library/Android/sdk/build-tools/30.0.0-rc1.
Context: https://devdiv.visualstudio.com/DevDiv/_build/results?buildId=3520928&view=ms.vss-test-web.build-test-results-tab&runId=11613622&resultId=100500&paneView=debug The **Xamarin.Android.Build.Tests - macOS** job has started reporting some failures within the past couple of days: System.FormatException : Input string was not in a correct format. at System.Number.ThrowOverflowOrFormatException (System.Boolean overflow, System.String overflowResourceKey) at System.Number.ParseInt32 (System.ReadOnlySpan`1[T] value, System.Globalization.NumberStyles styles, System.Globalization.NumberFormatInfo info) at System.Int32.Parse (System.ReadOnlySpan`1[T] s, System.Globalization.NumberStyles style, System.IFormatProvider provider) at System.Version.TryParseComponent (System.ReadOnlySpan`1[T] component, System.String componentName, System.Boolean throwOnFailure, System.Int32& parsedComponent) at System.Version.ParseVersion (System.ReadOnlySpan`1[T] input, System.Boolean throwOnFailure) at System.Version.Parse (System.String input) at System.Version..ctor (System.String version) at Xamarin.Android.Build.Tests.BaseTest+<>c.<GetPathToLatestBuildTools>b__48_0 (System.String x) at System.Linq.EnumerableSorter`2[TElement,TKey].ComputeKeys (TElement[] elements, System.Int32 count) at System.Linq.EnumerableSorter`1[TElement].ComputeMap (TElement[] elements, System.Int32 count) at System.Linq.EnumerableSorter`1[TElement].Sort (TElement[] elements, System.Int32 count) at System.Linq.OrderedEnumerable`1[TElement].SortedMap (System.Linq.Buffer`1[TElement] buffer) at System.Linq.OrderedEnumerable`1+<GetEnumerator>d__3[TElement].MoveNext () at Xamarin.Android.Build.Tests.BaseTest.GetPathToLatestBuildTools (System.String exe) at Xamarin.Android.Build.Tests.BaseTest.GetPathToAapt () at Xamarin.Android.Build.Tests.ManagedResourceParserTests.CompareAaptAndManagedParserOutputWithCustomIds () What's happened is that somehow, for some reason, Build-tools 30.0.0-rc1 has been installed onto the build machine: $HOME/Library/Android/sdk/build-tools/30.0.0-rc1 `30.0.0-rc` cannot be parsed by `System.Version`. I think we can be a bit more lenient when locating the latest version of build-tools by instead using a string comparison. This will also allow the relevant tests to use a preview version of build-tools if they exist. Additional logging has also been added to confirm this hypothesis, which is how we determined that it's Build-tools 30.0.0-rc1.
Context: https://devdiv.visualstudio.com/DevDiv/_build/results?buildId=3520928&view=ms.vss-test-web.build-test-results-tab&runId=11613622&resultId=100500&paneView=debug
Xamarin.Android.Build.Task tests which attempt to look up the path to
aapt/aapt2 recently started failing on the Azure Pipelines hosted macOS
machine pool [0]. I suspect this is caused by a preview version of tools
ending up on the machine. I think we can be a bit more lenient when
locating the latest version of build-tools by instead using a string
comparison. This will also allow the relevant tests to use a preview
version of build-tools if they exist. Additional logging has also been
added to confirm this hypothesis.
[0]: