Skip to content

Commit f644fca

Browse files
[Tests] Add test for CompileNativeAssembly per-file skip
Add CompileNativeAssemblySourcesSkipsUnchangedFiles integration test that verifies on incremental CoreCLR builds, unchanged .ll files are not recompiled by the CompileNativeAssembly task while changed .ll files are still correctly compiled. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent d2f07a1 commit f644fca

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/IncrementalBuildTest.cs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1289,6 +1289,38 @@ public void GenerateJavaStubsAndAssembly ([Values] bool isRelease, [Values] Andr
12891289
}
12901290
}
12911291

1292+
[Test]
1293+
public void CompileNativeAssemblySourcesSkipsUnchangedFiles ([Values (AndroidRuntime.CoreCLR)] AndroidRuntime runtime)
1294+
{
1295+
if (IgnoreUnsupportedConfiguration (runtime, release: false)) {
1296+
return;
1297+
}
1298+
1299+
var proj = new XamarinAndroidApplicationProject ();
1300+
proj.SetRuntime (runtime);
1301+
1302+
string abi = "arm64-v8a";
1303+
proj.SetRuntimeIdentifier (abi);
1304+
1305+
using (var b = CreateApkBuilder ()) {
1306+
b.Verbosity = LoggerVerbosity.Detailed;
1307+
Assert.IsTrue (b.Build (proj), "first build should have succeeded.");
1308+
1309+
// Modify MainActivity to trigger recompilation of typemap sources
1310+
proj.MainActivity = proj.DefaultMainActivity + Environment.NewLine + "// test comment";
1311+
proj.Touch ("MainActivity.cs");
1312+
Assert.IsTrue (b.Build (proj), "second build should have succeeded.");
1313+
1314+
Assert.IsFalse (b.Output.IsTargetSkipped ("_CompileNativeAssemblySources"), "`_CompileNativeAssemblySources` should *not* be skipped!");
1315+
1316+
// At least one .ll file should have been skipped as up to date (e.g., environment.arm64-v8a.ll)
1317+
Assert.IsTrue (
1318+
StringAssertEx.ContainsRegex (@"\[LLVM llc\] Skipping.*up to date", b.LastBuildOutput),
1319+
"Expected at least one .ll file to be skipped as up to date"
1320+
);
1321+
}
1322+
}
1323+
12921324
readonly string [] ExpectedAssemblyFiles = new [] {
12931325
Path.Combine ("android", "environment.@ABI@.o"),
12941326
Path.Combine ("android", "environment.@ABI@.ll"),

0 commit comments

Comments
 (0)