Skip to content

Commit 2b96e0d

Browse files
authored
[tests] Add deployment test for .dll files of the same size. (#5229)
Context: xamarin/monodroid#1123 There seems to be a bug in the new fast deployment system where if the `.dll` was modified BUT had exactly the same size as the existing `.dll` on the device it would not be uploaded. This commit adds a test to make sure this does work as expected.
1 parent 0f2dc44 commit 2b96e0d

File tree

1 file changed

+30
-7
lines changed

1 file changed

+30
-7
lines changed

tests/MSBuildDeviceIntegration/Tests/InstallTests.cs

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -478,23 +478,25 @@ public void IncrementalFastDeployment ()
478478
AssertCommercialBuild ();
479479
AssertHasDevices ();
480480

481+
var class1src = new BuildItem.Source ("Class1.cs") {
482+
TextContent = () => "namespace Library1 { public class Class1 { public static int foo = 0; } }"
483+
};
481484
var lib1 = new XamarinAndroidLibraryProject () {
482485
ProjectName = "Library1",
483486
Sources = {
484-
new BuildItem.Source ("Class1.cs") {
485-
TextContent = () => "namespace Library1 { public class Class1 { } }"
486-
},
487+
class1src,
487488
}
488489
};
489490

491+
var class2src = new BuildItem.Source ("Class2.cs") {
492+
TextContent = () => "namespace Library2 { public class Class2 { public static int foo = 0; } }"
493+
};
490494
var lib2 = new DotNetStandard {
491495
ProjectName = "Library2",
492496
Sdk = "Microsoft.NET.Sdk",
493497
TargetFramework = "netstandard2.0",
494498
Sources = {
495-
new BuildItem.Source ("Class2.cs") {
496-
TextContent = () => "namespace Library2 { public class Class2 { } }"
497-
},
499+
class2src,
498500
}
499501
};
500502

@@ -513,15 +515,22 @@ public void IncrementalFastDeployment ()
513515
using (var lb2 = CreateDllBuilder (Path.Combine (rootPath, lib2.ProjectName)))
514516
Assert.IsTrue (lb2.Build (lib2), "Second library build should have succeeded.");
515517

518+
long lib1FirstBuildSize = new FileInfo (Path.Combine (rootPath, lib1.ProjectName, lib1.OutputPath, "Library1.dll")).Length;
519+
516520
using (var builder = CreateApkBuilder (Path.Combine (rootPath, app.ProjectName))) {
517521
builder.ThrowOnBuildFailure = false;
522+
builder.BuildLogFile = "install.log";
518523
Assert.IsTrue (builder.Install (app), "First install should have succeeded.");
524+
var logLines = builder.LastBuildOutput;
525+
Assert.IsTrue (logLines.Any (l => l.Contains ("NotifySync CopyFile") && l.Contains ("UnnamedProject.dll")), "UnnamedProject.dll should have been uploaded");
526+
Assert.IsTrue (logLines.Any (l => l.Contains ("NotifySync CopyFile") && l.Contains ("Library1.dll")), "Library1.dll should have been uploaded");
527+
Assert.IsTrue (logLines.Any (l => l.Contains ("NotifySync CopyFile") && l.Contains ("Library2.dll")), "Library2.dll should have been uploaded");
519528
var firstInstallTime = builder.LastBuildTime;
529+
builder.BuildLogFile = "install2.log";
520530
Assert.IsTrue (builder.Install (app, doNotCleanupOnUpdate: true, saveProject: false), "Second install should have succeeded.");
521531
var secondInstallTime = builder.LastBuildTime;
522532

523533
var filesToTouch = new [] {
524-
Path.Combine (rootPath, lib1.ProjectName, "Class1.cs"),
525534
Path.Combine (rootPath, lib2.ProjectName, "Class2.cs"),
526535
Path.Combine (rootPath, app.ProjectName, "MainPage.xaml"),
527536
};
@@ -530,8 +539,22 @@ public void IncrementalFastDeployment ()
530539
File.SetLastWriteTimeUtc (file, DateTime.UtcNow);
531540
}
532541

542+
class1src.TextContent = () => "namespace Library1 { public class Class1 { public static int foo = 100; } }";
543+
class1src.Timestamp = DateTime.UtcNow.AddSeconds(1);
544+
using (var lb1 = CreateDllBuilder (Path.Combine (rootPath, lib1.ProjectName)))
545+
Assert.IsTrue (lb1.Build (lib1), "Second library build should have succeeded.");
546+
547+
long lib1SecondBuildSize = new FileInfo (Path.Combine (rootPath, lib1.ProjectName, lib1.OutputPath, "Library1.dll")).Length;
548+
Assert.AreEqual (lib1FirstBuildSize, lib1SecondBuildSize, "Library2.dll was not the same size.");
549+
550+
builder.BuildLogFile = "install3.log";
533551
Assert.IsTrue (builder.Install (app, doNotCleanupOnUpdate: true, saveProject: false), "Third install should have succeeded.");
552+
logLines = builder.LastBuildOutput;
553+
Assert.IsTrue (logLines.Any (l => l.Contains ("NotifySync CopyFile") && l.Contains ("UnnamedProject.dll")), "UnnamedProject.dll should have been uploaded");
554+
Assert.IsTrue (logLines.Any (l => l.Contains ("NotifySync CopyFile") && l.Contains ("Library1.dll")), "Library1.dll should have been uploaded");
555+
Assert.IsTrue (logLines.Any (l => l.Contains ("NotifySync SkipCopyFile") && l.Contains ("Library2.dll")), "Library2.dll should not have been uploaded");
534556
var thirdInstallTime = builder.LastBuildTime;
557+
builder.BuildLogFile = "install4.log";
535558
Assert.IsTrue (builder.Install (app, doNotCleanupOnUpdate: true, saveProject: false), "Fourth install should have succeeded.");
536559
var fourthInstalTime = builder.LastBuildTime;
537560

0 commit comments

Comments
 (0)