xamarin-macios/tests
Rolf Bjarne Kvinge 4d5d38be02
Drop the Xcode 9.4 dependency. (#7044) (#7135)
* Drop the Xcode 9.4 dependency. (#7044)

* Drop the Xcode 9.4 dependency.

Also bump mono to get the removal of the mac32 binaries.

New commits in mono/mono:

* mono/mono@beb9a1b182 [sdks] Remove the mac32 build.
* mono/mono@747a919a06 [ci] Make ios/mac sdks archive URL more predictable
* mono/mono@114013096e [ci] Build iOS/Mac Mono sdks archive using Xcode 11
* mono/mono@10a24f3ea1 Implement WriteCore and ReadCore in DeflateStream
* mono/mono@a925846b1f [offsets-tool] Install clang into the user-specific python directory. (#16933)
* mono/mono@fe64a4765e [2019-06] Bump msbuild and sdk versions to 3.0.1xx latest (#16870)
* mono/mono@7293597b90 [corlib] Fix building nunit-lite twice (#16910)
* mono/mono@1648e88687 Rename bundle identifier for the various Mono.frameworks we create for Xamarin.iOS. Fixes xamarin/xamarin-macios#7005. (#16896)
* mono/mono@a6b5187d76 [metadata] Fix leaks when handling a few attributes (#16675) (#16851)
* mono/mono@7da9a041b3 [2019-06] Bump to mono/corefx@e79cf5b
* mono/mono@2b7050bdf3 [2019-06] Add RenamedEvent* to FSW sources from CoreFX (#16758)
* mono/mono@4f5ed502c6 [msbuild] pick up p4 versions
* mono/mono@f04ee2219d [2019-06][msbuid][roslyn] Bump msbuild and roslyn-binaries to pick up dotnet 3.0.100-p9 toolset
* mono/mono@6b4b99e571 Vtable [i] can be null so this should be check before use it. Fixes #16712

Diff: 7af64d1ebe..beb9a1b182

* [tests] Add a fat macOS dylib for testing purposes.

Add a binary version of a fat macOS dylib (because we can't create one when we
need it since we can't create 32-bit slice anymore).

It was created like this (in tests/test-libraries):

	$ cat test.m
	int theUltimateAnswer ()
	{
		return 42;
	}

	$ /Applications/Xcode94.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang test.m -olibtest.i386.dylib -shared -isysroot /Applications/Xcode94.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk -framework Foundation -framework CoreLocation -lz  -arch i386
	$ lipo -create libtest.i386.dylib .libs/macos/libtest.dylib -output libtest-fat.dylib

* [tests] Adjust XM tests to XM not having fat dylibs anymore.

* [tests] Adjust product tests to some libraries not being fat anymore.

* [tests] Don't treat an Xcode with the same major version number as old.

Fixes an issue in the MT0091 test, where it would fail on tvOS because the
test wanted to use an older Xcode, and we could end up returning Xcode 11.0
when the current Xcode is 11.1. Since the test depends on using the OS SDK as
it was designed for (technically using an OS SDK earlier than the latest), it
ended up failing because while the iOS SDK was bumped in Xcode 11.1, the tvOS
SDK was not.
2019-10-01 16:18:28 +02:00
..
BundledResources [xharness] Add ARM64_32 support. 2019-05-22 08:06:44 +02:00
EmbeddedResources [xharness] Add ARM64_32 support. 2019-05-22 08:06:44 +02:00
api-shared [runtime] Improve exception creation. (#5944) 2019-04-26 11:16:23 +02:00
apitest Merge xcode11 into d16-3. 2019-09-12 08:29:02 +02:00
bcl-test Merge xcode11 into d16-3. 2019-09-12 08:29:02 +02:00
bindings-framework-test [xharness] Add ARM64_32 support. 2019-05-22 08:06:44 +02:00
bindings-test [xharness] Add ARM64_32 support. 2019-05-22 08:06:44 +02:00
bindings-test2 [xharness] Add ARM64_32 support. 2019-05-22 08:06:44 +02:00
common Drop the Xcode 9.4 dependency. (#7044) (#7135) 2019-10-01 16:18:28 +02:00
framework-test [tests] Enable LLVM for all Release|Device configurations. (#3376) 2018-02-01 17:59:40 +01:00
fsharp Bump the minimum iOS version to 7.0. Fixes #6213. (#6878) 2019-08-30 01:07:30 -07:00
fsharplibrary [xharness] Add ARM64_32 support. 2019-05-22 08:06:44 +02:00
generator Merge remote-tracking branch 'origin/xcode11' into d16-3. 2019-09-17 08:30:12 +02:00
interdependent-binding-projects Merge xcode11 into d16-3. 2019-09-12 08:29:02 +02:00
introspection Merge remote-tracking branch 'origin/xcode11' into d16-3-xcode11-v2 2019-09-17 08:40:53 +02:00
linker Merge xcode11 into d16-3. 2019-09-12 08:29:02 +02:00
mac-binding-project Merge branch 'master' into mono-2018-10 2018-11-29 13:41:32 +01:00
mini Merge xcode11 into d16-3. 2019-09-12 08:29:02 +02:00
misc [tests] Import 2016-05-26 15:06:52 +02:00
mmptest Drop the Xcode 9.4 dependency. (#7044) (#7135) 2019-10-01 16:18:28 +02:00
mono-native Merge xcode11 into d16-3. 2019-09-12 08:29:02 +02:00
monotouch-test [Tests] Make the CoreBluetooth tests more reliable. (#7115) 2019-09-26 17:07:57 -04:00
msbuild-mac [xcode11] Stop building/shipping 32-bit Xamarin.Mac bits. Partial fix for #6300. (#6393) 2019-07-15 10:19:24 -07:00
mtouch Merge xcode11 into d16-3. 2019-09-12 08:29:02 +02:00
no-mmp Remove more usage of mcs across the build and tests (#3815) 2018-04-18 11:17:00 +02:00
qa-regression Mono 2018-08 requires macOS 10.9+, so Xamarin.Mac must as well. 2018-10-25 09:54:43 +02:00
sampletester [sampletester] Bump xamarin-forms-book-samples to the tip of master, where a few fixes have been merged. (#6584) 2019-07-15 22:47:24 -07:00
scripted Remove more usage of mcs across the build and tests (#3815) 2018-04-18 11:17:00 +02:00
scriptingbridge Mono 2018-08 requires macOS 10.9+, so Xamarin.Mac must as well. 2018-10-25 09:54:43 +02:00
templates [tests] Run tests on watchOS in a background thread. (#6170) 2019-05-30 08:40:30 -07:00
test-libraries Drop the Xcode 9.4 dependency. (#7044) (#7135) 2019-10-01 16:18:28 +02:00
xammac_tests [monotouch-test] Fix ProxyTest according to changed behavior in iOS 13. 2019-09-13 16:16:22 +02:00
xharness [xharness] Bring more joy to the developer when all tests pass 🎉 (#6962) (#7037) 2019-09-20 14:11:03 -04:00
xtro-sharpie [AppKit] Add missing Accessibility protocols. (#7105) 2019-09-26 09:46:38 -04:00
.gitignore [UIKit] Partial update to Xcode 11 Beta 1 and 2 - Part 1 of ? (#6392) 2019-06-21 18:25:04 -04:00
HtmlTransform.xslt [tests] Move HtmlTransform.xslt here from maccore. (#16) 2016-04-28 15:07:26 -04:00
Makefile Fix downloading mono archive when running device tests. 2019-09-16 14:49:22 +02:00
README.md [tests/README.md] Fix a typing error (#6464) 2019-07-01 11:43:59 +02:00
common.mk Move tests to use new tool xibuild and thus fix msbuild tests (#5128) 2018-11-16 14:24:35 -05:00
package-mac-tests.sh Bump to mono:2019-06 (#6196) 2019-07-16 17:24:00 +02:00
test-dependencies.sh [system-dependencies] Add logic to auto-provision cmake. (#940) 2016-10-04 10:28:41 +02:00
tests-mac.sln [tests] Fix stale data in tests-mac.sln after recent changes. 2019-06-26 14:06:30 +02:00
tests.sln [XHarness] Remove the mini tests since they are not longer needed. (#6152) 2019-05-28 11:52:31 -07:00

README.md

Various tests to be executed prior to releases

Test solutions

Many of the test solutions and test projects are generated, and will only be available after running make once.

  • tests.sln: This is the base test solution for Xamarin.iOS, which targets iOS using the Unified API. Not generated.
  • tests-tvos.sln: All the TVOS test projects. Generated.
  • tests-watchos.sln: All the WatchOS test projects. Generated.
  • tests-mac.sln: This is the base test solution for Xamarin.Mac. Not generated.

Test solution/project generation

The tool that generates the test solutions / projects is called xharness, and lives in the xharness subdirectory.

Types of Tests

Unit Tests

Most of the projects are using NUnit[Lite] and looks like unit tests. They are meant to be executed on the target: simulator, devices, OSX.

In reality most of them are regression tests - but that does not change the need to execute and continually expand them to cover new code.

Introspection Tests

Introspection tests are executed on target (both simulator and device for iOS) or a specific version of OSX. The application proceed to analyze itself using:

  • System.Reflection for managed code; and
  • the ObjectiveC runtime library for native code

and compare the results. E.g. if using .NET reflection it can see a binding for a NSBundle type then it should be able to find a native NSBundle type using the ObjC runtime functions. Otherwise an error is raised...

Since the application analyze itself it must contains everything we wish to test. That's why the introspection tests are part of the dontlink.app application (for iOS) and the dontlink-mac project (for OSX).

Pros

  • They always tell the truth, which can differ from documentation

Cons

  • Incomplete - Not everything is encoded in the metadata / executable;
  • Too complete - Not every truth is good to be known (or published)

Extrospection Tests

Extrospection tests takes data from some outside sources and see if our implementation match the information, e.g.

  • Header files from the SDK;
  • Rules, like Gendarme or FxCop;

Since this is done externally there's no need to run them on the devices, simulator or even a specific version of OSX.

Pro

  • There is more data available, e.g. information lost when compiling

Con

  • The data might not represent the truth (errors, false positives...)

Xamarin.Mac

Many tests when run for macOS use a integration hack which helps handle a number of issues:

  • Allowing command line arguments to tests while excluding "psn" arguments passed in while debugging with Visual Studio for Mac
  • Optionally integrating with the macOS message loop for tests that require it (anything that uses most Cocoa primitives).
  • Invoking _exit to work around a number of post-test hangs. See the bug for details.
  • Add a number of "default" excludes for mono BCL tests

One very useful "hack" this support adds is the ability to run a single test from the command line via the XM_TEST_NAME environmental variable. For example

XM_TEST_NAME=MonoTouchFixtures.Security.KeyTest.CreateRandomKeyWithParametersTests make run-mac-unified-xammac_tests

Test Suites

*-tests : where * is the assembly name, e.g. monotouch

Use the project defaults for linking, i.e.

  • "Don't link" for simulator

  • "Link SDK assemblies only" for devices

  • regression testing without using the linker

  • both simulator and devices are set to "Don't link"

linkall

  • regression testing using the linker on the all assemblies

  • "Link all assemblies" for both simulator/devices

linksdk

  • regression testing using the linker on the SDK assemblies

  • "Link SDK assemblies only" for both simulator/devices

bcl-test

These are the Mono BCL test suite tweaked to run on the mobile profile. It reuse the files directly from mono's repository (linking, not copying).

As other unit tests the configuration is set to mimick normal apps, e.g.

  • "Don't link" for simulator

  • "Link SDK assemblies only" for devices

Common make targets

Run every test in both the simulator and on device, using both the compat and the new profile (for the simulator both in 32 and 64bit mode).

$ make run

Run every test in the simulator, using both the compat and the new profile (both 32 and 64bit simulators).

$ make run-all-sim

Run every test on device, using both the compat and the new profile

$ make run-all-dev

Detailed make targets

  • Main target

    • run-what-where-project: Builds, installs (if applicable) and runs the specified test project on the specified platform. This is the most common target to use.
    • build-what-where-project: Will build the specified test project for the specified platform and target.
    • install-what-where-project: Will install the specified test project on a connected device. There's currently no way to select the device, so ensure you've only one connected (if many devices are connected, it's random which will used).
    • exec-what-where-project: Will run the specified test project in the simulator or on a device.
  • What

    • -ios-: iOS.
    • -tvos-: TVOS.
    • -watchos-: WatchOS

    If "What" is skipped, all variations are executed sequentially.

  • Where

    • -simclassic-: Simulator using the Classic API. Only applicable when platform is iOS.
    • -simunified-: Simulator using Unified API. The build will contain both an i386 and an x86_64 binary. Only applicable to the build-* target, while the -sim32- and -sim64- are only applicable to the exec-* targets. Only applicable when the platform is iOS.
    • -sim32-: 32bits iOS simulator using the Unified API. Not applicable to other platforms.
    • -sim64-: 64bits iOS simulator using the Unified API. Not applicable to other platforms.
    • -sim-:
      • iOS: Both the -simclassic- and -simunified- versions.
      • WatchOS/TVOS: The WatchOS/TVOS simulator.
    • -devclassic-: Device using the Classic API. Only applicable when the platform is iOS.
    • -devunified-: Device using the Unified API. The build will contain both an armv7 and an arm64 binary. It's not possible to select a 32/64bit version, you'll run what your device supports. Only applicable when the platform is iOS.
    • -dev-:
      • iOS: Both the -devclassic- and -devunified- versions.
      • WatchOS/TVOS: A Watch or TV device.
  • Examples

    $ make run-ios-sim32-monotouchtest: This will run monotouch-test using the Unified API in a 32-bit simulator. $ make run-tvos-dev-dont\ link: This will run dont link on an Apple TV device.

Utility run-* targets

These targets will build, install (if applicable) and run the specified project(s).

  • Simulator

    • run-sim-project: Builds and runs the specified test project in the simulator in compat, 32 and 64bit mode.
    • run-sim: Builds and runs all the non-bcl test projects in the simulator in compat, 32 and 64bit mode.
  • Device

    • run-dev-project: Builds and runs the specified non-bcl test project on a device in compat and native mode (if it's 32 and 64bit depends on the device; 64bit devices will run in 64bit mode and the same for 32bit devices).
    • run-devcompat: Run all the non-bcl test projects on device, in compat mode.
    • run-devdual: Run all the non-bcl test projects on device, in native mode (if it's 32 and 64bit depends on the device; 64bit devices will run in 64bit mode and the same for 32bit devices).
    • run-dev: Run all the non-bcl test projects on device, in both compat and native mode.