You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Fail if a file was added to or removed from the app bundle.
* Fail if the set of APIs that survived trimming changed.
* Use Assert.Multiple to support multiple failing asserts.
* Improve diagnostic output a bit.
// There's a tolerance in the test for minor app size variances, so if this test fails, the current change might not mean there's a big change,
34
34
// there might just be many cumulative unnoticed/minor app size differences eventually triggering the test.
35
35
// The test fails even if app size goes down; this way we can also keep track of good news! And additionally we won't miss it if the app size first goes down, then back up again.
36
+
//
37
+
// List of failure modes:
38
+
// * Files added or removed from app bundle
39
+
// * Total app size changed >10kb
40
+
// * For those apps where assembly APIs can be compared, any API was added or removed.
Console.WriteLine($"App size difference is {FormatBytes(appSizeDifference)}, which is less than the tolerance ({toleranceInBytes}), so nothing will be reported.");
varmsg=$"App size changed significantly ({FormatBytes(appSizeDifference,true)} different > tolerance of +-{FormatBytes(toleranceInBytes)}). Expected app size: {FormatBytes(expectedAppBundleSize)}, actual app size: {FormatBytes(appBundleSize)}.";
97
+
stringmsg;
89
98
90
-
if(update){
99
+
if(appSizeDifference==0){
100
+
msg=$"App size did not change. Expected app size: {FormatBytes(expectedAppBundleSize)}, actual app size: {FormatBytes(appBundleSize)}.";
101
+
}elseif(withinTolerance){
102
+
msg=$"App size changed, but not significantly: ({FormatBytes(appSizeDifference,true)} different <= tolerance of +-{FormatBytes(toleranceInBytes)}). Expected app size: {FormatBytes(expectedAppBundleSize)}, actual app size: {FormatBytes(appBundleSize)}.";
103
+
}else{
104
+
msg=$"App size changed significantly ({FormatBytes(appSizeDifference,true)} different > tolerance of +-{FormatBytes(toleranceInBytes)}). Expected app size: {FormatBytes(expectedAppBundleSize)}, actual app size: {FormatBytes(appBundleSize)}.";
msg+=" Check the modified files for more information.";
112
+
updated=true;
113
+
}elseif(!withinTolerance){
114
+
msg+=" Set the environment variable WRITE_KNOWN_FAILURES=1, run the test again, and verify the modified files for more information.";
93
115
}
94
116
95
-
msg+=" Set the environment variable WRITE_KNOWN_FAILURES=1, run the test again, and verify the modified files for more information.";
96
117
Console.WriteLine($" {msg}");
97
118
98
119
varexpectedLines=expectedSizeReport.SplitLines().Skip(2).Where(v =>v.IndexOf(':')>=0).ToDictionary(v =>v[..v.IndexOf(':')], v =>v[(v.IndexOf(':')+1)..]);
Console.WriteLine($" {removedAPIs.Count()} APIs not present anymore:");
136
167
foreach(varlineinremovedAPIs)
137
168
Console.WriteLine($" {line}");
169
+
}
138
170
139
-
if(update){
140
-
File.WriteAllLines(expectedFile,preservedAPIs);
141
-
}
171
+
if(update){
172
+
File.WriteAllLines(expectedFile,preservedAPIs);
142
173
}
143
174
144
-
if(!update)
145
-
Assert.Fail(msg);
175
+
if(!update){
176
+
Assert.That(addedAPIs,Is.Empty,"No added APIs (set the environment variable WRITE_KNOWN_FAILURES=1 and run the test again to update the expected set of APIs)");
177
+
Assert.That(removedAPIs,Is.Empty,"No removed APIs (set the environment variable WRITE_KNOWN_FAILURES=1 and run the test again to update the expected set of APIs)");
0 commit comments