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 @@ -9,6 +9,7 @@
using Microsoft.Build.Framework;
using System.Xml.Linq;
using System.Security.Cryptography;
using System.Text.RegularExpressions;

namespace Xamarin.Android.Build.Tests
{
Expand Down Expand Up @@ -37,6 +38,8 @@ public void RepetitiveBuild ()
[Test]
public void DesignTimeBuild ([Values(false, true)] bool isRelease)
{
var regEx = new Regex (@"(?<type>([a-zA-Z_0-9])+)\slibrary_name=(?<value>([0-9A-Za-z])+);", RegexOptions.Compiled | RegexOptions.Multiline );

var path = Path.Combine (Root, "temp", $"DesignTimeBuild_{isRelease}");
var cachePath = Path.Combine (path, "Cache");
var envVar = new Dictionary<string, string> () {
Expand Down Expand Up @@ -71,8 +74,8 @@ public void DesignTimeBuild ([Values(false, true)] bool isRelease)
},
};

using (var l = CreateDllBuilder (Path.Combine (path, lib.ProjectName))) {
using (var b = CreateApkBuilder (Path.Combine (path, proj.ProjectName))) {
using (var l = CreateDllBuilder (Path.Combine (path, lib.ProjectName), false, false)) {
using (var b = CreateApkBuilder (Path.Combine (path, proj.ProjectName), false, false)) {
l.Verbosity = LoggerVerbosity.Diagnostic;
Assert.IsTrue(l.Clean(lib), "Lib1 should have cleaned successfully");
Assert.IsTrue (l.Build (lib), "Lib1 should have built successfully");
Expand All @@ -83,12 +86,26 @@ public void DesignTimeBuild ([Values(false, true)] bool isRelease)
"first build failed");
Assert.IsTrue (b.LastBuildOutput.Contains ("Skipping download of "),
"failed to skip the downloading of files.");
var items = new List<string> ();
foreach (var file in Directory.EnumerateFiles (Path.Combine (path, proj.ProjectName, proj.IntermediateOutputPath, "android"), "R.java", SearchOption.AllDirectories)) {
var matches = regEx.Matches (File.ReadAllText (file));
items.AddRange (matches.Cast<System.Text.RegularExpressions.Match> ().Select(x => x.Groups ["value"].Value));
}
var first = items.First ();
Assert.IsTrue (items.All (x => x == first), "All Items should have matching values");
WaitFor (1000);
b.Target = "Build";
Assert.IsTrue (b.Build (proj, doNotCleanupOnUpdate: true, parameters: new string [] { "DesignTimeBuild=false" }, environmentVariables: envVar), "second build failed");
Assert.IsFalse(b.Output.IsTargetSkipped ("_BuildAdditionalResourcesCache"), "_BuildAdditionalResourcesCache should have run.");
Assert.IsTrue (b.LastBuildOutput.Contains($"Downloading {url}") || b.LastBuildOutput.Contains ($"reusing existing archive: {zipPath}"), $"{url} should have been downloaded.");
Assert.IsTrue (b.LastBuildOutput.Contains ($"Downloading {url}") || b.LastBuildOutput.Contains ($"reusing existing archive: {zipPath}"), $"{url} should have been downloaded.");
Assert.IsTrue (File.Exists (Path.Combine (extractedDir, "1", "content", "android-N", "aapt")), $"Files should have been extracted to {extractedDir}");
items.Clear ();
foreach (var file in Directory.EnumerateFiles (Path.Combine (path, proj.ProjectName, proj.IntermediateOutputPath, "android"), "R.java", SearchOption.AllDirectories)) {
var matches = regEx.Matches (File.ReadAllText (file));
items.AddRange (matches.Cast<System.Text.RegularExpressions.Match> ().Select (x => x.Groups["value"].Value));
}
first = items.First ();
Assert.IsTrue (items.All (x => x == first), "All Items should have matching values");
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1244,7 +1244,8 @@ because xbuild doesn't support framework reference assemblies.
$(MSBuildAllProjects);
@(_AndroidResourceDest);
@(_LibraryResourceDirectoryStamps);
@(_AdditonalAndroidResourceCachePaths->'%(Identity)\cache.stamp')
@(_AdditonalAndroidResourceCachePaths->'%(Identity)\cache.stamp');
$(_AndroidBuildPropertiesCache)
</_UpdateAndroidResgenInputs>
</PropertyGroup>

Expand Down