Skip to content

Commit 7aaea22

Browse files
authored
[tests] Be more flexible when parsing build-tools versions (#4354)
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.
1 parent d1dd186 commit 7aaea22

File tree

1 file changed

+2
-1
lines changed
  • src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Utilities

1 file changed

+2
-1
lines changed

src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Utilities/BaseTest.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,8 @@ protected byte [] ReadAllBytesIgnoringLineEndings (Stream stream)
407407
protected string GetPathToLatestBuildTools (string exe)
408408
{
409409
var path = Path.Combine (AndroidSdkPath, "build-tools");
410-
foreach (var dir in Directory.GetDirectories (path, "*", SearchOption.TopDirectoryOnly).OrderByDescending (x => new Version (Path.GetFileName (x)))) {
410+
foreach (var dir in Directory.GetDirectories (path, "*", SearchOption.TopDirectoryOnly).OrderByDescending (x => Path.GetFileName (x))) {
411+
TestContext.Out.WriteLine ($"Found build tools version: {dir}.");
411412
var aapt2 = Path.Combine (dir, exe);
412413
if (File.Exists (aapt2))
413414
return dir;

0 commit comments

Comments
 (0)