Skip to content

Commit

Permalink
[msbuild] Update a few msbuild tests to Xcode 11 behavior. Fixes xama…
Browse files Browse the repository at this point in the history
  • Loading branch information
rolfbjarne authored and VincentDondain committed Oct 16, 2019
1 parent f83b7cb commit 1a3326a
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 39 deletions.
30 changes: 19 additions & 11 deletions msbuild/tests/Xamarin.iOS.Tasks.Tests/TargetTests/TargetTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -116,22 +116,23 @@ static string[] ExpectedLibraryEmbeddedResources {
}
}

static bool BundleResourceExists (string path, ref int extra)
static void BundleResourceExists (string path)
{
if (Path.GetExtension (path) == ".nib") {
if (Directory.Exists (path)) {
// Note: this suggests that things were built with the iOS 8 SDK...
var objects8Nib = Path.Combine (path, "objects-8.0+.nib");
var objects13Nib = Path.Combine (path, "objects-13.0+.nib");
var objectsNib = Path.Combine (path, "objects.nib");
var runtimeNib = Path.Combine (path, "runtime.nib");

extra++;

return File.Exists (runtimeNib) && (File.Exists (objectsNib) || File.Exists (objects8Nib));
Assert.That (File.Exists (runtimeNib), $"File exists: {runtimeNib}");
Assert.That (File.Exists (objectsNib) || File.Exists (objects8Nib) || File.Exists (objects13Nib), $"File exists: {objectsNib} || {objects8Nib} || {objects13Nib}");
return;
}
}

return File.Exists (path);
Assert.IsTrue (File.Exists (path), $"Existence of {path}");
}

[Test]
Expand Down Expand Up @@ -173,17 +174,22 @@ public void GetReferencedAssemblies_Library ()
CollectionAssert.AreEquivalent (expected_references, actual_references, "References");
}

// [Test] - https://github.com/xamarin/xamarin-macios/issues/6970
[Test]
public void BuildExecutable ()
{
var expectedFiles = ExpectedExecutableFiles;
int extra = 0;

RunTargetOnInstance (MonoTouchProjectInstance, TargetName.Build);

Assert.IsTrue (Directory.Exists (AppBundlePath), "#1");

var bundleResources = Directory.GetFileSystemEntries (AppBundlePath, "*", SearchOption.AllDirectories);
var inexistentResource = expectedFiles.Except (expectedFiles).ToArray ();

Assert.That (inexistentResource, Is.Empty, "No missing resources");

foreach (var file in expectedFiles)
Assert.IsTrue (BundleResourceExists (file, ref extra), "#2. " + file);
BundleResourceExists (file);

// Verify that we have not bundled BundleResource or Content items as embedded resources
var assemblyDef = AssemblyDefinition.ReadAssembly (Path.Combine (AppBundlePath, "MySingleView.exe"));
Expand Down Expand Up @@ -440,7 +446,7 @@ public void UnpackLibraryResources_LibraryProject ()
Assert.AreEqual (11, bundleResources.Length, "#1");
}

