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
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ public void BuildIncremental ([Values] AndroidRuntime runtime)
if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) {
return;
}
AssertCommercialBuild (); // Incremental build assertions require Fast Deployment

var gradleProject = AndroidGradleProject.CreateDefault (GradleTestProjectDir);
var gradleModule = gradleProject.Modules.First ();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,7 @@ public void RepetiviteBuildUpdateSingleResource ([Values] AndroidRuntime runtime
if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) {
return;
}
AssertCommercialBuild (); // Incremental build assertions require Fast Deployment

var proj = new XamarinAndroidApplicationProject {
IsRelease = isRelease,
Expand Down Expand Up @@ -543,7 +544,9 @@ protected override void OnClick()
Assert.IsFalse (StringAssertEx.ContainsText (b.LastBuildOutput, "AndroidResgen: Warning while updating Resource XML"),
"Warning while processing resources should not have been raised.");
Assert.IsTrue (b.Build (proj, doNotCleanupOnUpdate: true), "Build should have succeeded.");
Assert.IsTrue (b.Output.IsTargetSkipped ("_GenerateJavaStubs"), "Target _GenerateJavaStubs should have been skipped");
if (TestEnvironment.CommercialBuildAvailable) {
Assert.IsTrue (b.Output.IsTargetSkipped ("_GenerateJavaStubs"), "Target _GenerateJavaStubs should have been skipped");
}
Comment on lines +547 to +549
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is intentional. These tests primarily validate non-incremental functionality (AOT compilation, asset pack packaging, binding generation, resource processing, etc.). Only the incremental target-skipping assertions are secondary checks. Skipping the entire test with AssertCommercialBuild() would lose coverage for the primary test functionality on public CI. The if (TestEnvironment.CommercialBuildAvailable) pattern is already used elsewhere in the test suite (e.g., InstallAndRunTests.cs).


lib.Touch ("CustomTextView.cs");

Expand Down Expand Up @@ -1084,10 +1087,14 @@ public string GetFoo () {
appBuilder.Output.AssertTargetIsNotSkipped ("_UpdateAndroidResgen");
foo.Timestamp = DateTimeOffset.UtcNow;
Assert.IsTrue (libBuilder.Build (libProj, doNotCleanupOnUpdate: true, saveProject: false), "Library project should have built");
libBuilder.Output.AssertTargetIsSkipped (target);
if (TestEnvironment.CommercialBuildAvailable) {
libBuilder.Output.AssertTargetIsSkipped (target);
}
appBuilder.BuildLogFile = "build1.log";
Assert.IsTrue (appBuilder.Build (appProj, doNotCleanupOnUpdate: true, saveProject: false), "Application Build should have succeeded.");
appBuilder.Output.AssertTargetIsSkipped ("_UpdateAndroidResgen");
if (TestEnvironment.CommercialBuildAvailable) {
appBuilder.Output.AssertTargetIsSkipped ("_UpdateAndroidResgen");
}
// Check Contents of the file in the apk are correct.
string apk = Path.Combine (Root, appBuilder.ProjectDirectory, appProj.OutputPath, appProj.PackageName + "-Signed.apk");
byte[] rawContentBuildOne = ZipHelper.ReadFileFromZip (apk,
Expand Down Expand Up @@ -1169,12 +1176,16 @@ public void BuildAppWithManagedResourceParser ([Values] AndroidRuntime runtime)
appBuilder.BuildLogFile = "build.log";
Assert.IsTrue (appBuilder.Build (appProj, doNotCleanupOnUpdate: true),
"Normal Application Build should have succeeded.");
Assert.IsTrue (appProj.CreateBuildOutput (appBuilder).IsTargetSkipped ("_ManagedUpdateAndroidResgen", defaultIfNotUsed: true),
"Target '_ManagedUpdateAndroidResgen' should not have run.");
if (TestEnvironment.CommercialBuildAvailable) {
Assert.IsTrue (appProj.CreateBuildOutput (appBuilder).IsTargetSkipped ("_ManagedUpdateAndroidResgen", defaultIfNotUsed: true),
"Target '_ManagedUpdateAndroidResgen' should not have run.");
}
appBuilder.BuildLogFile = "designtimebuild.log";
Assert.IsTrue (appBuilder.DesignTimeBuild (appProj, doNotCleanupOnUpdate: true), "DesignTime Application Build should have succeeded.");
Assert.IsTrue (appProj.CreateBuildOutput (appBuilder).IsTargetSkipped ("_ManagedUpdateAndroidResgen", defaultIfNotUsed: true),
"Target '_ManagedUpdateAndroidResgen' should not have run.");
if (TestEnvironment.CommercialBuildAvailable) {
Assert.IsTrue (appProj.CreateBuildOutput (appBuilder).IsTargetSkipped ("_ManagedUpdateAndroidResgen", defaultIfNotUsed: true),
"Target '_ManagedUpdateAndroidResgen' should not have run.");
}

Assert.IsTrue (appBuilder.Clean (appProj), "Clean should have succeeded");
Assert.IsTrue (File.Exists (designerFile), $"'{designerFile}' should not have been cleaned.");
Expand Down Expand Up @@ -1451,12 +1462,14 @@ public void CustomViewAddResourceId ([Values] AndroidRuntime runtime)
proj.Touch (@"Resources\layout\Main.axml");

Assert.IsTrue (b.Build (proj, doNotCleanupOnUpdate: true), "second build should have succeeded");
Assert.IsTrue (
b.Output.IsTargetPartiallyBuilt ("_CompileResources"),
"The target _CompileResources should have been partially built");
Assert.IsTrue (
b.Output.IsTargetSkipped ("_FixupCustomViewsForAapt2", defaultIfNotUsed: true),
"The target _FixupCustomViewsForAapt2 should have been skipped");
if (TestEnvironment.CommercialBuildAvailable) {
Assert.IsTrue (
b.Output.IsTargetPartiallyBuilt ("_CompileResources"),
"The target _CompileResources should have been partially built");
Assert.IsTrue (
b.Output.IsTargetSkipped ("_FixupCustomViewsForAapt2", defaultIfNotUsed: true),
"The target _FixupCustomViewsForAapt2 should have been skipped");
}

var r_java = Path.Combine (Root, b.ProjectDirectory, proj.IntermediateOutputPath, "android", "src", proj.PackageNameJavaIntermediatePath, "R.java");
FileAssert.Exists (r_java);
Expand Down Expand Up @@ -1516,7 +1529,9 @@ BuildItem CreateItem (string include) =>
using (var b = CreateApkBuilder ()) {
Assert.IsTrue (b.Build (proj), "first build should have succeeded.");
Assert.IsTrue (b.Build (proj), "second build should have succeeded.");
b.Output.AssertTargetIsSkipped ("_CompileResources");
if (TestEnvironment.CommercialBuildAvailable) {
b.Output.AssertTargetIsSkipped ("_CompileResources");
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -239,12 +239,14 @@ public void BuildAotApplicationWithNdkAndBundleAndÜmläüts (string supportedAb
}
}
Assert.IsTrue (b.Build (proj), "Second Build should have succeeded.");
Assert.IsTrue (
b.Output.IsTargetSkipped ("_CompileJava"),
"the _CompileJava target should be skipped");
Assert.IsTrue (
b.Output.IsTargetSkipped ("_BuildApkEmbed"),
"the _BuildApkEmbed target should be skipped");
if (TestEnvironment.CommercialBuildAvailable) {
Assert.IsTrue (
b.Output.IsTargetSkipped ("_CompileJava"),
"the _CompileJava target should be skipped");
Assert.IsTrue (
b.Output.IsTargetSkipped ("_BuildApkEmbed"),
Comment on lines +242 to +247
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is intentional. These tests primarily validate non-incremental functionality (AOT compilation, asset pack packaging, binding generation, resource processing, etc.). Only the incremental target-skipping assertions are secondary checks. Skipping the entire test with AssertCommercialBuild() would lose coverage for the primary test functionality on public CI. The if (TestEnvironment.CommercialBuildAvailable) pattern is already used elsewhere in the test suite (e.g., InstallAndRunTests.cs).

"the _BuildApkEmbed target should be skipped");
}
}
}

Expand Down Expand Up @@ -287,12 +289,14 @@ public void BuildAotApplicationAndÜmläüts (string supportedAbis, bool enableL
}
}
Assert.IsTrue (b.Build (proj), "Second Build should have succeeded.");
Assert.IsTrue (
b.Output.IsTargetSkipped ("_CompileJava"),
"the _CompileJava target should be skipped");
Assert.IsTrue (
b.Output.IsTargetSkipped ("_BuildApkEmbed"),
"the _BuildApkEmbed target should be skipped");
if (TestEnvironment.CommercialBuildAvailable) {
Assert.IsTrue (
b.Output.IsTargetSkipped ("_CompileJava"),
"the _CompileJava target should be skipped");
Assert.IsTrue (
b.Output.IsTargetSkipped ("_BuildApkEmbed"),
"the _BuildApkEmbed target should be skipped");
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,9 +219,11 @@ public void BuildApplicationWithAssetPack ([Values] bool isRelease, [Values] And
Assert.IsFalse (zip.ContainsEntry ("assetpack1/resources.pb"), "aab should not contain assetpack1/resources.pb");
}
Assert.IsTrue (appBuilder.Build (app, doNotCleanupOnUpdate: true, saveProject: false), $"{app.ProjectName} should succeed");
appBuilder.Output.AssertTargetIsSkipped ("_CreateAssetPackManifests");
appBuilder.Output.AssertTargetIsSkipped ("_BuildAssetPacks");
appBuilder.Output.AssertTargetIsSkipped ("_GenerateAndroidAssetsDir");
if (TestEnvironment.CommercialBuildAvailable) {
appBuilder.Output.AssertTargetIsSkipped ("_CreateAssetPackManifests");
appBuilder.Output.AssertTargetIsSkipped ("_BuildAssetPacks");
appBuilder.Output.AssertTargetIsSkipped ("_GenerateAndroidAssetsDir");
}
FileAssert.Exists (asset3File, $"file {asset3File} should exist.");
asset3.TextContent = () => "Asset3 Updated";
asset3.Timestamp = DateTime.UtcNow.AddSeconds(1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ public void BindingLibraryIncremental (string classParser, AndroidRuntime runtim
if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) {
return;
}
AssertCommercialBuild (); // Incremental build assertions require Fast Deployment

var targets = new List<string> {
"_ExportJarToXml",
Expand Down Expand Up @@ -883,8 +884,10 @@ public void BindingWithAndroidJavaSource ([Values] AndroidRuntime runtime)
"generated", "src", "Com.Xamarin.Android.Test.Msbuildtest.IJavaSourceTestInterface.cs");
StringAssertEx.ContainsText (File.ReadAllLines (generatedIface), "string GreetWithQuestion (string name, global::Java.Util.Date date, string question);");
Assert.IsTrue (libBuilder.Build (lib), "Library build should have succeeded.");
Assert.IsTrue (libBuilder.Output.IsTargetSkipped ("_CompileBindingJava", defaultIfNotUsed: true), $"`_CompileBindingJava` should be skipped on second build!");
Assert.IsTrue (libBuilder.Output.IsTargetSkipped ("_ClearGeneratedManagedBindings", defaultIfNotUsed: true), $"`_ClearGeneratedManagedBindings` should be skipped on second build!");
if (TestEnvironment.CommercialBuildAvailable) {
Assert.IsTrue (libBuilder.Output.IsTargetSkipped ("_CompileBindingJava", defaultIfNotUsed: true), $"`_CompileBindingJava` should be skipped on second build!");
Assert.IsTrue (libBuilder.Output.IsTargetSkipped ("_ClearGeneratedManagedBindings", defaultIfNotUsed: true), $"`_ClearGeneratedManagedBindings` should be skipped on second build!");
}
FileAssert.Exists (generatedCode, $"'{generatedCode}' should have not be deleted on second build.");
Assert.IsTrue (libBuilder.DesignTimeBuild (lib, target: "UpdateGeneratedFiles"), "DTB should have succeeded.");
FileAssert.Exists (generatedCode, $"'{generatedCode}' should have not be deleted on DTB build.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -896,6 +896,7 @@ public void BuildXamarinFormsMapsApplication ([Values] bool multidex, [Values] A
if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) {
return;
}
AssertCommercialBuild (); // Incremental build assertions require Fast Deployment

var proj = new XamarinFormsMapsApplicationProject {
IsRelease = isRelease,
Expand Down Expand Up @@ -1197,17 +1198,19 @@ public CustomTextView(Context context, IAttributeSet attributes) : base(context,
FileAssert.Exists (designtime_build_props, "designtime/build.props should exist after the second `Build`.");

//NOTE: none of these targets should run, since we have not actually changed anything!
var targetsToBeSkipped = new [] {
//TODO: We would like for this assertion to work, but the <Compile /> item group changes between DTB and regular builds
// $(IntermediateOutputPath)designtime\Resource.designer.cs -> Resources\Resource.designer.cs
// And so the built assembly changes between DTB and regular build, triggering `_LinkAssembliesNoShrink`
//"_LinkAssembliesNoShrink",
"_UpdateAndroidResgen",
"_BuildLibraryImportsCache",
"_CompileJava",
};
foreach (var targetName in targetsToBeSkipped) {
Assert.IsTrue (b.Output.IsTargetSkipped (targetName), $"`{targetName}` should be skipped!");
if (TestEnvironment.CommercialBuildAvailable) {
var targetsToBeSkipped = new [] {
//TODO: We would like for this assertion to work, but the <Compile /> item group changes between DTB and regular builds
// $(IntermediateOutputPath)designtime\Resource.designer.cs -> Resources\Resource.designer.cs
// And so the built assembly changes between DTB and regular build, triggering `_LinkAssembliesNoShrink`
//"_LinkAssembliesNoShrink",
"_UpdateAndroidResgen",
"_BuildLibraryImportsCache",
"_CompileJava",
};
foreach (var targetName in targetsToBeSkipped) {
Assert.IsTrue (b.Output.IsTargetSkipped (targetName), $"`{targetName}` should be skipped!");
}
}

b.Target = "Clean";
Expand Down Expand Up @@ -1347,13 +1350,15 @@ public void CheckTimestamps ([Values] bool isRelease, [Values] AndroidRuntime ru
//One last build with no changes
Assert.IsTrue (b.Build (proj), "third build should have succeeded.");

// NativeAOT always runs the linking step
if (runtime != AndroidRuntime.NativeAOT) {
b.Output.AssertTargetIsSkipped (isRelease ? KnownTargets.LinkAssembliesShrink : KnownTargets.LinkAssembliesNoShrink);
if (TestEnvironment.CommercialBuildAvailable) {
// NativeAOT always runs the linking step
if (runtime != AndroidRuntime.NativeAOT) {
b.Output.AssertTargetIsSkipped (isRelease ? KnownTargets.LinkAssembliesShrink : KnownTargets.LinkAssembliesNoShrink);
}
b.Output.AssertTargetIsSkipped ("_UpdateAndroidResgen");
b.Output.AssertTargetIsSkipped ("_BuildLibraryImportsCache");
b.Output.AssertTargetIsSkipped ("_CompileJava");
}
b.Output.AssertTargetIsSkipped ("_UpdateAndroidResgen");
b.Output.AssertTargetIsSkipped ("_BuildLibraryImportsCache");
b.Output.AssertTargetIsSkipped ("_CompileJava");
}
}

Expand Down
Loading
Loading