Skip to content

Commit 11ba628

Browse files
committed
Added assembly size regression testing
1 parent e7ee8e9 commit 11ba628

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

ApkDescription.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,11 @@ public void Compare (ApkDescription other)
206206
if (!AddToDifference (diff.Key, diff.Value, out entryDiff))
207207
continue;
208208

209+
if (Program.AssemblyRegressionThreshold != 0 && entryDiff is AssemblyDiff && diff.Value > Program.AssemblyRegressionThreshold) {
210+
Program.Error ($"Assembly size differs more than {Program.AssemblyRegressionThreshold} bytes.");
211+
Program.RegressionFlag = true;
212+
}
213+
209214
if (comparingApks && !single)
210215
CompareEntries (new KeyValuePair<string, FileProperties> (diff.Key, Entries [diff.Key]), new KeyValuePair<string, FileProperties> (diff.Key, other.Entries [diff.Key]), other, entryDiff);
211216
}

Program.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ class Program {
1414

1515
public static long AssemblyRegressionThreshold;
1616
public static long ApkRegressionThreshold;
17+
public static bool RegressionFlag;
1718

1819
public static void Main (string [] args)
1920
{
@@ -28,9 +29,14 @@ public static void Main (string [] args)
2829

2930
if (ApkRegressionThreshold != 0 && (desc2.PackageSize - desc1.PackageSize) > ApkRegressionThreshold) {
3031
Error ($"PackageSize differ more than {ApkRegressionThreshold} bytes. apk1 size: {desc1.PackageSize} bytes, apk2 size: {desc2.PackageSize} bytes.");
31-
Environment.Exit (3);
32+
RegressionFlag = true;
3233
}
3334
}
35+
36+
if (RegressionFlag) {
37+
Error ("Size regression occured, test failed.");
38+
Environment.Exit (3);
39+
}
3440
}
3541

3642
static (string, string) ProcessArguments (string [] args)
@@ -53,6 +59,9 @@ public static void Main (string [] args)
5359
{ "test-apk-size-regression=",
5460
"Check whether apk size increased more than {BYTES}",
5561
v => ApkRegressionThreshold = long.Parse (v) },
62+
{ "test-assembly-size-regression=",
63+
"Check whether any assembly size increased more than {BYTES}",
64+
v => AssemblyRegressionThreshold = long.Parse (v) },
5665
{ "s|save-descriptions",
5766
"Save .apkdesc files next to the apk package(s)",
5867
v => SaveDescriptions = true },

0 commit comments

Comments
 (0)