// [Test] - https://github.com/xamarin/xamarin-macios/issues/6970
[Test]
public void BundleResources ()
{
var actool = Path.Combine ("obj", "iPhoneSimulator", "Debug", "actool", "bundle");
Expand All @@ -467,9 +473,11 @@ public void BundleResources ()
Assert.IsTrue (bundleItems.Any (i => i.EvaluatedInclude == Path.Combine (actool, "LaunchImage-568h@2x.png") && i.GetMetadataValue ("LogicalName") == "LaunchImage-568h@2x.png"), "#11");
Assert.IsTrue (bundleItems.Any (i => i.EvaluatedInclude == Path.Combine (actool, "LaunchImage.png") && i.GetMetadataValue ("LogicalName") == "LaunchImage.png"), "#12");
Assert.IsTrue (bundleItems.Any (i => i.EvaluatedInclude == Path.Combine (actool, "LaunchImage@2x.png") && i.GetMetadataValue ("LogicalName") == "LaunchImage@2x.png"), "#13");
Assert.IsTrue (bundleItems.Any (i => i.EvaluatedInclude == Path.Combine (ibtool, "MainStoryboard.storyboardc", "1-view-2.nib") && i.GetMetadataValue ("LogicalName") == "MainStoryboard.storyboardc/1-view-2.nib"), "#14");
Assert.IsTrue (bundleItems.Any (i => i.EvaluatedInclude == Path.Combine (ibtool, "MainStoryboard.storyboardc", "1-view-2.nib", "objects-13.0+.nib") && i.GetMetadataValue ("LogicalName") == "MainStoryboard.storyboardc/1-view-2.nib/objects-13.0+.nib"), "#14.1");
Assert.IsTrue (bundleItems.Any (i => i.EvaluatedInclude == Path.Combine (ibtool, "MainStoryboard.storyboardc", "1-view-2.nib", "runtime.nib") && i.GetMetadataValue ("LogicalName") == "MainStoryboard.storyboardc/1-view-2.nib/runtime.nib"), "#14.2");
Assert.IsTrue (bundleItems.Any (i => i.EvaluatedInclude == Path.Combine (ibtool, "MainStoryboard.storyboardc", "Info.plist") && i.GetMetadataValue ("LogicalName") == "MainStoryboard.storyboardc/Info.plist"), "#15");
Assert.IsTrue (bundleItems.Any (i => i.EvaluatedInclude == Path.Combine (ibtool, "MainStoryboard.storyboardc", "UIViewController-1.nib") && i.GetMetadataValue ("LogicalName") == "MainStoryboard.storyboardc/UIViewController-1.nib"), "#16");
Assert.IsTrue (bundleItems.Any (i => i.EvaluatedInclude == Path.Combine (ibtool, "MainStoryboard.storyboardc", "UIViewController-1.nib", "objects-13.0+.nib") && i.GetMetadataValue ("LogicalName") == "MainStoryboard.storyboardc/UIViewController-1.nib/objects-13.0+.nib"), "#16.1");
Assert.IsTrue (bundleItems.Any (i => i.EvaluatedInclude == Path.Combine (ibtool, "MainStoryboard.storyboardc", "UIViewController-1.nib", "runtime.nib") && i.GetMetadataValue ("LogicalName") == "MainStoryboard.storyboardc/UIViewController-1.nib/runtime.nib"), "#16.2");
if (bundleItems.Length > ExpectedExecutableBundleResources.Length) {
Assert.IsTrue (bundleItems.Any (i => i.EvaluatedInclude == Path.Combine (ibtool, "en.lproj", "TranslatedView.nib", "runtime.nib") && i.GetMetadataValue ("LogicalName") == "en.lproj/TranslatedView.nib/runtime.nib"), "#17");
Assert.IsTrue (bundleItems.Any (i => i.EvaluatedInclude == Path.Combine (ibtool, "FolderView.nib", "runtime.nib") && i.GetMetadataValue ("LogicalName") == "FolderView.nib/runtime.nib"), "#18");
Expand Down
80 changes: 52 additions & 28 deletions msbuild/tests/Xamarin.iOS.Tasks.Tests/TaskTests/IBToolTaskTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ static IBTool CreateIBToolTask (PlatformFramework framework, string projectDir,
};
}

// [Test] - https://github.com/xamarin/xamarin-macios/issues/6970
[Test]
public void TestBasicIBToolFunctionality ()
{
var tmp = Path.Combine (Path.GetTempPath (), "basic-ibtool");
Expand All @@ -81,33 +81,40 @@ public void TestBasicIBToolFunctionality ()
}

string[] expected = { "LaunchScreen~ipad.nib/objects-8.0+.nib",
"LaunchScreen~ipad.nib/objects-13.0+.nib",
"LaunchScreen~ipad.nib/runtime.nib",
"LaunchScreen~iphone.nib/objects-13.0+.nib",
"LaunchScreen~iphone.nib/objects-8.0+.nib",
"LaunchScreen~iphone.nib/runtime.nib",
"Main.storyboardc/BYZ-38-t0r-view-8bC-Xf-vdC~ipad.nib/objects-13.0+.nib",
"Main.storyboardc/BYZ-38-t0r-view-8bC-Xf-vdC~ipad.nib/objects-8.0+.nib",
"Main.storyboardc/BYZ-38-t0r-view-8bC-Xf-vdC~ipad.nib/runtime.nib",
"Main.storyboardc/BYZ-38-t0r-view-8bC-Xf-vdC~iphone.nib/objects-13.0+.nib",
"Main.storyboardc/BYZ-38-t0r-view-8bC-Xf-vdC~iphone.nib/objects-8.0+.nib",
"Main.storyboardc/BYZ-38-t0r-view-8bC-Xf-vdC~iphone.nib/runtime.nib",
"Main.storyboardc/UIViewController-BYZ-38-t0r~ipad.nib/objects-13.0+.nib",
"Main.storyboardc/UIViewController-BYZ-38-t0r~ipad.nib/objects-8.0+.nib",
"Main.storyboardc/UIViewController-BYZ-38-t0r~ipad.nib/runtime.nib",
"Main.storyboardc/UIViewController-BYZ-38-t0r~iphone.nib/objects-13.0+.nib",
"Main.storyboardc/UIViewController-BYZ-38-t0r~iphone.nib/objects-8.0+.nib",
"Main.storyboardc/UIViewController-BYZ-38-t0r~iphone.nib/runtime.nib",
"Main~ipad.storyboardc/Info-8.0+.plist",
"Main~ipad.storyboardc/Info.plist",
"Main~iphone.storyboardc/Info-8.0+.plist",
"Main~iphone.storyboardc/Info.plist"
"Main~iphone.storyboardc/Info.plist",
};

foreach (var bundleResource in expected)
Assert.IsTrue (bundleResources.Contains (bundleResource), "BundleResources should include '{0}'", bundleResource);
var inexistentResource = bundleResources.Except (expected).ToArray ();
var unexpectedResource = expected.Except (bundleResources).ToArray ();

Assert.AreEqual (expected.Length, bundleResources.Count, "Unexpected number of BundleResources");
Assert.That (inexistentResource, Is.Empty, "No missing resources");
Assert.That (unexpectedResource, Is.Empty, "No extra resources");
} finally {
Directory.Delete (tmp, true);
}
}

