Skip to content

Commit f7ca41b

Browse files
committed
[tests/MSBuildDeviceIntegration] Add test for dll's which have the same size.
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 uploade. This commit adds a test to make sure this does work as expected.
1 parent 57c5a5f commit f7ca41b

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
@@ -469,23 +469,25 @@ public void IncrementalFastDeployment ()
469469
AssertCommercialBuild ();
470470
AssertHasDevices ();
471471

472+
var class1src = new BuildItem.Source ("Class1.cs") {
473+
TextContent = () => "namespace Library1 { public class Class1 { public static int foo = 0; } }"
474+
};
472475
var lib1 = new XamarinAndroidLibraryProject () {
473476
ProjectName = "Library1",
474477
Sources = {
475-
new BuildItem.Source ("Class1.cs") {
476-
TextContent = () => "namespace Library1 { public class Class1 { } }"
477-
},
478+
class1src,
478479
}
479480
};
480481

482+
var class2src = new BuildItem.Source ("Class2.cs") {
483+
TextContent = () => "namespace Library2 { public class Class2 { public static int foo = 0; } }"
484+
};
481485
var lib2 = new DotNetStandard {
482486
ProjectName = "Library2",
483487
Sdk = "Microsoft.NET.Sdk",
484488
TargetFramework = "netstandard2.0",
485489
Sources = {
486-
new BuildItem.Source ("Class2.cs") {
487-
TextContent = () => "namespace Library2 { public class Class2 { } }"
488-
},
490+
class2src,
489491
}
490492
};
491493

@@ -504,15 +506,22 @@ public void IncrementalFastDeployment ()
504506
using (var lb2 = CreateDllBuilder (Path.Combine (rootPath, lib2.ProjectName)))
505507
Assert.IsTrue (lb2.Build (lib2), "Second library build should have succeeded.");
506508

509+
long lib1FirstBuildSize = new FileInfo (Path.Combine (rootPath, lib1.ProjectName, lib1.OutputPath, "Library1.dll")).Length;
510+
507511
using (var builder = CreateApkBuilder (Path.Combine (rootPath, app.ProjectName))) {
508512
builder.ThrowOnBuildFailure = false;
513+
builder.BuildLogFile = "install.log";
509514
Assert.IsTrue (builder.Install (app), "First install should have succeeded.");
515+
var logLines = builder.LastBuildOutput;
516+
Assert.IsTrue (logLines.Any (l => l.Contains ("NotifySync CopyFile") && l.Contains ("UnnamedProject.dll")), "UnnamedProject.dll should have been uploaded");
517+
Assert.IsTrue (logLines.Any (l => l.Contains ("NotifySync CopyFile") && l.Contains ("Library1.dll")), "Library1.dll should have been uploaded");
518+
Assert.IsTrue (logLines.Any (l => l.Contains ("NotifySync CopyFile") && l.Contains ("Library2.dll")), "Library2.dll should have been uploaded");
510519
var firstInstallTime = builder.LastBuildTime;
520+
builder.BuildLogFile = "install2.log";
511521
Assert.IsTrue (builder.Install (app, doNotCleanupOnUpdate: true, saveProject: false), "Second install should have succeeded.");
512522
var secondInstallTime = builder.LastBuildTime;
513523

514524
var filesToTouch = new [] {
515-
Path.Combine (rootPath, lib1.ProjectName, "Class1.cs"),
516525
Path.Combine (rootPath, lib2.ProjectName, "Class2.cs"),
517526
Path.Combine (rootPath, app.ProjectName, "MainPage.xaml"),
518527
};
@@ -521,8 +530,22 @@ public void IncrementalFastDeployment ()
521530
File.SetLastWriteTimeUtc (file, DateTime.UtcNow);
522531
}
523532

533+
class1src.TextContent = () => "namespace Library1 { public class Class1 { public static int foo = 100; } }";
534+
class1src.Timestamp = DateTime.UtcNow.AddSeconds(1);
535+
using (var lb1 = CreateDllBuilder (Path.Combine (rootPath, lib1.ProjectName)))
536+
Assert.IsTrue (lb1.Build (lib1), "Second library build should have succeeded.");
537+
538+
long lib1SecondBuildSize = new FileInfo (Path.Combine (rootPath, lib1.ProjectName, lib1.OutputPath, "Library1.dll")).Length;
539+
Assert.AreEqual (lib1FirstBuildSize, lib1SecondBuildSize, "Library2.dll was not the same size.");
540+
541+
builder.BuildLogFile = "install3.log";
524542
Assert.IsTrue (builder.Install (app, doNotCleanupOnUpdate: true, saveProject: false), "Third install should have succeeded.");
543+
logLines = builder.LastBuildOutput;
544+
Assert.IsTrue (logLines.Any (l => l.Contains ("NotifySync CopyFile") && l.Contains ("UnnamedProject.dll")), "UnnamedProject.dll should have been uploaded");
545+
Assert.IsTrue (logLines.Any (l => l.Contains ("NotifySync CopyFile") && l.Contains ("Library1.dll")), "Library1.dll should have been uploaded");
546+
Assert.IsTrue (logLines.Any (l => l.Contains ("NotifySync SkipCopyFile") && l.Contains ("Library2.dll")), "Library2.dll should not have been uploaded");
525547
var thirdInstallTime = builder.LastBuildTime;
548+
builder.BuildLogFile = "install4.log";
526549
Assert.IsTrue (builder.Install (app, doNotCleanupOnUpdate: true, saveProject: false), "Fourth install should have succeeded.");
527550
var fourthInstalTime = builder.LastBuildTime;
528551

0 commit comments

Comments
 (0)