Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Xamarin.Android.Build.Tests] Fix Repeat Build Tests #2582

Merged
merged 1 commit into from
Jan 3, 2019
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 @@ -23,13 +23,15 @@ public void RepetitiveBuild ()
if (Directory.Exists ("temp/RepetitiveBuild"))
Directory.Delete ("temp/RepetitiveBuild", true);
var proj = new XamarinAndroidApplicationProject ();
using (var b = CreateApkBuilder ("temp/RepetitiveBuild")) {
using (var b = CreateApkBuilder ("temp/RepetitiveBuild", cleanupAfterSuccessfulBuild: false, cleanupOnDispose: false)) {
b.Verbosity = Microsoft.Build.Framework.LoggerVerbosity.Diagnostic;
b.ThrowOnBuildFailure = false;
Assert.IsTrue (b.Build (proj), "first build failed");
Assert.IsTrue (b.Build (proj), "second build failed");
Assert.IsTrue (b.Output.IsTargetSkipped ("_Sign"), "failed to skip some build");
proj.AndroidResources.Last ().Timestamp = null; // means "always build"
var item = proj.AndroidResources.First (x => x.Include () == "Resources\\values\\Strings.xml");
item.TextContent = () => proj.StringsXml.Replace ("${PROJECT_NAME}", "Foo");
item.Timestamp = null;
Assert.IsTrue (b.Build (proj), "third build failed");
Assert.IsFalse (b.Output.IsTargetSkipped ("_Sign"), "incorrectly skipped some build");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -978,7 +978,7 @@ public override void OnCreate()
public void BasicApplicationRepetitiveBuild ()
{
var proj = new XamarinAndroidApplicationProject ();
using (var b = CreateApkBuilder ("temp/BasicApplicationRepetitiveBuild", cleanupAfterSuccessfulBuild: false)) {
using (var b = CreateApkBuilder ("temp/BasicApplicationRepetitiveBuild", cleanupAfterSuccessfulBuild: false, cleanupOnDispose: false)) {
b.Verbosity = Microsoft.Build.Framework.LoggerVerbosity.Diagnostic;
b.ThrowOnBuildFailure = false;
Assert.IsTrue (b.Build (proj), "first build failed");
Expand All @@ -991,7 +991,9 @@ public void BasicApplicationRepetitiveBuild ()
Assert.IsTrue (
b.Output.IsTargetSkipped ("_Sign"),
"the _Sign target should not run");
proj.AndroidResources.Last ().Timestamp = null;
var item = proj.AndroidResources.First (x => x.Include () == "Resources\\values\\Strings.xml");
item.TextContent = () => proj.StringsXml.Replace ("${PROJECT_NAME}", "Foo");
item.Timestamp = null;
Assert.IsTrue (b.Build (proj), "third build failed");
Assert.IsFalse (
b.Output.IsTargetSkipped ("_Sign"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,9 @@ public void CheckSignApk ([Values(true, false)] bool useApkSigner, [Values(true,
}
}

proj.AndroidResources.First ().Timestamp = null;
var item = proj.AndroidResources.First (x => x.Include () == "Resources\\values\\Strings.xml");
item.TextContent = () => proj.StringsXml.Replace ("${PROJECT_NAME}", "Foo");
item.Timestamp = null;
Assert.IsTrue (b.Build (proj), "Second build failed");
Assert.IsTrue (StringAssertEx.ContainsText (b.LastBuildOutput, " 0 Warning(s)"),
"Second build should not contain warnings! Contains\n" +
Expand Down