// [Test] - https://github.com/xamarin/xamarin-macios/issues/6970
[Test]
public void TestAdvancedIBToolFunctionality ()
{
var tmp = Path.Combine (Path.GetTempPath (), "advanced-ibtool");
Expand Down Expand Up @@ -146,29 +153,42 @@ public void TestAdvancedIBToolFunctionality ()
ibtool.EnableOnDemandResources = true;

string[] expected = {
"Base.lproj/LaunchScreen.storyboardc/01J-lp-oVM-view-Ze5-6b-2t3.nib",
"Base.lproj/LaunchScreen.storyboardc/01J-lp-oVM-view-Ze5-6b-2t3.nib/objects-13.0+.nib",
"Base.lproj/LaunchScreen.storyboardc/01J-lp-oVM-view-Ze5-6b-2t3.nib/runtime.nib",
"Base.lproj/LaunchScreen.storyboardc/Info.plist",
"Base.lproj/LaunchScreen.storyboardc/UIViewController-01J-lp-oVM.nib",
"Base.lproj/Linked.storyboardc/5xv-Yx-H4r-view-gMo-tm-chA.nib",
"Base.lproj/LaunchScreen.storyboardc/UIViewController-01J-lp-oVM.nib/objects-13.0+.nib",
"Base.lproj/LaunchScreen.storyboardc/UIViewController-01J-lp-oVM.nib/runtime.nib",
"Base.lproj/Linked.storyboardc/5xv-Yx-H4r-view-gMo-tm-chA.nib/objects-13.0+.nib",
"Base.lproj/Linked.storyboardc/5xv-Yx-H4r-view-gMo-tm-chA.nib/runtime.nib",
"Base.lproj/Linked.storyboardc/Info.plist",
"Base.lproj/Linked.storyboardc/MyLinkedViewController.nib",
"Base.lproj/Main.storyboardc/BYZ-38-t0r-view-8bC-Xf-vdC.nib",
"Base.lproj/Linked.storyboardc/MyLinkedViewController.nib/objects-13.0+.nib",
"Base.lproj/Linked.storyboardc/MyLinkedViewController.nib/runtime.nib",
"Base.lproj/Main.storyboardc/BYZ-38-t0r-view-8bC-Xf-vdC.nib/objects-13.0+.nib",
"Base.lproj/Main.storyboardc/BYZ-38-t0r-view-8bC-Xf-vdC.nib/runtime.nib",
"Base.lproj/Main.storyboardc/Info.plist",
"Base.lproj/Main.storyboardc/MyLinkedViewController.nib",
"Base.lproj/Main.storyboardc/UIViewController-BYZ-38-t0r.nib",
"en.lproj/Linked.storyboardc/5xv-Yx-H4r-view-gMo-tm-chA.nib",
"Base.lproj/Main.storyboardc/MyLinkedViewController.nib/objects-13.0+.nib",
"Base.lproj/Main.storyboardc/MyLinkedViewController.nib/runtime.nib",
"Base.lproj/Main.storyboardc/UIViewController-BYZ-38-t0r.nib/objects-13.0+.nib",
"Base.lproj/Main.storyboardc/UIViewController-BYZ-38-t0r.nib/runtime.nib",
"en.lproj/Linked.storyboardc/5xv-Yx-H4r-view-gMo-tm-chA.nib/objects-13.0+.nib",
"en.lproj/Linked.storyboardc/5xv-Yx-H4r-view-gMo-tm-chA.nib/runtime.nib",
"en.lproj/Linked.storyboardc/Info.plist",
"en.lproj/Linked.storyboardc/MyLinkedViewController.nib",
"en.lproj/Main.storyboardc/BYZ-38-t0r-view-8bC-Xf-vdC.nib",
"en.lproj/Linked.storyboardc/MyLinkedViewController.nib/objects-13.0+.nib",
"en.lproj/Linked.storyboardc/MyLinkedViewController.nib/runtime.nib",
"en.lproj/Main.storyboardc/BYZ-38-t0r-view-8bC-Xf-vdC.nib/objects-13.0+.nib",
"en.lproj/Main.storyboardc/BYZ-38-t0r-view-8bC-Xf-vdC.nib/runtime.nib",
"en.lproj/Main.storyboardc/Info.plist",
"en.lproj/Main.storyboardc/MyLinkedViewController.nib",
"en.lproj/Main.storyboardc/UIViewController-BYZ-38-t0r.nib"
"en.lproj/Main.storyboardc/MyLinkedViewController.nib/objects-13.0+.nib",
"en.lproj/Main.storyboardc/MyLinkedViewController.nib/runtime.nib",
"en.lproj/Main.storyboardc/UIViewController-BYZ-38-t0r.nib/objects-13.0+.nib",
"en.lproj/Main.storyboardc/UIViewController-BYZ-38-t0r.nib/runtime.nib",
};

foreach (var bundleResource in expected)
Assert.IsTrue (bundleResources.Contains (bundleResource), "BundleResources should include '{0}'", bundleResource);
var inexistentResource = bundleResources.Except (expected).ToArray ();
var unexpectedResource = expected.Except (bundleResources).ToArray ();

Assert.AreEqual (expected.Length, bundleResources.Count, "Unexpected number of BundleResources");
Assert.That (inexistentResource, Is.Empty, "No missing resources");
Assert.That (unexpectedResource, Is.Empty, "No extra resources");
} finally {
Directory.Delete (tmp, true);
}
Expand Down Expand Up @@ -217,31 +237,35 @@ static void TestGenericAndDeviceSpecificXibsGeneric (params string[] fileNames)
Assert.IsNotNullOrEmpty (bundleResource.GetMetadata ("Optimize"), "The 'Optimize' metadata must be set.");

