Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build-tools/automation/azure-pipelines.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ extends:
testName: Mono.Android.NET_Tests-Debug
project: tests/Mono.Android-Tests/Runtime-Microsoft.Android.Sdk/Mono.Android.NET-Tests.csproj
testResultsFiles: TestResult-Mono.Android.NET_Tests-Debug.xml
artifactSource: bin/Test$(XA.Build.Configuration)/$(DotNetTargetFramework)-android/Mono.Android.NET_Tests-Signed.apk
artifactSource: bin/TestDebug/$(DotNetTargetFramework)-android/Mono.Android.NET_Tests-Signed.apk
artifactFolder: $(DotNetTargetFramework)-Debug

- template: /build-tools/automation/yaml-templates/apk-instrumentation.yaml@self
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,8 @@ public void BuildReleaseArm64 ([Values (false, true)] bool forms)
var apkFile = Path.Combine (Root, b.ProjectDirectory, proj.OutputPath, proj.PackageName + "-Signed.apk");
var apkDescPath = Path.Combine (Root, apkDescFilename);
var apkDescReferencePath = Path.Combine (Root, b.ProjectDirectory, apkDescReference);
var (code, stdOut, stdErr) = RunApkDiffCommand ($"-s --save-description-2={apkDescPath} --descrease-is-regression {regressionCheckArgs} {apkDescReferencePath} {apkFile}");
Assert.IsTrue (code == 0, $"apkdiff regression test failed with exit code: {code}\ncontext: https://github.com/xamarin/xamarin-android/blob/main/Documentation/project-docs/ApkSizeRegressionChecks.md\nstdOut: {stdOut}\nstdErr: {stdErr}");
var (code, stdOut, stdErr) = RunApkDiffCommand ($"-s --save-description-2={apkDescPath} --descrease-is-regression {regressionCheckArgs} {apkDescReferencePath} {apkFile}", Path.Combine (Root, b.ProjectDirectory, "apkdiff.log"));
Assert.IsTrue (code == 0, $"apkdiff regression test failed with exit code: {code}. See test attachments.");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,13 @@ protected static string RunAdbCommand (string command, bool ignoreErrors = true,
return RunProcess (adb, $"{adbTarget} {command}", timeout);
}

protected static (int code, string stdOutput, string stdError) RunApkDiffCommand (string args)
protected static (int code, string stdOutput, string stdError) RunApkDiffCommand (string args, string logFilePath)
{
string ext = Environment.OSVersion.Platform != PlatformID.Unix ? ".exe" : "";
(int code, string stdOutput, string stdError) result;

try {
return RunProcessWithExitCode ("apkdiff" + ext, args);
result = RunProcessWithExitCode ("apkdiff" + ext, args);
} catch (System.ComponentModel.Win32Exception) {
// apkdiff's location might not be in the $PATH, try known locations
var profileDir = Environment.GetFolderPath (Environment.SpecialFolder.UserProfile);
Expand All @@ -117,8 +118,13 @@ protected static (int code, string stdOutput, string stdError) RunApkDiffCommand
apkdiffPath = Path.Combine (agentToolsDir, "apkdiff" + ext);
}
}
return RunProcessWithExitCode (apkdiffPath, args);
result = RunProcessWithExitCode (apkdiffPath, args);
}
var logContent = $"apkdiff exited with code: {result.code}" +
$"\ncontext: https://github.com/xamarin/xamarin-android/blob/main/Documentation/project-docs/ApkSizeRegressionChecks.md" +
$"\nstdOut:\n{result.stdOutput}\nstdErr:\n{result.stdError}";
File.WriteAllText (logFilePath, logContent);
return result;
}

protected static string RunProcess (string exe, string args, int timeoutInSeconds = 30)
Expand Down
Loading