Граф коммитов

6345 Коммитов

Автор SHA1 Сообщение Дата
Rolf Bjarne Kvinge 0dfadd0c01
[tests] Try to make CoreServices.FSEventStreamTest behave better. (#18844)
Try to make CoreServices.FSEventStreamTest better by using shorter duration locks,
and re-checking success condition after timing out in case there’s a race condition.

Also improve exception reporting/logging a bit.

Ref: https://github.com/xamarin/maccore/issues/2630
2023-08-29 07:29:12 +02:00
dustin-wojciechowski 1b016fa072
[MacCatalyst] Added Default Entitlements for MacCatalyst projects (#18669)
Added default entitlements for MacCatalyst templates.
For Debug, the com.apple.security.get-task-allow entitlement that allows for using developer tools when developing MAUI Blazor apps.
For release, com.apple.security.app-sandbox is required to publish MacCatalyst apps to the Mac App Store.

Also added unit test to check for entitlements when project is created.

Fixes #18344

---------

Co-authored-by: GitHub Actions Autoformatter <github-actions-autoformatter@xamarin.com>
Co-authored-by: Rolf Bjarne Kvinge <rolf@xamarin.com>
2023-08-28 09:14:25 -07:00
Rolf Bjarne Kvinge d9405ff27c
[tests] Misc changes to make tests work/pass when .NET isn't enabled. (#18828) 2023-08-28 16:15:28 +02:00
Rolf Bjarne Kvinge e111b8701b
[tests] Add support for specifying whether build properties should be specified on the command line or in a file. (#18814)
Some time ago we added a workaround for an msbuild bug that has since
been fixed (since the initial .NET 7 release). This workaround involved
writing build properties to a file instead of passing them on the
command line.

We no longer need the workaround, but it turnes out we still need to be
able to pass build properties in a file (because we have a test that
needs this behavior). We'll also soon run into a scenario where we need
to be able to specify a build property on the command line
(`TargetFrameworks`) - the build won't work if specified in a file.

So add support for both, and make the test that needs to specify the
build property on the command line say so explicitly.
2023-08-28 14:43:35 +02:00
Rolf Bjarne Kvinge 61493dd438
[msbuild] Store the command line to sign in the stamp file. Fixes #16124. (#18750)
When figuring out whether something needs to be (re)signed or not, we must
also take into account that the signing identity may have changed (for
instance a release build will often have a different signing identity than a
debug build).

Do this by storing the command line to sign for each item we need to sign in
the stamp file, and if the stored contents don't match the new command line
to sign, then we must resign the item.

This is rather obnoxious to write unit tests for (since we'd need to have two
different signing identities available on the bots), so I've only done local
testing.

Fixes https://github.com/xamarin/xamarin-macios/issues/16124.
2023-08-22 12:34:16 +02:00
Rolf Bjarne Kvinge 9937f17f99
[tests] Disable build parallelism when setting IntermediateOutputPath as a property for the build. (#18731)
* A property set on the command line is set for all projects that are built,
  including projects referenced by the main project.
* If the main project references more than one project, those referenced
  projects may be built in parallel.
* This means multiple projects might have the same IntermediateOutputPath if
  set on the command line, and thus accessing files in the directory
  simultaneously, which is a bad idea.

Fix this by manually disabling build parallelism in tests that set
IntermediateOutputPath.

Fixes https://github.com/xamarin/maccore/issues/2567.
2023-08-18 16:50:20 +02:00
Rolf Bjarne Kvinge a03fbb70f9
Run the generator tests on Windows. (#18513)
We'll soon change the generator to execute locally on Windows, even for
remote builds. As a stepping stone towards that goal, this PR adds the
generator tests to the list of tests we run on Windows.
2023-08-18 16:04:59 +02:00
Rolf Bjarne Kvinge 47b5601ffc
[tests/xharness] Add support for setting test configuration using environment variables. (#18738)
Setting test configuration variables using the environment is useful
when running tests on a Windows machine (easier than having to deal with
make).

Also refactor the code a bit to not use constants, and more consistent
naming.
2023-08-16 10:34:02 +02:00
Rolf Bjarne Kvinge d6c79bffb3
[tests] Add missing check for available runtime identifiers in a few tests. (#18739) 2023-08-16 10:29:42 +02:00
Rolf Bjarne Kvinge cb1ffa0da7
[monotouch-test] Fix BlocksTest to work on maccatalyst-arm64. (#18708)
We use the AOT compiler on ARM64 on Mac Catalyst, so these tests have to
be excluded on Mac Catalyst.
2023-08-14 12:05:03 +02:00
Rolf Bjarne Kvinge 72a7f88b94
[tests] Improve assertion when a .NET test fails executing 'dotnet'. (#18700)
Improve assertion when a .NET test fails executing 'dotnet' by including
more information (any errors in particular) in the assert message.
2023-08-14 11:57:21 +02:00
Rolf Bjarne Kvinge 24895406b2
[dotnet] Link Mono and Xamarin statically in Mac Catalyst by default. Fixes #14686. (#18619)
It's possible to create a provisioning profile for Mac Catalyst that
doesn't allow dylibs in the app. It seems a significant number of people run
into this problem when publishing their apps, so avoid it by linking Mono and
Xamarin statically by default instead.

The downside is that build time might increase a little bit.

An upside however is that the app size might decrease somewhat.

Fixes https://github.com/xamarin/xamarin-macios/issues/14686.
2023-08-11 15:08:27 +02:00
Rolf Bjarne Kvinge 8732e1cedd
[xharness] Stop hardcoding the target framework in xharness. (#18682) 2023-08-10 13:14:34 +02:00
Rolf Bjarne Kvinge a64104cf76
[tests] Filter out any warnings about out-of-support workloads. (#18679)
Our test projects may be using an earlier version of .NET (in particular
Touch.Unit and MonoTouch.Dialog often are), so ignore any warnings about
out-of-support workloads.

Fixes test failures like:

    Xamarin.Tests.BundleStructureTest.Build(MacCatalyst,"maccatalyst-x64;maccatalyst-arm64",All,"Debug"): Warnings

        Expected is <System.Collections.Generic.List`1[System.String]> with 22 elements, actual is <System.String[28]>
        Values differ at index [22]
        Extra: < "The workload 'maccatalyst' is out of support and will not receive security updates in the future. Please refer to https://aka.ms/maui-support-policy for more information about the support policy.", "The workload 'maccatalyst' is out of support and will not receive security updates in the future. Please refer to https://aka.ms/maui-support-policy for more information about the support policy.", "The workload 'maccatalyst' is out of support and will not receive security updates in the future. Please refer to https://aka.ms/maui-support-policy for more information about the support policy."... >
2023-08-10 10:28:34 +02:00
Rolf Bjarne Kvinge 2eddcf8eea
[tests] Parse configure.inc for build settings as well. (#18674)
Additionally parse files in reverse order, because any variables at the
end should take precedence (when parsing config files the first time
variable is found is the one we use).
2023-08-10 07:55:50 +02:00
Manuel de la Pena 716e8baf63
[Generator] Ensure that selectors fields do not have overlapping names. Fixes #18645 (#18646) 2023-08-08 09:25:21 -04:00
Rolf Bjarne Kvinge b17626ff1c
[msbuild] Re-aot referencing assemblies. Fixes #17708. (#18509)
If an assembly changes, then we must AOT compile that assembly again (which we already
did), in addition to any assembly that references the modified assembly (which we
didn't do).

So rework the AOTCompile target: remove the Inputs and Outputs (because the dependency
tracking is too complicated for MSBuild to resolve), and instead move the logic to
detect if an assembly must be AOT-compiled again into the AOTCompile task.

Note that this PR has a custom port to .NET 8: #18518.

Fixes https://github.com/xamarin/xamarin-macios/issues/17708.

---------

Co-authored-by: Alex Soto <alex@alexsoto.me>
2023-08-07 20:19:30 +02:00
Rolf Bjarne Kvinge 1e7e084fd1
[tests] If listing included platforms for .NET, don't include anything if .NET isn't enabled. (#18637) 2023-08-07 15:39:42 +02:00
Manuel de la Pena e4ed7e18bf
[Introspection] Fix intro skip when the properties are internal. (#18613) 2023-08-02 07:46:45 -04:00
Alexander Köplinger bfb8665d19
Convert XHarness.Tests from packages.config to PackageReference and add darc dependency (#18611)
Also needed a few tweaks to fix build errors that were introduced
recently.

---------

Co-authored-by: Manuel de la Pena <mandel@microsoft.com>
2023-08-02 13:39:33 +02:00
Manuel de la Pena c4c95b368b
[Tests] Use the correct nuget version on CI (#18610)
Similar to PR https://github.com/xamarin/xamarin-macios/pull/18600 we
need to use the same verison as the one found in the workload file in CI
and not that one from the make.config.

---------

Co-authored-by: GitHub Actions Autoformatter <github-actions-autoformatter@xamarin.com>
2023-08-01 23:51:19 -04:00
Manuel de la Pena 78f8985ac5
Update tests/xharness/Harness.cs 2023-07-28 12:50:37 -04:00
Manuel de la Pena a4972fd1bd Merge branch 'fix-mlaunch-location' of github.com:mandel-macaque/xamarin-macios into fix-mlaunch-location 2023-07-28 12:48:45 -04:00
Manuel de la Pena cc78a45eb6 Fix ompilation. 2023-07-28 12:45:21 -04:00
Manuel de la Pena 3a02f2b721
Update tests/xharness/Harness.cs
Co-authored-by: Haritha Mohan <harithamohan@microsoft.com>
2023-07-28 11:32:18 -04:00
Manuel de la Pena 290206629a [Xharness] Fix path to mlaunch when using mlaunch from a .NET SDK pack on CI.
This commit fixes the code that was added in
https://github.com/xamarin/xamarin-macios/pull/16361.

The previous change uses the version number that is part of the config
file in the current build machine. That is correct when we are working
when we are running the tests in the same machine that built them. That
IS NOT THE CASE when building on CI.

Back when the CI did the separation to accommodate the EO we noticed
that if the workload is built in a diff machine, the versions were not
to be trusted, that is why the CI sets and enviroment variable to track
the version that was built in the original step. This change check if we
are on the CI, if we are we trust the version given by the previos
machine, else we use the config one.
2023-07-28 11:13:28 -04:00
JonnHard d1d3dcdf68
Add getFileProviderConnectionWithCompletionHandler signature to start… (#18533)
… supporting XPC on File Provider instance

File Provider Service can act as an standalone XPC that you can
establish the connection with.
To open up the capability this new signature has to be exposed

---------

Co-authored-by: GitHub Actions Autoformatter <github-actions-autoformatter@xamarin.com>
Co-authored-by: Alex Soto <alex@alexsoto.me>
2023-07-20 10:39:08 -04:00
Rolf Bjarne Kvinge 64b4a5909a
[tests] Automatic network failure detection in tests. (#18439)
Detect if a url we use in our tests actually works, and if not, save the
results and ignore any subsequent test that tries to use that url.

---------

Co-authored-by: Haritha Mohan <harithamohan@microsoft.com>
2023-06-29 07:48:53 +02:00
Meri Khamoyan 3f6d43c756
[iOS] HybridGlobalization set flag in SDK (#18498)
Add HybridGlobalization flag in SDK and load icudt_hybrid.dat file when
HybridGlobalization is on.

Contributes to https://github.com/dotnet/runtime/issues/80689
2023-06-28 10:25:24 +02:00
Rolf Bjarne Kvinge 7f910487f5
[msbuild/dotnet] Handle dylibs that don't start with 'lib' better. Fixes #15044. (#18496)
For a given dylib named '/path/to/libMyLibrary.dylib', we pass this to the native linker:

    -L/path/to -lMyLibrary

however, that doesn't work unless the dylib's name starts with 'lib'.

So detect this, and if the dylib doesn't start with 'lib' (say it's just
'MyLibrary.dylib'), then just pass the path to the dylib as-is to the native
linker:

	/path/to/MyLibrary.dylib

Fixes https://github.com/xamarin/xamarin-macios/issues/15044.
2023-06-27 07:55:04 +02:00
EmilienDup 7cea2a8c3a
NSUrlSessionHandler should propagate network exceptions (#18459)
fixes #18458
2023-06-20 07:27:46 +02:00
Rolf Bjarne Kvinge aab0ed1362
[AVFoundation] Fix a few issues with the AVAssetImageGenerator bindings. Partial fix for #18452. (#18460)
* The 'copyCGImageAtTime:actualTime:error:' selector is deprecated, so
replicate that.
* Bind the 'generateCGImageAsynchronouslyForTime:completionHandler:'
selector.

Fixes parts 1 and 2 of https://github.com/xamarin/xamarin-macios/issues/18452.
2023-06-19 19:16:29 +02:00
Rolf Bjarne Kvinge 959bb55d86
[tests] Fix formatting issues. (#18453) 2023-06-16 13:58:49 +02:00
Rolf Bjarne Kvinge 7df3eb1520
[dotnet] Add targets to compute mlaunch arguments for installing and launching mobile apps. Fixes #18359. (#18446)
Add public targets to compute the mlaunch command lines for installing
and launching mobile apps.

These new targets are:

* ComputeMlaunchInstallArguments
* ComputeMlaunchRunArguments

As part of this change, also create a few new public properties:

* MlaunchPath
* MlaunchRunArguments
* MlaunchInstallArguments
* MlaunchRunScript
* MlaunchInstallScript

If the *Script variables are set, the corresponding target will create a
script file with the path to mlaunch + the corresponding arguments.

Otherwise, it's also possible to get the arguments directly from the
build log.

Fixes https://github.com/xamarin/xamarin-macios/issues/18359.
2023-06-15 07:21:09 +02:00
Rolf Bjarne Kvinge 9e2143032f
Use Enum.GetValues<T> instead of Enum.GetValues in numerous places for .NET. (#18382)
NativeAOT warns about Enum.GetValues and suggests using Enum.GetValues<T>
instead, so do just that.
2023-06-07 08:47:55 +02:00
Haritha Mohan 4bbd7df8f5
[dotnet] Enable runtime identifiers to be overriden at build time (#18396)
Fixes #17707
The error target for when there is a conflict of interest in defining
both the runtime identifier and runtime identifiers is called during the
multi-rid builds, but not sure if the placement is the most ideal..

---------

Co-authored-by: GitHub Actions Autoformatter <github-actions-autoformatter@xamarin.com>
Co-authored-by: Rolf Bjarne Kvinge <rolf@xamarin.com>
Co-authored-by: Alex Soto <alex@alexsoto.me>
2023-06-06 13:49:29 -07:00
Rolf Bjarne Kvinge b59587a0cd
[tests] Rework TestRuntime.RunAsync. (#18391)
* Move all the RunAsync logic to the TestRuntime class, instead of having some
  in TestRuntime and some in AppDelegate.
* Create a unified Task-based implementation for all platforms, optionally showing
  a UI on the platforms where we can do that.
* Remove all the overloads that took a DateTime timeout, and instead only use a
  TimeSpan timeout. This simplified some of the code.
* The new Task-based implementation will capture any exceptions (and rethrow most
  of them) from the tasks we're waiting for, so no need to do that in each RunAsync
  caller. This simplifies the testing code a lot for some tests.
* Add a new TryRunAsync method that will return (instead of rethrowing) any exceptions.
  This simplifies some of the testing code (which verifies the correct exception,
  or ignores the test in case of some exceptions).
* The new Task-based implementation will bubble up any NUnit exceptions, which
  means that the tasks we're waiting for can call NUnit's Assert and the right thing
  happens (in particular Assert.Ignore will actually ignore the test).
2023-06-06 21:36:49 +02:00
Rolf Bjarne Kvinge 1ca3c6ad8a
[tests] Adjust a few tests to not write a temporary file into the user directory. (#18394)
Fixes:

    MonoTouchFixtures.Foundation.NSFileManagerTest
    	[FAIL] GetSkipBackupAttribute : System.UnauthorizedAccessException : Access to the path '/private/var/mobile/Containers/Data/Application/F9F5B72D-D452-49F9-93AC-5CBB1E60A81C/DoNotBackupMe-NSFileManager-14036' is denied.
      ----> System.IO.IOException : Operation not permitted
    		   at Interop.ThrowExceptionForIoErrno(ErrorInfo , String , Boolean )
    		   at Interop.CheckIo(Error , String , Boolean )
    		   at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String , OpenFlags , Int32 , Func`4 )
    		   at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String , FileMode , FileAccess , FileShare , FileOptions , Int64 , UnixFileMode , Int64& , UnixFileMode& , Func`4 )
    		   at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String , FileMode , FileAccess , FileShare , FileOptions , Int64 , Nullable`1 , Func`4 )
    		   at System.IO.File.OpenHandle(String , FileMode , FileAccess , FileShare , FileOptions , Int64 )
    		   at System.IO.File.WriteToFile(String , FileMode , String , Encoding )
    		   at System.IO.File.WriteAllText(String , String , Encoding )
    		   at System.IO.File.WriteAllText(String , String )
    		   at MonoTouchFixtures.Foundation.NSFileManagerTest.GetSkipBackupAttribute() in xamarin-macios/tests/monotouch-test/Foundation/FileManagerTest.cs:line 98
    		   at System.Reflection.MethodInvoker.InterpretedInvoke(Object , Span`1 , BindingFlags )
    		--IOException
    MonoTouchFixtures.Foundation.UrlTest
    	[FAIL] IsExcludedFromBackupKey : System.UnauthorizedAccessException : Access to the path '/private/var/mobile/Containers/Data/Application/F9F5B72D-D452-49F9-93AC-5CBB1E60A81C/DoNotBackupMe-NSUrl-14036' is denied.
      ----> System.IO.IOException : Operation not permitted
    		   at Interop.ThrowExceptionForIoErrno(ErrorInfo , String , Boolean )
    		   at Interop.CheckIo(Error , String , Boolean )
    		   at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String , OpenFlags , Int32 , Func`4 )
    		   at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String , FileMode , FileAccess , FileShare , FileOptions , Int64 , UnixFileMode , Int64& , UnixFileMode& , Func`4 )
    		   at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String , FileMode , FileAccess , FileShare , FileOptions , Int64 , Nullable`1 , Func`4 )
    		   at System.IO.File.OpenHandle(String , FileMode , FileAccess , FileShare , FileOptions , Int64 )
    		   at System.IO.File.WriteToFile(String , FileMode , String , Encoding )
    		   at System.IO.File.WriteAllText(String , String , Encoding )
    		   at System.IO.File.WriteAllText(String , String )
    		   at MonoTouchFixtures.Foundation.UrlTest.IsExcludedFromBackupKey() in xamarin-macios/tests/monotouch-test/Foundation/UrlTest.cs:line 54
    		   at System.Reflection.MethodInvoker.InterpretedInvoke(Object , Span`1 , BindingFlags )
    		--IOException
2023-06-06 18:28:23 +02:00
Rolf Bjarne Kvinge 11e7883da0
[tests] System.Numerics.Vector3.Length is a method, not a property, so treat it as such. (#18401)
Fixes:

    MonoTouchFixtures.Phase.PhaseObjectTest
    	[FAIL] ForwardTest :   length
			Expected: 1
			But was:  <System.Func`1[System.Single]>
    	[FAIL] RigthTest :   length
			Expected: 1
			But was:  <System.Func`1[System.Single]>
    	[FAIL] UpTest :   length
			Expected: 1
			But was:  <System.Func`1[System.Single]>
2023-06-05 15:46:33 +02:00
Rolf Bjarne Kvinge 8d3a1aff7e
[tests] Fix warnings in tests/bgen/bgen-tests.csproj and enforce no more nullability warnings. (#18400) 2023-06-05 10:42:33 +02:00
Rolf Bjarne Kvinge 481ce215c9
[tests] Update the Xcode version check for Xcode 13.3. (#18390)
Fixes:

    MonoTouchFixtures.AVFoundation.CaptureMetadataOutputTest
    	[PASS] Defaults
    	[PASS] Flags
    	[FAIL] MetadataObjectTypesTest : System.NotImplementedException : The method or operation is not implemented.
    		   at TestRuntime.CheckXcodeVersion(Int32 major, Int32 minor, Int32 build) in xamarin-macios/tests/common/TestRuntime.cs:line 483
    		   at MonoTouchFixtures.AVFoundation.CaptureMetadataOutputTest.MetadataObjectTypesTest() in xamarin-macios/tests/monotouch-test/AVFoundation/CaptureMetadataOutputTest.cs:line 131
    		   at System.Reflection.MethodInvoker.InterpretedInvoke(Object , Span`1 , BindingFlags )
2023-06-05 10:27:32 +02:00
Rolf Bjarne Kvinge d33a5d812d
[tests] Use the NetworkResources class for urls instead of hardcoding them. (#18374) 2023-06-02 15:27:41 +02:00
Rolf Bjarne Kvinge a43b664584
[Foundation] Several fixes to NSFileManager. (#18371)
* Enable nullability.
* Add API that was previously iOS-specific to all platforms.
2023-06-02 15:19:42 +02:00
Rolf Bjarne Kvinge 7198886910
[tests] Give the CGImagePropertiesGPSTest some latitude with the coordinates. (#18375)
Seems like the actual values on device might be ever so slightly off.
2023-06-02 14:35:51 +02:00
Rolf Bjarne Kvinge 9e14229176
[tests] Adjust BundleTest to not use Assembly.Location, since it doesn't work in NativeAOT. (#18376) 2023-06-02 14:35:01 +02:00
Rolf Bjarne Kvinge fad26bcc3e
[tests] Adjust BundleTest to cope with a differently named app. (#18392)
It seems the actual app name might be "PublicStaging.app" on device now.

Fixes:

    MonoTouchFixtures.CoreFoundation.BundleTest
        [FAIL] TestExecutableUrl :
            Expected: String containing "monotouchtest.app/monotouchtest"
            But was:  "file:///private/var/containers/Bundle/Application/4B2AD441-C411-42D4-ACCB-4E964A905A17/PublicStaging.app/monotouchtest"
        [FAIL] TestResourcesDirectoryUrl :
            Expected: String containing "monotouchtest.app/"
            But was:  "file:///private/var/containers/Bundle/Application/4B2AD441-C411-42D4-ACCB-4E964A905A17/PublicStaging.app/"
        [FAIL] TestSupportFilesDirectoryUrl :
            Expected: String containing "monotouchtest.app/"
            But was:  "file:///private/var/containers/Bundle/Application/4B2AD441-C411-42D4-ACCB-4E964A905A17/PublicStaging.app/"
         [FAIL] TestUrl :
            Expected: String containing "monotouchtest.app/"
            But was:  "file:///private/var/containers/Bundle/Application/4B2AD441-C411-42D4-ACCB-4E964A905A17/PublicStaging.app/"
2023-06-02 14:32:05 +02:00
Rolf Bjarne Kvinge d98be15ea7
[tests] Fix typo in method name. (#18393) 2023-06-02 14:31:41 +02:00
Steve Hawley 91daf664c4
[dotnet] Add to optimizations (#18387)
add redirect-class-handles to test output along with options

---------

Co-authored-by: Alex Soto <alex@soto.dev>
2023-06-01 22:04:33 -04:00
Rolf Bjarne Kvinge b4f7daac08
[tests] Ignore the NWParametersTest.SetPrivacyContextText, it crashes everywhere. (#18383) 2023-06-01 12:03:56 +02:00
Rolf Bjarne Kvinge 12be89c189
[CoreFoundation] Add a few missing APIs to CFRunLoop and enable nullability. (#18322) 2023-05-30 08:50:42 +02:00