Assert.IsNotNullOrEmpty (tag, "The 'ResourceTags' metadata should be set.");
Assert.AreEqual (Path.Combine (tmp, "ibtool", tag + ".nib"), bundleResource.ItemSpec, "BundleResource is not at the expected location.");
Assert.AreEqual (Path.Combine (tmp, "ibtool", tag + ".nib", Path.GetFileName (bundleName)), bundleResource.ItemSpec, $"BundleResource {bundleName} is not at the expected location.");

bundleResources.Add (bundleName);
}

string[] expected = {
"View.nib", "View~ipad.nib"
"View~ipad.nib/objects-13.0+.nib",
"View~ipad.nib/runtime.nib",
"View.nib/objects-13.0+.nib",
"View.nib/runtime.nib",
};

foreach (var bundleResource in expected)
Assert.IsTrue (bundleResources.Contains (bundleResource), "BundleResources should include '{0}'", bundleResource);
var inexistentResource = bundleResources.Except (expected).ToArray ();
var unexpectedResource = expected.Except (bundleResources).ToArray ();

Assert.AreEqual (expected.Length, bundleResources.Count, "Unexpected number of BundleResources");
Assert.That (inexistentResource, Is.Empty, "No missing resources");
Assert.That (unexpectedResource, Is.Empty, "No extra resources");
} finally {
Directory.Delete (tmp, true);
}
}

// [Test] - https://github.com/xamarin/xamarin-macios/issues/6970
[Test]
public void TestGenericAndDeviceSpecificXibsGenericFirst ()
{
TestGenericAndDeviceSpecificXibsGeneric ("View.xib", "View~ipad.xib");
}

// [Test] - https://github.com/xamarin/xamarin-macios/issues/6970
[Test]
public void TestGenericAndDeviceSpecificXibsGenericLast ()
{
TestGenericAndDeviceSpecificXibsGeneric ("View~ipad.xib", "View.xib");
Expand Down

0 comments on commit 1a3326a

Please sign in to comment.