From b026c649e6aaf4f0a8a571aae8d72aad5c562593 Mon Sep 17 00:00:00 2001 From: Siyu Mao Date: Fri, 6 Jan 2023 15:42:02 -0800 Subject: [PATCH 01/92] First verison --- .DS_Store | Bin 0 -> 6148 bytes Directory.Build.props | 1 + global.json | 2 +- src/.DS_Store | Bin 0 -> 8196 bytes src/Xunit.StaFact/.DS_Store | Bin 0 -> 6148 bytes src/Xunit.StaFact/Mac/CocoaFactAttribute.cs | 18 ++++++++ src/Xunit.StaFact/Mac/CocoaTheoryAttribute.cs | 18 ++++++++ .../Sdk.Mac/CocoaFactDiscoverer.cs | 42 +++++++++++++++++ .../Sdk.Mac/CocoaSynchronizationContext.cs | 21 +++++++++ .../CocoaSynchronizationContextAdapter.cs | 37 +++++++++++++++ .../Sdk.Mac/CocoaTheoryDiscoverer.cs | 38 ++++++++++++++++ src/Xunit.StaFact/Sdk/UITestCase.cs | 11 +++++ src/Xunit.StaFact/Xunit.StaFact.csproj | 13 +++++- .../net472/PublicAPI.Unshipped.txt | 7 +++ .../net6.0-macos10.15/PublicAPI.Shipped.txt | 43 ++++++++++++++++++ .../net6.0-macos10.15/PublicAPI.Unshipped.txt | 0 test/Xunit.StaFact.Tests/Mac/CocoaFactTest.cs | 32 +++++++++++++ .../Xunit.StaFact.Tests.csproj | 6 +++ 18 files changed, 287 insertions(+), 2 deletions(-) create mode 100644 .DS_Store create mode 100644 src/.DS_Store create mode 100644 src/Xunit.StaFact/.DS_Store create mode 100644 src/Xunit.StaFact/Mac/CocoaFactAttribute.cs create mode 100644 src/Xunit.StaFact/Mac/CocoaTheoryAttribute.cs create mode 100644 src/Xunit.StaFact/Sdk.Mac/CocoaFactDiscoverer.cs create mode 100644 src/Xunit.StaFact/Sdk.Mac/CocoaSynchronizationContext.cs create mode 100644 src/Xunit.StaFact/Sdk.Mac/CocoaSynchronizationContextAdapter.cs create mode 100644 src/Xunit.StaFact/Sdk.Mac/CocoaTheoryDiscoverer.cs create mode 100644 src/Xunit.StaFact/net6.0-macos10.15/PublicAPI.Shipped.txt create mode 100644 src/Xunit.StaFact/net6.0-macos10.15/PublicAPI.Unshipped.txt create mode 100644 test/Xunit.StaFact.Tests/Mac/CocoaFactTest.cs diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..577c29551279de393bf7ab00b26632e958c77bcb GIT binary patch literal 6148 zcmeHK!A`ma8|@MU#K1pf0M7>j zis%{4G^(Qm2Gs%p;x$qU%(0ii7-7&em}!I^5UxW3btpG22G`+W7sk&sm}%7EjGN|z zn>TaQp>Xwfc)n2XjC&esBnF6qSqAcYX=D9A_`Lt04Wbn>Kn(mT26&<6x0;ZWsjYL# wVXYOQ7oaHUmuY+nfr%=`;ESbr9aIU}1x^4xgPBIKfY3!i(Le(+@U09y1Lm!T0{{R3 literal 0 HcmV?d00001 diff --git a/Directory.Build.props b/Directory.Build.props index 2ca46b18..6ff86125 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -14,6 +14,7 @@ true true true + true true diff --git a/global.json b/global.json index cc08211e..e5187f36 100644 --- a/global.json +++ b/global.json @@ -1,6 +1,6 @@ { "sdk": { - "version": "7.0.101", + "version": "7.0.100", "rollForward": "patch", "allowPrerelease": false } diff --git a/src/.DS_Store b/src/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..86ec87e9139cc785a8c79d4a6fc384090186a187 GIT binary patch literal 8196 zcmeHMU5wOJ6h7auux(-4vVfG)g@IKRSYeh0hhltQoGFpf5c;GdnTh16kfAHDDXIrVu82wu2zQ=O1?DU>ksK9LxD$jsA-Xc63I*ZS*)J8E z6EZ@^eT+biz|9B*=~G7oR3eA0arL`S1@iM1ZzylOdA2&AAF?gaPp7XSF{x(qlv=4) znkpU09&#&LU-wI1hhE$lXuYm$=d0&>ez#>-a_X#3*YS1BF^i#tWteQTzu$5Ux6klwR&~y$cQY>Zd$&6SMG>C=(sP5 zs1WT89M1T5oYe_Jw7qht2r+TJ8seAL5M^bmmhDw`4_F1)$y!gDIkn#77`L#xvuKt% zw*G=^mj)d#r_LzocA;eJzS(Zufw4E>n@9cNY_I1Q{m#%Zr>Z5-+-0(zRW`fWnq3=$ zm3oGJ%XPfnX3=BWlu3&?SmUdc8VBnW^k$upHld!ZM3{ zbgy7KhUFaWt5}AAsK0D^R^B#y9evQ0)zk9jy87wrU2`;Tpp>_sELr|BwMmk~rS8@m zmHh_a#}3yB7BeLE9NY6nQd*<7FPP~pn%ov-P}b%c>!+)2gh}`pY6XS=}ZE*C^|>fr2|Y$dP#R3^a@3jar-bSa9X-y65){ znNDz57sOl#&+YXN=|!`r!hDKuYBP_94~NGCr*6aY-Efiv-`c2YdxGWK4I>Ogt)E_} z^=OYu>LrOEh~<L%~eUM+ytD1j~`e3bbMa+R=e7bmI~9 zq7VHTfDQ|XVPgm+(2h#&`H0*YFE|#c%jM zAtmHQLt;)M__)U{QB9D3p;!CFVm_NVL83h%F?6d0Np5~v+48R@$kl0KN;J%zHG5u= zC#%v${>4BGly4W{LAmO@ykFOt;9KP3ojbUAl@@2t`@DPUgH)Ya(@18>^>P z3e{w?vx^tHph|zAvuEgC`hY&B&zQ5{Fk7$Dbr2*pK*PL{r%kvI%Oa+(#71mF8?&_& z+p&Y$x)Zyw5BqTdIcDr(9AU;fsNg7$VHhKL4$tESyolpCfs=Rzui`c4@F~2FcLWE= zn7OseNg?s!#LO&bi;nF&2idC1?ePo5+C&IU5|dg`|99X1`~O5s#B(tMF#`W{1W?nJ z?dsqlZnudBwRVb+$N30aU^gmc=)zrCj2zGks%2H literal 0 HcmV?d00001 diff --git a/src/Xunit.StaFact/.DS_Store b/src/Xunit.StaFact/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..a58cb1e76034cbe7aecc7f789b171f186e08868d GIT binary patch literal 6148 zcmeHKOH0E*5T0$TO({YT3VK`cTC}ycAYMYPM=wV7pi&c4G&E*QANEiRx$7VDkNA6> z+1-HE9z2QI8QA@1=dqjlAo~CS(Vm2LfC>OO*a!tFON7izT{#;}DD)g>;KO||9Swqb z$wYtAMBiQn4?^g}9(?+K6`>EgKdyctzz)SX2Mpa_$SXi|lJVhEFtc4^~Wi>X1A4nnVt^VpTM$BWRbqh0E75UxS)nE_^Ck%7D! zR_Odc#b0LWBY!c4N6Y{-@Xr_!g^t&0V^Q{O{Z<~GwG!JMHWG?UNkKt<;SzuY+DEpv d)A%Ln80T6{4bm)R*Xf9S5zvHi#|-=e10T8`ONIad literal 0 HcmV?d00001 diff --git a/src/Xunit.StaFact/Mac/CocoaFactAttribute.cs b/src/Xunit.StaFact/Mac/CocoaFactAttribute.cs new file mode 100644 index 00000000..4df11c63 --- /dev/null +++ b/src/Xunit.StaFact/Mac/CocoaFactAttribute.cs @@ -0,0 +1,18 @@ +// Copyright (c) Andrew Arnott. All rights reserved. +// Licensed under the Ms-PL license. See LICENSE.txt file in the project root for full license information. + +namespace Xunit +{ + using System; + using Xunit.Sdk; + + /// + /// Identifies an xunit test that starts on with a + /// running on . + /// + [AttributeUsage(AttributeTargets.Method, AllowMultiple = false)] + [XunitTestCaseDiscoverer("Xunit.Sdk.CocoaFactDiscoverer", ThisAssembly.AssemblyName)] + public class CocoaFactAttribute : FactAttribute + { + } +} diff --git a/src/Xunit.StaFact/Mac/CocoaTheoryAttribute.cs b/src/Xunit.StaFact/Mac/CocoaTheoryAttribute.cs new file mode 100644 index 00000000..a9e7c93a --- /dev/null +++ b/src/Xunit.StaFact/Mac/CocoaTheoryAttribute.cs @@ -0,0 +1,18 @@ +// Copyright (c) Andrew Arnott. All rights reserved. +// Licensed under the Ms-PL license. See LICENSE.txt file in the project root for full license information. + +namespace Xunit +{ + using System; + using Xunit.Sdk; + + /// + /// Identifies an xunit theory that starts on with a + /// running on + /// + [AttributeUsage(AttributeTargets.Method, AllowMultiple = false)] + [XunitTestCaseDiscoverer("Xunit.Sdk.CocoaTheoryDiscoverer", ThisAssembly.AssemblyName)] + public class CocoaTheoryAttribute : TheoryAttribute + { + } +} diff --git a/src/Xunit.StaFact/Sdk.Mac/CocoaFactDiscoverer.cs b/src/Xunit.StaFact/Sdk.Mac/CocoaFactDiscoverer.cs new file mode 100644 index 00000000..0aad8e26 --- /dev/null +++ b/src/Xunit.StaFact/Sdk.Mac/CocoaFactDiscoverer.cs @@ -0,0 +1,42 @@ +// Copyright (c) Andrew Arnott. All rights reserved. +// Licensed under the Ms-PL license. See LICENSE.txt file in the project root for full license information. + +using System; +using System.Linq; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using Xunit.Abstractions; + +namespace Xunit.Sdk +{ + /// + /// The discovery class for . + /// + public class CocoaFactDiscoverer : FactDiscoverer + { + private readonly IMessageSink diagnosticMessageSink; + + /// + /// Initializes a new instance of the class. + /// + /// The diagnostic message sink. + public CocoaFactDiscoverer(IMessageSink diagnosticMessageSink) + : base(diagnosticMessageSink) + { + this.diagnosticMessageSink = diagnosticMessageSink; + } + + protected override IXunitTestCase CreateTestCase(ITestFrameworkDiscoveryOptions discoveryOptions, ITestMethod testMethod, IAttributeInfo factAttribute) + { + if (testMethod.Method.ReturnType.Name == "System.Void" && + testMethod.Method.GetCustomAttributes(typeof(AsyncStateMachineAttribute)).Any()) + { + return new ExecutionErrorTestCase(this.diagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), TestMethodDisplayOptions.None, testMethod, "Async void methods are not supported."); + } + + return RuntimeInformation.IsOSPlatform(OSPlatform.OSX) + ? (IXunitTestCase)new UITestCase(UITestCase.SyncContextType.Cocoa, this.diagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), testMethod) + : new XunitSkippedDataRowTestCase(this.diagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), discoveryOptions.MethodDisplayOptionsOrDefault(), testMethod, "Cocoa only exists on macOS."); + } + } +} \ No newline at end of file diff --git a/src/Xunit.StaFact/Sdk.Mac/CocoaSynchronizationContext.cs b/src/Xunit.StaFact/Sdk.Mac/CocoaSynchronizationContext.cs new file mode 100644 index 00000000..88512bc9 --- /dev/null +++ b/src/Xunit.StaFact/Sdk.Mac/CocoaSynchronizationContext.cs @@ -0,0 +1,21 @@ +// Copyright (c) Aaron Bockover. All rights reserved. +// Licensed under the Ms-PL license. See LICENSE.txt file in the project root for full license information. + +using System.Threading; + +using Foundation; + +namespace Xunit.Sdk +{ + internal sealed class CocoaSynchronizationContext : SynchronizationContext + { + public override SynchronizationContext CreateCopy() + => new CocoaSynchronizationContext(); + + public override void Post(SendOrPostCallback d, object state) + => NSRunLoop.Main.BeginInvokeOnMainThread(() => d(state)); + + public override void Send(SendOrPostCallback d, object state) + => NSRunLoop.Main.InvokeOnMainThread(() => d(state)); + } +} \ No newline at end of file diff --git a/src/Xunit.StaFact/Sdk.Mac/CocoaSynchronizationContextAdapter.cs b/src/Xunit.StaFact/Sdk.Mac/CocoaSynchronizationContextAdapter.cs new file mode 100644 index 00000000..414ab2af --- /dev/null +++ b/src/Xunit.StaFact/Sdk.Mac/CocoaSynchronizationContextAdapter.cs @@ -0,0 +1,37 @@ +// Copyright (c) Aaron Bockover. All rights reserved. +// Licensed under the Ms-PL license. See LICENSE.txt file in the project root for full license information. + +using System; +using System.Threading; +using System.Threading.Tasks; + +using Foundation; + +namespace Xunit.Sdk +{ + internal class CocoaSynchronizationContextAdapter : SyncContextAdapter + { + internal static readonly SyncContextAdapter Default = new CocoaSynchronizationContextAdapter(); + + private CocoaSynchronizationContextAdapter() + { + } + + internal override bool CanCompleteOperations => true; + + internal override SynchronizationContext Create(string name) => new CocoaSynchronizationContext(); + + internal override Task WaitForOperationCompletionAsync(SynchronizationContext syncContext) + { + throw new NotSupportedException("Async void test methods are not supported by the WinForms dispatcher. Use Async Task instead."); + } + + // internal override void CompleteOperations() + // { + // } + + internal override void PumpTill(SynchronizationContext synchronizationContext, Task task) + { + } + } +} diff --git a/src/Xunit.StaFact/Sdk.Mac/CocoaTheoryDiscoverer.cs b/src/Xunit.StaFact/Sdk.Mac/CocoaTheoryDiscoverer.cs new file mode 100644 index 00000000..6282e6d0 --- /dev/null +++ b/src/Xunit.StaFact/Sdk.Mac/CocoaTheoryDiscoverer.cs @@ -0,0 +1,38 @@ +// Copyright (c) Andrew Arnott. All rights reserved. +// Licensed under the Ms-PL license. See LICENSE.txt file in the project root for full license information. + +using System.Collections.Generic; +using System.Runtime.InteropServices; +using Xunit.Abstractions; + +namespace Xunit.Sdk +{ + /// + /// The discovery class for . + /// + public class CocoaTheoryDiscoverer : TheoryDiscoverer + { + /// + /// Initializes a new instance of the class. + /// + /// The diagnostic message sink. + public CocoaTheoryDiscoverer(IMessageSink diagnosticMessageSink) + : base(diagnosticMessageSink) + { + } + + protected override IEnumerable CreateTestCasesForDataRow(ITestFrameworkDiscoveryOptions discoveryOptions, ITestMethod testMethod, IAttributeInfo theoryAttribute, object[] dataRow) + { + yield return RuntimeInformation.IsOSPlatform(OSPlatform.OSX) + ? (IXunitTestCase)new UITestCase(UITestCase.SyncContextType.Cocoa, this.DiagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), testMethod, dataRow) + : new XunitSkippedDataRowTestCase(this.DiagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), discoveryOptions.MethodDisplayOptionsOrDefault(), testMethod, "Cocoa only exists on macOS."); + } + + protected override IEnumerable CreateTestCasesForTheory(ITestFrameworkDiscoveryOptions discoveryOptions, ITestMethod testMethod, IAttributeInfo theoryAttribute) + { + yield return RuntimeInformation.IsOSPlatform(OSPlatform.OSX) + ? (IXunitTestCase)new UITheoryTestCase(UITestCase.SyncContextType.Cocoa, this.DiagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), TestMethodDisplayOptions.None, testMethod) + : new XunitSkippedDataRowTestCase(this.DiagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), discoveryOptions.MethodDisplayOptionsOrDefault(), testMethod, "Cocoa only exists on macOS."); + } + } +} \ No newline at end of file diff --git a/src/Xunit.StaFact/Sdk/UITestCase.cs b/src/Xunit.StaFact/Sdk/UITestCase.cs index d6796661..f0ed6fe9 100644 --- a/src/Xunit.StaFact/Sdk/UITestCase.cs +++ b/src/Xunit.StaFact/Sdk/UITestCase.cs @@ -55,6 +55,13 @@ public enum SyncContextType /// Portable, +#if MACOS + /// + /// Use a running on , which is only available on macOS. + /// + Cocoa, +#endif + #if NETFRAMEWORK || WINDOWS /// /// Use the , which is only available on Desktop. @@ -115,6 +122,10 @@ internal static SyncContextAdapter GetAdapter(SyncContextType syncContextType) case SyncContextType.Portable: return UISynchronizationContext.Adapter.Default; +#if MACOS + case SyncContextType.Cocoa: + return CocoaSynchronizationContextAdapter.Default; +#endif #if NETFRAMEWORK || WINDOWS case SyncContextType.WPF: return DispatcherSynchronizationContextAdapter.Default; diff --git a/src/Xunit.StaFact/Xunit.StaFact.csproj b/src/Xunit.StaFact/Xunit.StaFact.csproj index 839526d7..c5e392fd 100644 --- a/src/Xunit.StaFact/Xunit.StaFact.csproj +++ b/src/Xunit.StaFact/Xunit.StaFact.csproj @@ -1,6 +1,7 @@  - net472;netstandard2.0;net6.0;net6.0-windows + net472;netstandard2.0;net6.0;net6.0-windows;net6.0-macos10.15 + 10.15 Xunit Run your xunit-based tests on an STA thread with the WPF Dispatcher, a WinForms SynchronizationContext, or even a cross-platform generic UI thread emulation with a SynchronizationContext that keeps code running on a "main thread" for that test. @@ -14,6 +15,10 @@ Theory variants of these attributes allow for parameterized testing. Check out t + + + + @@ -22,4 +27,10 @@ Theory variants of these attributes allow for parameterized testing. Check out t + + + + + + diff --git a/src/Xunit.StaFact/net472/PublicAPI.Unshipped.txt b/src/Xunit.StaFact/net472/PublicAPI.Unshipped.txt index e69de29b..73194657 100644 --- a/src/Xunit.StaFact/net472/PublicAPI.Unshipped.txt +++ b/src/Xunit.StaFact/net472/PublicAPI.Unshipped.txt @@ -0,0 +1,7 @@ +override Xunit.Sdk.CocoaFactDiscoverer.CreateTestCase(Xunit.Abstractions.ITestFrameworkDiscoveryOptions! discoveryOptions, Xunit.Abstractions.ITestMethod! testMethod, Xunit.Abstractions.IAttributeInfo! factAttribute) -> Xunit.Sdk.IXunitTestCase! +override Xunit.Sdk.CocoaTheoryDiscoverer.CreateTestCasesForDataRow(Xunit.Abstractions.ITestFrameworkDiscoveryOptions! discoveryOptions, Xunit.Abstractions.ITestMethod! testMethod, Xunit.Abstractions.IAttributeInfo! theoryAttribute, object![]! dataRow) -> System.Collections.Generic.IEnumerable! +override Xunit.Sdk.CocoaTheoryDiscoverer.CreateTestCasesForTheory(Xunit.Abstractions.ITestFrameworkDiscoveryOptions! discoveryOptions, Xunit.Abstractions.ITestMethod! testMethod, Xunit.Abstractions.IAttributeInfo! theoryAttribute) -> System.Collections.Generic.IEnumerable! +Xunit.Sdk.CocoaFactDiscoverer +Xunit.Sdk.CocoaFactDiscoverer.CocoaFactDiscoverer(Xunit.Abstractions.IMessageSink! diagnosticMessageSink) -> void +Xunit.Sdk.CocoaTheoryDiscoverer +Xunit.Sdk.CocoaTheoryDiscoverer.CocoaTheoryDiscoverer(Xunit.Abstractions.IMessageSink! diagnosticMessageSink) -> void \ No newline at end of file diff --git a/src/Xunit.StaFact/net6.0-macos10.15/PublicAPI.Shipped.txt b/src/Xunit.StaFact/net6.0-macos10.15/PublicAPI.Shipped.txt new file mode 100644 index 00000000..0abd6804 --- /dev/null +++ b/src/Xunit.StaFact/net6.0-macos10.15/PublicAPI.Shipped.txt @@ -0,0 +1,43 @@ +#nullable enable +override Xunit.Sdk.StaFactDiscoverer.CreateTestCase(Xunit.Abstractions.ITestFrameworkDiscoveryOptions! discoveryOptions, Xunit.Abstractions.ITestMethod! testMethod, Xunit.Abstractions.IAttributeInfo! factAttribute) -> Xunit.Sdk.IXunitTestCase! +override Xunit.Sdk.StaTheoryDiscoverer.CreateTestCasesForDataRow(Xunit.Abstractions.ITestFrameworkDiscoveryOptions! discoveryOptions, Xunit.Abstractions.ITestMethod! testMethod, Xunit.Abstractions.IAttributeInfo! theoryAttribute, object![]! dataRow) -> System.Collections.Generic.IEnumerable! +override Xunit.Sdk.StaTheoryDiscoverer.CreateTestCasesForTheory(Xunit.Abstractions.ITestFrameworkDiscoveryOptions! discoveryOptions, Xunit.Abstractions.ITestMethod! testMethod, Xunit.Abstractions.IAttributeInfo! theoryAttribute) -> System.Collections.Generic.IEnumerable! +override Xunit.Sdk.UIFactDiscoverer.CreateTestCase(Xunit.Abstractions.ITestFrameworkDiscoveryOptions! discoveryOptions, Xunit.Abstractions.ITestMethod! testMethod, Xunit.Abstractions.IAttributeInfo! factAttribute) -> Xunit.Sdk.IXunitTestCase! +override Xunit.Sdk.UITestCase.Deserialize(Xunit.Abstractions.IXunitSerializationInfo! data) -> void +override Xunit.Sdk.UITestCase.RunAsync(Xunit.Abstractions.IMessageSink! diagnosticMessageSink, Xunit.Sdk.IMessageBus! messageBus, object![]! constructorArguments, Xunit.Sdk.ExceptionAggregator! aggregator, System.Threading.CancellationTokenSource! cancellationTokenSource) -> System.Threading.Tasks.Task! +override Xunit.Sdk.UITestCase.Serialize(Xunit.Abstractions.IXunitSerializationInfo! data) -> void +override Xunit.Sdk.UITheoryDiscoverer.CreateTestCasesForDataRow(Xunit.Abstractions.ITestFrameworkDiscoveryOptions! discoveryOptions, Xunit.Abstractions.ITestMethod! testMethod, Xunit.Abstractions.IAttributeInfo! theoryAttribute, object![]! dataRow) -> System.Collections.Generic.IEnumerable! +override Xunit.Sdk.UITheoryDiscoverer.CreateTestCasesForTheory(Xunit.Abstractions.ITestFrameworkDiscoveryOptions! discoveryOptions, Xunit.Abstractions.ITestMethod! testMethod, Xunit.Abstractions.IAttributeInfo! theoryAttribute) -> System.Collections.Generic.IEnumerable! +override Xunit.Sdk.UITheoryTestCase.Deserialize(Xunit.Abstractions.IXunitSerializationInfo! data) -> void +override Xunit.Sdk.UITheoryTestCase.RunAsync(Xunit.Abstractions.IMessageSink! diagnosticMessageSink, Xunit.Sdk.IMessageBus! messageBus, object![]! constructorArguments, Xunit.Sdk.ExceptionAggregator! aggregator, System.Threading.CancellationTokenSource! cancellationTokenSource) -> System.Threading.Tasks.Task! +override Xunit.Sdk.UITheoryTestCase.Serialize(Xunit.Abstractions.IXunitSerializationInfo! data) -> void +Xunit.Sdk.StaFactDiscoverer +Xunit.Sdk.StaFactDiscoverer.StaFactDiscoverer(Xunit.Abstractions.IMessageSink! diagnosticMessageSink) -> void +Xunit.Sdk.StaTheoryDiscoverer +Xunit.Sdk.StaTheoryDiscoverer.StaTheoryDiscoverer(Xunit.Abstractions.IMessageSink! diagnosticMessageSink) -> void +Xunit.Sdk.UIFactDiscoverer +Xunit.Sdk.UIFactDiscoverer.UIFactDiscoverer(Xunit.Abstractions.IMessageSink! diagnosticMessageSink) -> void +Xunit.Sdk.UITestCase +Xunit.Sdk.UITestCase.SyncContextType +Xunit.Sdk.UITestCase.SyncContextType.None = 0 -> Xunit.Sdk.UITestCase.SyncContextType +Xunit.Sdk.UITestCase.SyncContextType.Portable = 1 -> Xunit.Sdk.UITestCase.SyncContextType +Xunit.Sdk.UITestCase.UITestCase() -> void +Xunit.Sdk.UITestCase.UITestCase(Xunit.Sdk.UITestCase.SyncContextType synchronizationContextType, Xunit.Abstractions.IMessageSink! diagnosticMessageSink, Xunit.Sdk.TestMethodDisplay defaultMethodDisplay, Xunit.Abstractions.ITestMethod! testMethod, object?[]? testMethodArguments = null) -> void +Xunit.Sdk.UITestCaseRunner +Xunit.Sdk.UITestInvoker +Xunit.Sdk.UITestInvoker.RunAsync() -> System.Threading.Tasks.Task! +Xunit.Sdk.UITestRunner +Xunit.Sdk.UITheoryDiscoverer +Xunit.Sdk.UITheoryDiscoverer.UITheoryDiscoverer(Xunit.Abstractions.IMessageSink! diagnosticMessageSink) -> void +Xunit.Sdk.UITheoryTestCase +Xunit.Sdk.UITheoryTestCase.UITheoryTestCase() -> void +Xunit.Sdk.UITheoryTestCase.UITheoryTestCase(Xunit.Sdk.UITestCase.SyncContextType synchronizationContextType, Xunit.Abstractions.IMessageSink! diagnosticMessageSink, Xunit.Sdk.TestMethodDisplay defaultMethodDisplay, Xunit.Sdk.TestMethodDisplayOptions defaultMethodDisplayOptions, Xunit.Abstractions.ITestMethod! testMethod) -> void +Xunit.Sdk.UITheoryTestCaseRunner +Xunit.StaFactAttribute +Xunit.StaFactAttribute.StaFactAttribute() -> void +Xunit.StaTheoryAttribute +Xunit.StaTheoryAttribute.StaTheoryAttribute() -> void +Xunit.UIFactAttribute +Xunit.UIFactAttribute.UIFactAttribute() -> void +Xunit.UITheoryAttribute +Xunit.UITheoryAttribute.UITheoryAttribute() -> void diff --git a/src/Xunit.StaFact/net6.0-macos10.15/PublicAPI.Unshipped.txt b/src/Xunit.StaFact/net6.0-macos10.15/PublicAPI.Unshipped.txt new file mode 100644 index 00000000..e69de29b diff --git a/test/Xunit.StaFact.Tests/Mac/CocoaFactTest.cs b/test/Xunit.StaFact.Tests/Mac/CocoaFactTest.cs new file mode 100644 index 00000000..d4a17022 --- /dev/null +++ b/test/Xunit.StaFact.Tests/Mac/CocoaFactTest.cs @@ -0,0 +1,32 @@ +using System.Threading.Tasks; +using AppKit; +using Xunit; +public class CocoaFactTests +{ + [CocoaFact] + public void AssertMainThreadSync() + => NSApplication.EnsureUIThread(); + [Fact] + public void AssertMainThreadSyncAndFail() + => Assert.Throws(NSApplication.EnsureUIThread); + [CocoaFact] + public Task AssertMainThreadAsyncReturnCompletedTask() + { + NSApplication.EnsureUIThread(); + return Task.CompletedTask; + } + [CocoaFact] + public async Task AssertMainThreadAsyncWithAwait() + { + await Task.Yield(); + NSApplication.EnsureUIThread(); + await Task.Delay(100); + } + + [CocoaFact] + public void AssertExceptionsAreCaptured() + { + NSApplication.EnsureUIThread(); + throw new System.Exception("Thrown from Main"); + } +} diff --git a/test/Xunit.StaFact.Tests/Xunit.StaFact.Tests.csproj b/test/Xunit.StaFact.Tests/Xunit.StaFact.Tests.csproj index 71be7992..3fe55e6e 100644 --- a/test/Xunit.StaFact.Tests/Xunit.StaFact.Tests.csproj +++ b/test/Xunit.StaFact.Tests/Xunit.StaFact.Tests.csproj @@ -1,10 +1,16 @@  net472;net6.0;net6.0-windows + word + 10.15 + osx-arm64 + + + From d7718fa38700f5b18b88fbe99c395e8df984f157 Mon Sep 17 00:00:00 2001 From: Siyu Mao Date: Mon, 9 Jan 2023 16:10:03 -0800 Subject: [PATCH 02/92] Modify CocoaSynchronizationContextAdapter.cs pumptill method. --- src/Xunit.StaFact/Sdk.Mac/CocoaSynchronizationContextAdapter.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Xunit.StaFact/Sdk.Mac/CocoaSynchronizationContextAdapter.cs b/src/Xunit.StaFact/Sdk.Mac/CocoaSynchronizationContextAdapter.cs index 414ab2af..0811d21e 100644 --- a/src/Xunit.StaFact/Sdk.Mac/CocoaSynchronizationContextAdapter.cs +++ b/src/Xunit.StaFact/Sdk.Mac/CocoaSynchronizationContextAdapter.cs @@ -32,6 +32,7 @@ internal override Task WaitForOperationCompletionAsync(SynchronizationContext sy internal override void PumpTill(SynchronizationContext synchronizationContext, Task task) { + ((CocoaSynchronizationContext)syncContext).PumpMessages(task); } } } From 9516e6d74b51f53ae2494967fbefc32c2fdeacec Mon Sep 17 00:00:00 2001 From: Siyu Mao Date: Mon, 9 Jan 2023 16:12:43 -0800 Subject: [PATCH 03/92] Modify PumpTill. --- src/Xunit.StaFact/Sdk.Mac/CocoaSynchronizationContextAdapter.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Xunit.StaFact/Sdk.Mac/CocoaSynchronizationContextAdapter.cs b/src/Xunit.StaFact/Sdk.Mac/CocoaSynchronizationContextAdapter.cs index 0811d21e..f8989e8c 100644 --- a/src/Xunit.StaFact/Sdk.Mac/CocoaSynchronizationContextAdapter.cs +++ b/src/Xunit.StaFact/Sdk.Mac/CocoaSynchronizationContextAdapter.cs @@ -32,7 +32,7 @@ internal override Task WaitForOperationCompletionAsync(SynchronizationContext sy internal override void PumpTill(SynchronizationContext synchronizationContext, Task task) { - ((CocoaSynchronizationContext)syncContext).PumpMessages(task); + ((CocoaSynchronizationContext)synchronizationContext).PumpMessages(task); } } } From 8fbeb9a90486b46fdeccf0761380ebae543d310a Mon Sep 17 00:00:00 2001 From: Siyu Mao Date: Mon, 9 Jan 2023 16:37:16 -0800 Subject: [PATCH 04/92] Modify more CocoaSynchronizationContext.cs and CocoaSynchronizationContextAdapter.cs --- .../Sdk.Mac/CocoaSynchronizationContext.cs | 181 +++++++++++++++++- .../CocoaSynchronizationContextAdapter.cs | 2 +- 2 files changed, 180 insertions(+), 3 deletions(-) diff --git a/src/Xunit.StaFact/Sdk.Mac/CocoaSynchronizationContext.cs b/src/Xunit.StaFact/Sdk.Mac/CocoaSynchronizationContext.cs index 88512bc9..ebf24467 100644 --- a/src/Xunit.StaFact/Sdk.Mac/CocoaSynchronizationContext.cs +++ b/src/Xunit.StaFact/Sdk.Mac/CocoaSynchronizationContext.cs @@ -9,13 +9,190 @@ namespace Xunit.Sdk { internal sealed class CocoaSynchronizationContext : SynchronizationContext { + + private readonly Queue> messageQueue = new Queue>(); + private readonly int mainThread = Environment.CurrentManagedThreadId; + private readonly AsyncAutoResetEvent workItemDone = new AsyncAutoResetEvent(); + private readonly string name; + private readonly bool shouldSetAsCurrent; + private int activeOperations; + private bool pumping; + private bool pumpingEnded; + private ExceptionAggregator? aggregator; + + /// + /// Initializes a new instance of the class. + /// + public CocoaSynchronizationContext(string name, bool shouldSetAsCurrent) + { + this.name = name; + this.shouldSetAsCurrent = shouldSetAsCurrent; + } + + internal bool IsInContext => this.mainThread == Environment.CurrentManagedThreadId; + + private bool AnyMessagesInQueue + { + get + { + lock (this.messageQueue) + { + return this.messageQueue.Count > 0; + } + } + } + + private bool AnyPendingOperations => Volatile.Read(ref this.activeOperations) > 0; + public override SynchronizationContext CreateCopy() - => new CocoaSynchronizationContext(); + => new CocoaSynchronizationContext(name, shouldSetAsCurrent); public override void Post(SendOrPostCallback d, object state) => NSRunLoop.Main.BeginInvokeOnMainThread(() => d(state)); public override void Send(SendOrPostCallback d, object state) => NSRunLoop.Main.InvokeOnMainThread(() => d(state)); + + /// + /// Blocks the calling thread to pump messages until a task has completed. + /// + /// The task that must complete to break out of the message loop. + public void PumpMessages(Task untilCompleted) + { + this.VerifyState(); + + this.pumping = true; + try + { + // Arrange to wake up immediately when the task completes. + untilCompleted.ContinueWith( + _ => + { + lock (this.messageQueue) + { + Monitor.Pulse(this.messageQueue); + } + }, + TaskScheduler.Default); + + // Now run the message loop until the task completes. + while (!untilCompleted.IsCompleted) + { + this.TryOneWorkItem(); + } + } + finally + { + this.pumping = false; + this.pumpingEnded = true; + } + } + + public async Task WaitForOperationCompletionAsync() + { + while (this.AnyPendingOperations || this.AnyMessagesInQueue) + { + await this.workItemDone.WaitAsync().ConfigureAwait(false); + } + } + + /// + /// Pump messages until all pending operations have completed + /// and the message queue is empty. + /// + public void CompleteOperations() + { + this.VerifyState(); + this.pumping = true; + try + { + while (this.AnyPendingOperations || this.AnyMessagesInQueue) + { + this.TryOneWorkItem(); + } + } + finally + { + this.pumping = false; + } + } + + /// + public override void OperationStarted() + { + Interlocked.Increment(ref this.activeOperations); + } + + /// + public override void OperationCompleted() + { + int result = Interlocked.Decrement(ref this.activeOperations); + if (result == 0) + { + // Give any message waiter a heads up that the operation count has reached zero, + // in case the queue is empty at the same time the operation count is, which + // is usually a sign to return to its caller. + lock (this.messageQueue) + { + Monitor.Pulse(this.messageQueue); + } + } + } + + internal void SetExceptionAggregator(ExceptionAggregator aggregator) + { + this.aggregator = aggregator; + } + + private void VerifyState() + { + if (Environment.CurrentManagedThreadId != this.mainThread) + { + throw new InvalidOperationException("Wrong thread"); + } + + if (Current != this && this.shouldSetAsCurrent) + { + throw new InvalidOperationException("Wrong sync context"); + } + + if (this.pumping) + { + throw new InvalidOperationException("Already pumping"); + } + } + + private bool TryOneWorkItem() + { + KeyValuePair work = default; + lock (this.messageQueue) + { + if (this.messageQueue.Count == 0) + { + Monitor.Wait(this.messageQueue); + return false; + } + + work = this.messageQueue.Dequeue(); + } + + try + { + if (this.aggregator is object) + { + this.aggregator.Run(() => work.Key(work.Value)); + } + else + { + work.Key(work.Value); + } + + return true; + } + finally + { + this.workItemDone.Set(); + } + } } -} \ No newline at end of file +} diff --git a/src/Xunit.StaFact/Sdk.Mac/CocoaSynchronizationContextAdapter.cs b/src/Xunit.StaFact/Sdk.Mac/CocoaSynchronizationContextAdapter.cs index f8989e8c..179a8bb7 100644 --- a/src/Xunit.StaFact/Sdk.Mac/CocoaSynchronizationContextAdapter.cs +++ b/src/Xunit.StaFact/Sdk.Mac/CocoaSynchronizationContextAdapter.cs @@ -19,7 +19,7 @@ private CocoaSynchronizationContextAdapter() internal override bool CanCompleteOperations => true; - internal override SynchronizationContext Create(string name) => new CocoaSynchronizationContext(); + internal override SynchronizationContext Create(string name) => new CocoaSynchronizationContext(name, this.ShouldSetAsCurrent); internal override Task WaitForOperationCompletionAsync(SynchronizationContext syncContext) { From e996a5c37ab7df2f8cc07bdfc0023b43850990d7 Mon Sep 17 00:00:00 2001 From: Siyu Mao Date: Mon, 9 Jan 2023 18:11:46 -0800 Subject: [PATCH 05/92] Modify version2 --- src/Xunit.StaFact/Sdk.Mac/CocoaFactDiscoverer.cs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/Xunit.StaFact/Sdk.Mac/CocoaFactDiscoverer.cs b/src/Xunit.StaFact/Sdk.Mac/CocoaFactDiscoverer.cs index 0aad8e26..e64c5727 100644 --- a/src/Xunit.StaFact/Sdk.Mac/CocoaFactDiscoverer.cs +++ b/src/Xunit.StaFact/Sdk.Mac/CocoaFactDiscoverer.cs @@ -5,6 +5,7 @@ using System.Linq; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; +using Internal; using Xunit.Abstractions; namespace Xunit.Sdk @@ -26,8 +27,20 @@ public CocoaFactDiscoverer(IMessageSink diagnosticMessageSink) this.diagnosticMessageSink = diagnosticMessageSink; } + class MyMessage: IMessageSinkMessage + { + public string Message { get; set; } + } + protected override IXunitTestCase CreateTestCase(ITestFrameworkDiscoveryOptions discoveryOptions, ITestMethod testMethod, IAttributeInfo factAttribute) { + var message = new MyMessage + { + Message = "Hello" + }; + + Console.WriteLine("hello!!"); + diagnosticMessageSink.OnMessage(message); if (testMethod.Method.ReturnType.Name == "System.Void" && testMethod.Method.GetCustomAttributes(typeof(AsyncStateMachineAttribute)).Any()) { @@ -39,4 +52,4 @@ protected override IXunitTestCase CreateTestCase(ITestFrameworkDiscoveryOptions : new XunitSkippedDataRowTestCase(this.diagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), discoveryOptions.MethodDisplayOptionsOrDefault(), testMethod, "Cocoa only exists on macOS."); } } -} \ No newline at end of file +} From 897247bd48962aa027c0844e028ca3e92f5d4e19 Mon Sep 17 00:00:00 2001 From: Siyu Mao Date: Mon, 9 Jan 2023 18:13:19 -0800 Subject: [PATCH 06/92] version3 --- src/Xunit.StaFact/Sdk.Mac/CocoaFactDiscoverer.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Xunit.StaFact/Sdk.Mac/CocoaFactDiscoverer.cs b/src/Xunit.StaFact/Sdk.Mac/CocoaFactDiscoverer.cs index e64c5727..e15cb18f 100644 --- a/src/Xunit.StaFact/Sdk.Mac/CocoaFactDiscoverer.cs +++ b/src/Xunit.StaFact/Sdk.Mac/CocoaFactDiscoverer.cs @@ -5,7 +5,6 @@ using System.Linq; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; -using Internal; using Xunit.Abstractions; namespace Xunit.Sdk From 53bf326e814074de964f0f7df5ed8c793f8722aa Mon Sep 17 00:00:00 2001 From: Siyu Mao Date: Tue, 10 Jan 2023 10:15:17 -0800 Subject: [PATCH 07/92] Version4: --- src/Xunit.StaFact/Mac/CocoaFactAttribute.cs | 6 +++--- src/Xunit.StaFact/Mac/CocoaTheoryAttribute.cs | 6 +++--- src/Xunit.StaFact/Sdk.Mac/CocoaFactDiscoverer.cs | 8 +++++--- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/Xunit.StaFact/Mac/CocoaFactAttribute.cs b/src/Xunit.StaFact/Mac/CocoaFactAttribute.cs index 4df11c63..c632e68e 100644 --- a/src/Xunit.StaFact/Mac/CocoaFactAttribute.cs +++ b/src/Xunit.StaFact/Mac/CocoaFactAttribute.cs @@ -1,11 +1,11 @@ // Copyright (c) Andrew Arnott. All rights reserved. // Licensed under the Ms-PL license. See LICENSE.txt file in the project root for full license information. +using System; +using System.Threading; +using Xunit.Sdk; namespace Xunit { - using System; - using Xunit.Sdk; - /// /// Identifies an xunit test that starts on with a /// running on . diff --git a/src/Xunit.StaFact/Mac/CocoaTheoryAttribute.cs b/src/Xunit.StaFact/Mac/CocoaTheoryAttribute.cs index a9e7c93a..d86ac057 100644 --- a/src/Xunit.StaFact/Mac/CocoaTheoryAttribute.cs +++ b/src/Xunit.StaFact/Mac/CocoaTheoryAttribute.cs @@ -1,11 +1,11 @@ // Copyright (c) Andrew Arnott. All rights reserved. // Licensed under the Ms-PL license. See LICENSE.txt file in the project root for full license information. +using System; +using System.Threading; +using Xunit.Sdk; namespace Xunit { - using System; - using Xunit.Sdk; - /// /// Identifies an xunit theory that starts on with a /// running on diff --git a/src/Xunit.StaFact/Sdk.Mac/CocoaFactDiscoverer.cs b/src/Xunit.StaFact/Sdk.Mac/CocoaFactDiscoverer.cs index e15cb18f..fc461a29 100644 --- a/src/Xunit.StaFact/Sdk.Mac/CocoaFactDiscoverer.cs +++ b/src/Xunit.StaFact/Sdk.Mac/CocoaFactDiscoverer.cs @@ -46,9 +46,11 @@ protected override IXunitTestCase CreateTestCase(ITestFrameworkDiscoveryOptions return new ExecutionErrorTestCase(this.diagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), TestMethodDisplayOptions.None, testMethod, "Async void methods are not supported."); } - return RuntimeInformation.IsOSPlatform(OSPlatform.OSX) - ? (IXunitTestCase)new UITestCase(UITestCase.SyncContextType.Cocoa, this.diagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), testMethod) - : new XunitSkippedDataRowTestCase(this.diagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), discoveryOptions.MethodDisplayOptionsOrDefault(), testMethod, "Cocoa only exists on macOS."); + return (IXunitTestCase)new UITestCase(UITestCase.SyncContextType.Cocoa, this.diagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), testMethod); + + //return RuntimeInformation.IsOSPlatform(OSPlatform.OSX) + // ? (IXunitTestCase)new UITestCase(UITestCase.SyncContextType.Cocoa, this.diagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), testMethod) + // : new XunitSkippedDataRowTestCase(this.diagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), discoveryOptions.MethodDisplayOptionsOrDefault(), testMethod, "Cocoa only exists on macOS."); } } } From fca1e869192a66c93a3803c082fc13fb33be7967 Mon Sep 17 00:00:00 2001 From: Siyu Mao Date: Tue, 10 Jan 2023 10:41:36 -0800 Subject: [PATCH 08/92] Version5 --- src/Xunit.StaFact/Sdk.Mac/CocoaFactDiscoverer.cs | 2 +- .../Sdk.Mac/CocoaSynchronizationContextAdapter.cs | 5 +---- src/Xunit.StaFact/Sdk.Mac/CocoaTheoryDiscoverer.cs | 9 +++++---- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/src/Xunit.StaFact/Sdk.Mac/CocoaFactDiscoverer.cs b/src/Xunit.StaFact/Sdk.Mac/CocoaFactDiscoverer.cs index fc461a29..5fbb24f0 100644 --- a/src/Xunit.StaFact/Sdk.Mac/CocoaFactDiscoverer.cs +++ b/src/Xunit.StaFact/Sdk.Mac/CocoaFactDiscoverer.cs @@ -50,7 +50,7 @@ protected override IXunitTestCase CreateTestCase(ITestFrameworkDiscoveryOptions //return RuntimeInformation.IsOSPlatform(OSPlatform.OSX) // ? (IXunitTestCase)new UITestCase(UITestCase.SyncContextType.Cocoa, this.diagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), testMethod) - // : new XunitSkippedDataRowTestCase(this.diagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), discoveryOptions.MethodDisplayOptionsOrDefault(), testMethod, "Cocoa only exists on macOS."); + // : new XunitSkippedDataRowTestCase(this.diagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), discoveryOptions.MethodDisplayOptionsOrDefault(), testMethod, "Cocoa only exists on macOS."); } } } diff --git a/src/Xunit.StaFact/Sdk.Mac/CocoaSynchronizationContextAdapter.cs b/src/Xunit.StaFact/Sdk.Mac/CocoaSynchronizationContextAdapter.cs index 179a8bb7..8387181d 100644 --- a/src/Xunit.StaFact/Sdk.Mac/CocoaSynchronizationContextAdapter.cs +++ b/src/Xunit.StaFact/Sdk.Mac/CocoaSynchronizationContextAdapter.cs @@ -21,10 +21,7 @@ private CocoaSynchronizationContextAdapter() internal override SynchronizationContext Create(string name) => new CocoaSynchronizationContext(name, this.ShouldSetAsCurrent); - internal override Task WaitForOperationCompletionAsync(SynchronizationContext syncContext) - { - throw new NotSupportedException("Async void test methods are not supported by the WinForms dispatcher. Use Async Task instead."); - } + internal override Task WaitForOperationCompletionAsync(SynchronizationContext syncContext) => ((CocoaSynchronizationContext)syncContext).WaitForOperationCompletionAsync(); // internal override void CompleteOperations() // { diff --git a/src/Xunit.StaFact/Sdk.Mac/CocoaTheoryDiscoverer.cs b/src/Xunit.StaFact/Sdk.Mac/CocoaTheoryDiscoverer.cs index 6282e6d0..7b4d3564 100644 --- a/src/Xunit.StaFact/Sdk.Mac/CocoaTheoryDiscoverer.cs +++ b/src/Xunit.StaFact/Sdk.Mac/CocoaTheoryDiscoverer.cs @@ -30,9 +30,10 @@ protected override IEnumerable CreateTestCasesForDataRow(ITestFr protected override IEnumerable CreateTestCasesForTheory(ITestFrameworkDiscoveryOptions discoveryOptions, ITestMethod testMethod, IAttributeInfo theoryAttribute) { - yield return RuntimeInformation.IsOSPlatform(OSPlatform.OSX) - ? (IXunitTestCase)new UITheoryTestCase(UITestCase.SyncContextType.Cocoa, this.DiagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), TestMethodDisplayOptions.None, testMethod) - : new XunitSkippedDataRowTestCase(this.DiagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), discoveryOptions.MethodDisplayOptionsOrDefault(), testMethod, "Cocoa only exists on macOS."); + yield return (IXunitTestCase)new UITheoryTestCase(UITestCase.SyncContextType.Cocoa, this.DiagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), TestMethodDisplayOptions.None, testMethod); + //yield return RuntimeInformation.IsOSPlatform(OSPlatform.OSX) + // ? (IXunitTestCase)new UITheoryTestCase(UITestCase.SyncContextType.Cocoa, this.DiagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), TestMethodDisplayOptions.None, testMethod) + // : new XunitSkippedDataRowTestCase(this.DiagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), discoveryOptions.MethodDisplayOptionsOrDefault(), testMethod, "Cocoa only exists on macOS."); } } -} \ No newline at end of file +} From 0d636e270cd93722155cb9eecec2e77492ef2bd4 Mon Sep 17 00:00:00 2001 From: Siyu Mao Date: Wed, 11 Jan 2023 10:56:47 -0800 Subject: [PATCH 09/92] Version6 --- src/Xunit.StaFact/Sdk.Mac/CocoaTheoryDiscoverer.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Xunit.StaFact/Sdk.Mac/CocoaTheoryDiscoverer.cs b/src/Xunit.StaFact/Sdk.Mac/CocoaTheoryDiscoverer.cs index 7b4d3564..749a79fc 100644 --- a/src/Xunit.StaFact/Sdk.Mac/CocoaTheoryDiscoverer.cs +++ b/src/Xunit.StaFact/Sdk.Mac/CocoaTheoryDiscoverer.cs @@ -23,9 +23,10 @@ public CocoaTheoryDiscoverer(IMessageSink diagnosticMessageSink) protected override IEnumerable CreateTestCasesForDataRow(ITestFrameworkDiscoveryOptions discoveryOptions, ITestMethod testMethod, IAttributeInfo theoryAttribute, object[] dataRow) { - yield return RuntimeInformation.IsOSPlatform(OSPlatform.OSX) - ? (IXunitTestCase)new UITestCase(UITestCase.SyncContextType.Cocoa, this.DiagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), testMethod, dataRow) - : new XunitSkippedDataRowTestCase(this.DiagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), discoveryOptions.MethodDisplayOptionsOrDefault(), testMethod, "Cocoa only exists on macOS."); + yield return (IXunitTestCase)new UITestCase(UITestCase.SyncContextType.Cocoa, this.DiagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), testMethod, dataRow); + //yield return RuntimeInformation.IsOSPlatform(OSPlatform.OSX) + // ? (IXunitTestCase)new UITestCase(UITestCase.SyncContextType.Cocoa, this.DiagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), testMethod, dataRow) + // : new XunitSkippedDataRowTestCase(this.DiagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), discoveryOptions.MethodDisplayOptionsOrDefault(), testMethod, "Cocoa only exists on macOS."); } protected override IEnumerable CreateTestCasesForTheory(ITestFrameworkDiscoveryOptions discoveryOptions, ITestMethod testMethod, IAttributeInfo theoryAttribute) From 68e2e4971c9a06ddbe930c390bc63b4fa8b2891d Mon Sep 17 00:00:00 2001 From: Siyu Mao Date: Tue, 17 Jan 2023 09:02:29 -0800 Subject: [PATCH 10/92] CocoaFact code clean up --- .gitignore | 3 ++ .../Sdk.Mac/CocoaFactDiscoverer.cs | 4 -- .../CocoaSynchronizationContextAdapter.cs | 4 -- .../Sdk.Mac/CocoaTheoryDiscoverer.cs | 6 --- src/Xunit.StaFact/Xunit.StaFact.csproj | 8 +--- .../net472/PublicAPI.Unshipped.txt | 7 --- .../net6.0-macos10.15/PublicAPI.Shipped.txt | 43 ------------------- 7 files changed, 4 insertions(+), 71 deletions(-) diff --git a/.gitignore b/.gitignore index 3bb49919..e0f9b3b8 100644 --- a/.gitignore +++ b/.gitignore @@ -349,3 +349,6 @@ MigrationBackup/ # dotnet tool local install directory .store/ + +# File built by MacOS +.DS_Store diff --git a/src/Xunit.StaFact/Sdk.Mac/CocoaFactDiscoverer.cs b/src/Xunit.StaFact/Sdk.Mac/CocoaFactDiscoverer.cs index 5fbb24f0..8c2bb9d9 100644 --- a/src/Xunit.StaFact/Sdk.Mac/CocoaFactDiscoverer.cs +++ b/src/Xunit.StaFact/Sdk.Mac/CocoaFactDiscoverer.cs @@ -47,10 +47,6 @@ protected override IXunitTestCase CreateTestCase(ITestFrameworkDiscoveryOptions } return (IXunitTestCase)new UITestCase(UITestCase.SyncContextType.Cocoa, this.diagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), testMethod); - - //return RuntimeInformation.IsOSPlatform(OSPlatform.OSX) - // ? (IXunitTestCase)new UITestCase(UITestCase.SyncContextType.Cocoa, this.diagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), testMethod) - // : new XunitSkippedDataRowTestCase(this.diagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), discoveryOptions.MethodDisplayOptionsOrDefault(), testMethod, "Cocoa only exists on macOS."); } } } diff --git a/src/Xunit.StaFact/Sdk.Mac/CocoaSynchronizationContextAdapter.cs b/src/Xunit.StaFact/Sdk.Mac/CocoaSynchronizationContextAdapter.cs index 8387181d..cbf6bbaa 100644 --- a/src/Xunit.StaFact/Sdk.Mac/CocoaSynchronizationContextAdapter.cs +++ b/src/Xunit.StaFact/Sdk.Mac/CocoaSynchronizationContextAdapter.cs @@ -23,10 +23,6 @@ private CocoaSynchronizationContextAdapter() internal override Task WaitForOperationCompletionAsync(SynchronizationContext syncContext) => ((CocoaSynchronizationContext)syncContext).WaitForOperationCompletionAsync(); - // internal override void CompleteOperations() - // { - // } - internal override void PumpTill(SynchronizationContext synchronizationContext, Task task) { ((CocoaSynchronizationContext)synchronizationContext).PumpMessages(task); diff --git a/src/Xunit.StaFact/Sdk.Mac/CocoaTheoryDiscoverer.cs b/src/Xunit.StaFact/Sdk.Mac/CocoaTheoryDiscoverer.cs index 749a79fc..9f476643 100644 --- a/src/Xunit.StaFact/Sdk.Mac/CocoaTheoryDiscoverer.cs +++ b/src/Xunit.StaFact/Sdk.Mac/CocoaTheoryDiscoverer.cs @@ -24,17 +24,11 @@ public CocoaTheoryDiscoverer(IMessageSink diagnosticMessageSink) protected override IEnumerable CreateTestCasesForDataRow(ITestFrameworkDiscoveryOptions discoveryOptions, ITestMethod testMethod, IAttributeInfo theoryAttribute, object[] dataRow) { yield return (IXunitTestCase)new UITestCase(UITestCase.SyncContextType.Cocoa, this.DiagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), testMethod, dataRow); - //yield return RuntimeInformation.IsOSPlatform(OSPlatform.OSX) - // ? (IXunitTestCase)new UITestCase(UITestCase.SyncContextType.Cocoa, this.DiagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), testMethod, dataRow) - // : new XunitSkippedDataRowTestCase(this.DiagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), discoveryOptions.MethodDisplayOptionsOrDefault(), testMethod, "Cocoa only exists on macOS."); } protected override IEnumerable CreateTestCasesForTheory(ITestFrameworkDiscoveryOptions discoveryOptions, ITestMethod testMethod, IAttributeInfo theoryAttribute) { yield return (IXunitTestCase)new UITheoryTestCase(UITestCase.SyncContextType.Cocoa, this.DiagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), TestMethodDisplayOptions.None, testMethod); - //yield return RuntimeInformation.IsOSPlatform(OSPlatform.OSX) - // ? (IXunitTestCase)new UITheoryTestCase(UITestCase.SyncContextType.Cocoa, this.DiagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), TestMethodDisplayOptions.None, testMethod) - // : new XunitSkippedDataRowTestCase(this.DiagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), discoveryOptions.MethodDisplayOptionsOrDefault(), testMethod, "Cocoa only exists on macOS."); } } } diff --git a/src/Xunit.StaFact/Xunit.StaFact.csproj b/src/Xunit.StaFact/Xunit.StaFact.csproj index c5e392fd..dab95daa 100644 --- a/src/Xunit.StaFact/Xunit.StaFact.csproj +++ b/src/Xunit.StaFact/Xunit.StaFact.csproj @@ -1,7 +1,7 @@  net472;netstandard2.0;net6.0;net6.0-windows;net6.0-macos10.15 - 10.15 + Xunit Run your xunit-based tests on an STA thread with the WPF Dispatcher, a WinForms SynchronizationContext, or even a cross-platform generic UI thread emulation with a SynchronizationContext that keeps code running on a "main thread" for that test. @@ -27,10 +27,4 @@ Theory variants of these attributes allow for parameterized testing. Check out t - - - - - - diff --git a/src/Xunit.StaFact/net472/PublicAPI.Unshipped.txt b/src/Xunit.StaFact/net472/PublicAPI.Unshipped.txt index 73194657..e69de29b 100644 --- a/src/Xunit.StaFact/net472/PublicAPI.Unshipped.txt +++ b/src/Xunit.StaFact/net472/PublicAPI.Unshipped.txt @@ -1,7 +0,0 @@ -override Xunit.Sdk.CocoaFactDiscoverer.CreateTestCase(Xunit.Abstractions.ITestFrameworkDiscoveryOptions! discoveryOptions, Xunit.Abstractions.ITestMethod! testMethod, Xunit.Abstractions.IAttributeInfo! factAttribute) -> Xunit.Sdk.IXunitTestCase! -override Xunit.Sdk.CocoaTheoryDiscoverer.CreateTestCasesForDataRow(Xunit.Abstractions.ITestFrameworkDiscoveryOptions! discoveryOptions, Xunit.Abstractions.ITestMethod! testMethod, Xunit.Abstractions.IAttributeInfo! theoryAttribute, object![]! dataRow) -> System.Collections.Generic.IEnumerable! -override Xunit.Sdk.CocoaTheoryDiscoverer.CreateTestCasesForTheory(Xunit.Abstractions.ITestFrameworkDiscoveryOptions! discoveryOptions, Xunit.Abstractions.ITestMethod! testMethod, Xunit.Abstractions.IAttributeInfo! theoryAttribute) -> System.Collections.Generic.IEnumerable! -Xunit.Sdk.CocoaFactDiscoverer -Xunit.Sdk.CocoaFactDiscoverer.CocoaFactDiscoverer(Xunit.Abstractions.IMessageSink! diagnosticMessageSink) -> void -Xunit.Sdk.CocoaTheoryDiscoverer -Xunit.Sdk.CocoaTheoryDiscoverer.CocoaTheoryDiscoverer(Xunit.Abstractions.IMessageSink! diagnosticMessageSink) -> void \ No newline at end of file diff --git a/src/Xunit.StaFact/net6.0-macos10.15/PublicAPI.Shipped.txt b/src/Xunit.StaFact/net6.0-macos10.15/PublicAPI.Shipped.txt index 0abd6804..e69de29b 100644 --- a/src/Xunit.StaFact/net6.0-macos10.15/PublicAPI.Shipped.txt +++ b/src/Xunit.StaFact/net6.0-macos10.15/PublicAPI.Shipped.txt @@ -1,43 +0,0 @@ -#nullable enable -override Xunit.Sdk.StaFactDiscoverer.CreateTestCase(Xunit.Abstractions.ITestFrameworkDiscoveryOptions! discoveryOptions, Xunit.Abstractions.ITestMethod! testMethod, Xunit.Abstractions.IAttributeInfo! factAttribute) -> Xunit.Sdk.IXunitTestCase! -override Xunit.Sdk.StaTheoryDiscoverer.CreateTestCasesForDataRow(Xunit.Abstractions.ITestFrameworkDiscoveryOptions! discoveryOptions, Xunit.Abstractions.ITestMethod! testMethod, Xunit.Abstractions.IAttributeInfo! theoryAttribute, object![]! dataRow) -> System.Collections.Generic.IEnumerable! -override Xunit.Sdk.StaTheoryDiscoverer.CreateTestCasesForTheory(Xunit.Abstractions.ITestFrameworkDiscoveryOptions! discoveryOptions, Xunit.Abstractions.ITestMethod! testMethod, Xunit.Abstractions.IAttributeInfo! theoryAttribute) -> System.Collections.Generic.IEnumerable! -override Xunit.Sdk.UIFactDiscoverer.CreateTestCase(Xunit.Abstractions.ITestFrameworkDiscoveryOptions! discoveryOptions, Xunit.Abstractions.ITestMethod! testMethod, Xunit.Abstractions.IAttributeInfo! factAttribute) -> Xunit.Sdk.IXunitTestCase! -override Xunit.Sdk.UITestCase.Deserialize(Xunit.Abstractions.IXunitSerializationInfo! data) -> void -override Xunit.Sdk.UITestCase.RunAsync(Xunit.Abstractions.IMessageSink! diagnosticMessageSink, Xunit.Sdk.IMessageBus! messageBus, object![]! constructorArguments, Xunit.Sdk.ExceptionAggregator! aggregator, System.Threading.CancellationTokenSource! cancellationTokenSource) -> System.Threading.Tasks.Task! -override Xunit.Sdk.UITestCase.Serialize(Xunit.Abstractions.IXunitSerializationInfo! data) -> void -override Xunit.Sdk.UITheoryDiscoverer.CreateTestCasesForDataRow(Xunit.Abstractions.ITestFrameworkDiscoveryOptions! discoveryOptions, Xunit.Abstractions.ITestMethod! testMethod, Xunit.Abstractions.IAttributeInfo! theoryAttribute, object![]! dataRow) -> System.Collections.Generic.IEnumerable! -override Xunit.Sdk.UITheoryDiscoverer.CreateTestCasesForTheory(Xunit.Abstractions.ITestFrameworkDiscoveryOptions! discoveryOptions, Xunit.Abstractions.ITestMethod! testMethod, Xunit.Abstractions.IAttributeInfo! theoryAttribute) -> System.Collections.Generic.IEnumerable! -override Xunit.Sdk.UITheoryTestCase.Deserialize(Xunit.Abstractions.IXunitSerializationInfo! data) -> void -override Xunit.Sdk.UITheoryTestCase.RunAsync(Xunit.Abstractions.IMessageSink! diagnosticMessageSink, Xunit.Sdk.IMessageBus! messageBus, object![]! constructorArguments, Xunit.Sdk.ExceptionAggregator! aggregator, System.Threading.CancellationTokenSource! cancellationTokenSource) -> System.Threading.Tasks.Task! -override Xunit.Sdk.UITheoryTestCase.Serialize(Xunit.Abstractions.IXunitSerializationInfo! data) -> void -Xunit.Sdk.StaFactDiscoverer -Xunit.Sdk.StaFactDiscoverer.StaFactDiscoverer(Xunit.Abstractions.IMessageSink! diagnosticMessageSink) -> void -Xunit.Sdk.StaTheoryDiscoverer -Xunit.Sdk.StaTheoryDiscoverer.StaTheoryDiscoverer(Xunit.Abstractions.IMessageSink! diagnosticMessageSink) -> void -Xunit.Sdk.UIFactDiscoverer -Xunit.Sdk.UIFactDiscoverer.UIFactDiscoverer(Xunit.Abstractions.IMessageSink! diagnosticMessageSink) -> void -Xunit.Sdk.UITestCase -Xunit.Sdk.UITestCase.SyncContextType -Xunit.Sdk.UITestCase.SyncContextType.None = 0 -> Xunit.Sdk.UITestCase.SyncContextType -Xunit.Sdk.UITestCase.SyncContextType.Portable = 1 -> Xunit.Sdk.UITestCase.SyncContextType -Xunit.Sdk.UITestCase.UITestCase() -> void -Xunit.Sdk.UITestCase.UITestCase(Xunit.Sdk.UITestCase.SyncContextType synchronizationContextType, Xunit.Abstractions.IMessageSink! diagnosticMessageSink, Xunit.Sdk.TestMethodDisplay defaultMethodDisplay, Xunit.Abstractions.ITestMethod! testMethod, object?[]? testMethodArguments = null) -> void -Xunit.Sdk.UITestCaseRunner -Xunit.Sdk.UITestInvoker -Xunit.Sdk.UITestInvoker.RunAsync() -> System.Threading.Tasks.Task! -Xunit.Sdk.UITestRunner -Xunit.Sdk.UITheoryDiscoverer -Xunit.Sdk.UITheoryDiscoverer.UITheoryDiscoverer(Xunit.Abstractions.IMessageSink! diagnosticMessageSink) -> void -Xunit.Sdk.UITheoryTestCase -Xunit.Sdk.UITheoryTestCase.UITheoryTestCase() -> void -Xunit.Sdk.UITheoryTestCase.UITheoryTestCase(Xunit.Sdk.UITestCase.SyncContextType synchronizationContextType, Xunit.Abstractions.IMessageSink! diagnosticMessageSink, Xunit.Sdk.TestMethodDisplay defaultMethodDisplay, Xunit.Sdk.TestMethodDisplayOptions defaultMethodDisplayOptions, Xunit.Abstractions.ITestMethod! testMethod) -> void -Xunit.Sdk.UITheoryTestCaseRunner -Xunit.StaFactAttribute -Xunit.StaFactAttribute.StaFactAttribute() -> void -Xunit.StaTheoryAttribute -Xunit.StaTheoryAttribute.StaTheoryAttribute() -> void -Xunit.UIFactAttribute -Xunit.UIFactAttribute.UIFactAttribute() -> void -Xunit.UITheoryAttribute -Xunit.UITheoryAttribute.UITheoryAttribute() -> void From 04de106d6605fea73a9842aa97fceaa3866297a3 Mon Sep 17 00:00:00 2001 From: Siyu Mao Date: Tue, 17 Jan 2023 13:26:19 -0800 Subject: [PATCH 11/92] More cleanup --- Directory.Build.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Directory.Build.props b/Directory.Build.props index 6ff86125..f7c277db 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -14,7 +14,7 @@ true true true - true + true true From 0bdc56751e9b364517165b732779e4d9d1ee8d97 Mon Sep 17 00:00:00 2001 From: Sandy Armstrong Date: Wed, 18 Jan 2023 11:50:22 -0800 Subject: [PATCH 12/92] Use Mac app as harness for xunit test runner Need a full app bundle in order to start Cocoa mainloop. --- Directory.Packages.props | 1 + Xunit.StaFact.sln | 7 +++++ test/Xunit.StaFact.Tests.Mac/AppDelegate.cs | 25 +++++++++++++++++ .../CocoaFactTests.cs} | 16 +++++------ test/Xunit.StaFact.Tests.Mac/Info.plist | 26 +++++++++++++++++ test/Xunit.StaFact.Tests.Mac/Main.cs | 11 ++++++++ .../Xunit.StaFact.Tests.Mac.csproj | 28 +++++++++++++++++++ .../Xunit.StaFact.Tests.csproj | 6 ---- 8 files changed, 105 insertions(+), 15 deletions(-) create mode 100644 test/Xunit.StaFact.Tests.Mac/AppDelegate.cs rename test/{Xunit.StaFact.Tests/Mac/CocoaFactTest.cs => Xunit.StaFact.Tests.Mac/CocoaFactTests.cs} (74%) create mode 100644 test/Xunit.StaFact.Tests.Mac/Info.plist create mode 100644 test/Xunit.StaFact.Tests.Mac/Main.cs create mode 100644 test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj diff --git a/Directory.Packages.props b/Directory.Packages.props index 12841338..94385735 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -9,6 +9,7 @@ + diff --git a/Xunit.StaFact.sln b/Xunit.StaFact.sln index 95fc7dea..80131053 100644 --- a/Xunit.StaFact.sln +++ b/Xunit.StaFact.sln @@ -35,6 +35,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{1E94DC16-5 test\Directory.Build.targets = test\Directory.Build.targets EndProjectSection EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Xunit.StaFact.Tests.Mac", "test\Xunit.StaFact.Tests.Mac\Xunit.StaFact.Tests.Mac.csproj", "{077DFB77-0E63-4399-BD0B-4F9D9AC80495}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -49,6 +51,10 @@ Global {9F99EC1E-7FF7-419D-84F7-3CE96D653C2E}.Debug|Any CPU.Build.0 = Debug|Any CPU {9F99EC1E-7FF7-419D-84F7-3CE96D653C2E}.Release|Any CPU.ActiveCfg = Release|Any CPU {9F99EC1E-7FF7-419D-84F7-3CE96D653C2E}.Release|Any CPU.Build.0 = Release|Any CPU + {077DFB77-0E63-4399-BD0B-4F9D9AC80495}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {077DFB77-0E63-4399-BD0B-4F9D9AC80495}.Debug|Any CPU.Build.0 = Debug|Any CPU + {077DFB77-0E63-4399-BD0B-4F9D9AC80495}.Release|Any CPU.ActiveCfg = Release|Any CPU + {077DFB77-0E63-4399-BD0B-4F9D9AC80495}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -56,6 +62,7 @@ Global GlobalSection(NestedProjects) = preSolution {8C500C20-0CD6-4257-A9ED-C571DA6E68D6} = {B9635B8C-19E8-4D04-ACA4-A391D558D80A} {9F99EC1E-7FF7-419D-84F7-3CE96D653C2E} = {1E94DC16-537C-4D14-A201-ED3140A994EB} + {077DFB77-0E63-4399-BD0B-4F9D9AC80495} = {1E94DC16-537C-4D14-A201-ED3140A994EB} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {DA3510A0-C12F-4470-B8A6-197F0D32CB7C} diff --git a/test/Xunit.StaFact.Tests.Mac/AppDelegate.cs b/test/Xunit.StaFact.Tests.Mac/AppDelegate.cs new file mode 100644 index 00000000..7c04be57 --- /dev/null +++ b/test/Xunit.StaFact.Tests.Mac/AppDelegate.cs @@ -0,0 +1,25 @@ +// Copyright (c) Andrew Arnott. All rights reserved. +// Licensed under the Ms-PL license. See LICENSE file in the project root for full license information. + +using System.Runtime.InteropServices; + +namespace Xunit.StaFact.Tests.Mac; + +[Register("AppDelegate")] +public partial class AppDelegate : NSApplicationDelegate +{ + public override void DidFinishLaunching(NSNotification notification) + => ThreadPool.QueueUserWorkItem( + o => _exit( + Xunit.ConsoleClient.Program.Main(new[] + { + typeof(AppDelegate).Assembly.Location, + "-appdomains", + "denied", + }))); + + [LibraryImport(ObjCRuntime.Constants.libcLibrary)] +#pragma warning disable SA1300 // Element should begin with upper-case letter + private static partial void _exit(int exitCode); +#pragma warning restore SA1300 // Element should begin with upper-case letter +} diff --git a/test/Xunit.StaFact.Tests/Mac/CocoaFactTest.cs b/test/Xunit.StaFact.Tests.Mac/CocoaFactTests.cs similarity index 74% rename from test/Xunit.StaFact.Tests/Mac/CocoaFactTest.cs rename to test/Xunit.StaFact.Tests.Mac/CocoaFactTests.cs index d4a17022..4c8e41f4 100644 --- a/test/Xunit.StaFact.Tests/Mac/CocoaFactTest.cs +++ b/test/Xunit.StaFact.Tests.Mac/CocoaFactTests.cs @@ -1,20 +1,25 @@ -using System.Threading.Tasks; -using AppKit; +// Copyright (c) Andrew Arnott. All rights reserved. +// Licensed under the Ms-PL license. See LICENSE file in the project root for full license information. + using Xunit; + public class CocoaFactTests { [CocoaFact] public void AssertMainThreadSync() => NSApplication.EnsureUIThread(); + [Fact] public void AssertMainThreadSyncAndFail() => Assert.Throws(NSApplication.EnsureUIThread); + [CocoaFact] public Task AssertMainThreadAsyncReturnCompletedTask() { NSApplication.EnsureUIThread(); return Task.CompletedTask; } + [CocoaFact] public async Task AssertMainThreadAsyncWithAwait() { @@ -22,11 +27,4 @@ public async Task AssertMainThreadAsyncWithAwait() NSApplication.EnsureUIThread(); await Task.Delay(100); } - - [CocoaFact] - public void AssertExceptionsAreCaptured() - { - NSApplication.EnsureUIThread(); - throw new System.Exception("Thrown from Main"); - } } diff --git a/test/Xunit.StaFact.Tests.Mac/Info.plist b/test/Xunit.StaFact.Tests.Mac/Info.plist new file mode 100644 index 00000000..65c1f660 --- /dev/null +++ b/test/Xunit.StaFact.Tests.Mac/Info.plist @@ -0,0 +1,26 @@ + + + + + CFBundleName + Xunit.StaFact.Tests.Mac + CFBundleIdentifier + com.companyname.Xunit.StaFact.Tests.Mac + CFBundleShortVersionString + 1.0 + CFBundleVersion + 1 + CFBundleDevelopmentRegion + en + CFBundleInfoDictionaryVersion + 6.0 + CFBundlePackageType + APPL + CFBundleSignature + ???? + NSHumanReadableCopyright + ${AuthorCopyright:HtmlEncode} + NSPrincipalClass + NSApplication + + diff --git a/test/Xunit.StaFact.Tests.Mac/Main.cs b/test/Xunit.StaFact.Tests.Mac/Main.cs new file mode 100644 index 00000000..8f217142 --- /dev/null +++ b/test/Xunit.StaFact.Tests.Mac/Main.cs @@ -0,0 +1,11 @@ +// Copyright (c) Andrew Arnott. All rights reserved. +// Licensed under the Ms-PL license. See LICENSE file in the project root for full license information. + +using Xunit.StaFact.Tests.Mac; + +NSApplication.Init(); + +// Need to manually set up AppDelegate due to lack of UI +NSApplication.SharedApplication.Delegate = new AppDelegate(); + +NSApplication.Main(args); diff --git a/test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj b/test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj new file mode 100644 index 00000000..ba6da0ab --- /dev/null +++ b/test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj @@ -0,0 +1,28 @@ + + + net7.0-macos + Exe + enable + true + 10.15 + true + + + + + + + + + + + + + + + <_AppExePath>$(MSBuildThisFileDirectory)..\..\bin\Xunit.StaFact.Tests.Mac\$(Configuration)\$(TargetFramework)\Xunit.StaFact.Tests.Mac.app\Contents\MacOS\Xunit.StaFact.Tests.Mac + + + + + diff --git a/test/Xunit.StaFact.Tests/Xunit.StaFact.Tests.csproj b/test/Xunit.StaFact.Tests/Xunit.StaFact.Tests.csproj index 3fe55e6e..71be7992 100644 --- a/test/Xunit.StaFact.Tests/Xunit.StaFact.Tests.csproj +++ b/test/Xunit.StaFact.Tests/Xunit.StaFact.Tests.csproj @@ -1,16 +1,10 @@  net472;net6.0;net6.0-windows - word - 10.15 - osx-arm64 - - - From 2ca50968228a296964b54a90313b9673864d5e2b Mon Sep 17 00:00:00 2001 From: Sandy Armstrong Date: Wed, 18 Jan 2023 12:02:49 -0800 Subject: [PATCH 13/92] Delete .DS_Store files --- .DS_Store | Bin 6148 -> 0 bytes src/.DS_Store | Bin 8196 -> 0 bytes src/Xunit.StaFact/.DS_Store | Bin 6148 -> 0 bytes 3 files changed, 0 insertions(+), 0 deletions(-) delete mode 100644 .DS_Store delete mode 100644 src/.DS_Store delete mode 100644 src/Xunit.StaFact/.DS_Store diff --git a/.DS_Store b/.DS_Store deleted file mode 100644 index 577c29551279de393bf7ab00b26632e958c77bcb..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6148 zcmeHK!A`ma8|@MU#K1pf0M7>j zis%{4G^(Qm2Gs%p;x$qU%(0ii7-7&em}!I^5UxW3btpG22G`+W7sk&sm}%7EjGN|z zn>TaQp>Xwfc)n2XjC&esBnF6qSqAcYX=D9A_`Lt04Wbn>Kn(mT26&<6x0;ZWsjYL# wVXYOQ7oaHUmuY+nfr%=`;ESbr9aIU}1x^4xgPBIKfY3!i(Le(+@U09y1Lm!T0{{R3 diff --git a/src/.DS_Store b/src/.DS_Store deleted file mode 100644 index 86ec87e9139cc785a8c79d4a6fc384090186a187..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 8196 zcmeHMU5wOJ6h7auux(-4vVfG)g@IKRSYeh0hhltQoGFpf5c;GdnTh16kfAHDDXIrVu82wu2zQ=O1?DU>ksK9LxD$jsA-Xc63I*ZS*)J8E z6EZ@^eT+biz|9B*=~G7oR3eA0arL`S1@iM1ZzylOdA2&AAF?gaPp7XSF{x(qlv=4) znkpU09&#&LU-wI1hhE$lXuYm$=d0&>ez#>-a_X#3*YS1BF^i#tWteQTzu$5Ux6klwR&~y$cQY>Zd$&6SMG>C=(sP5 zs1WT89M1T5oYe_Jw7qht2r+TJ8seAL5M^bmmhDw`4_F1)$y!gDIkn#77`L#xvuKt% zw*G=^mj)d#r_LzocA;eJzS(Zufw4E>n@9cNY_I1Q{m#%Zr>Z5-+-0(zRW`fWnq3=$ zm3oGJ%XPfnX3=BWlu3&?SmUdc8VBnW^k$upHld!ZM3{ zbgy7KhUFaWt5}AAsK0D^R^B#y9evQ0)zk9jy87wrU2`;Tpp>_sELr|BwMmk~rS8@m zmHh_a#}3yB7BeLE9NY6nQd*<7FPP~pn%ov-P}b%c>!+)2gh}`pY6XS=}ZE*C^|>fr2|Y$dP#R3^a@3jar-bSa9X-y65){ znNDz57sOl#&+YXN=|!`r!hDKuYBP_94~NGCr*6aY-Efiv-`c2YdxGWK4I>Ogt)E_} z^=OYu>LrOEh~<L%~eUM+ytD1j~`e3bbMa+R=e7bmI~9 zq7VHTfDQ|XVPgm+(2h#&`H0*YFE|#c%jM zAtmHQLt;)M__)U{QB9D3p;!CFVm_NVL83h%F?6d0Np5~v+48R@$kl0KN;J%zHG5u= zC#%v${>4BGly4W{LAmO@ykFOt;9KP3ojbUAl@@2t`@DPUgH)Ya(@18>^>P z3e{w?vx^tHph|zAvuEgC`hY&B&zQ5{Fk7$Dbr2*pK*PL{r%kvI%Oa+(#71mF8?&_& z+p&Y$x)Zyw5BqTdIcDr(9AU;fsNg7$VHhKL4$tESyolpCfs=Rzui`c4@F~2FcLWE= zn7OseNg?s!#LO&bi;nF&2idC1?ePo5+C&IU5|dg`|99X1`~O5s#B(tMF#`W{1W?nJ z?dsqlZnudBwRVb+$N30aU^gmc=)zrCj2zGks%2H diff --git a/src/Xunit.StaFact/.DS_Store b/src/Xunit.StaFact/.DS_Store deleted file mode 100644 index a58cb1e76034cbe7aecc7f789b171f186e08868d..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6148 zcmeHKOH0E*5T0$TO({YT3VK`cTC}ycAYMYPM=wV7pi&c4G&E*QANEiRx$7VDkNA6> z+1-HE9z2QI8QA@1=dqjlAo~CS(Vm2LfC>OO*a!tFON7izT{#;}DD)g>;KO||9Swqb z$wYtAMBiQn4?^g}9(?+K6`>EgKdyctzz)SX2Mpa_$SXi|lJVhEFtc4^~Wi>X1A4nnVt^VpTM$BWRbqh0E75UxS)nE_^Ck%7D! zR_Odc#b0LWBY!c4N6Y{-@Xr_!g^t&0V^Q{O{Z<~GwG!JMHWG?UNkKt<;SzuY+DEpv d)A%Ln80T6{4bm)R*Xf9S5zvHi#|-=e10T8`ONIad From b6218584de1ea13bdd2efea8e48ce7b393b1b895 Mon Sep 17 00:00:00 2001 From: Sandy Armstrong Date: Wed, 18 Jan 2023 12:20:15 -0800 Subject: [PATCH 14/92] Ensure macos workload is installed --- init.ps1 | 2 ++ 1 file changed, 2 insertions(+) diff --git a/init.ps1 b/init.ps1 index 774ead58..6d3a30b3 100755 --- a/init.ps1 +++ b/init.ps1 @@ -65,6 +65,8 @@ if (!$NoPrerequisites) { if ($env:OS -eq 'Windows_NT') { $EnvVars['PROCDUMP_PATH'] = & "$PSScriptRoot\azure-pipelines\Get-ProcDump.ps1" } + + dotnet workload install macos } # Workaround nuget credential provider bug that causes very unreliable package restores on Azure Pipelines From 0695648ce3f7a5471c9076bf8145a04150317415 Mon Sep 17 00:00:00 2001 From: Sandy Armstrong Date: Wed, 18 Jan 2023 13:13:39 -0800 Subject: [PATCH 15/92] Convert to file-scoped namespaces --- src/Xunit.StaFact/Mac/CocoaFactAttribute.cs | 19 +- src/Xunit.StaFact/Mac/CocoaTheoryAttribute.cs | 19 +- .../Sdk.Mac/CocoaFactDiscoverer.cs | 63 ++-- .../Sdk.Mac/CocoaSynchronizationContext.cs | 275 +++++++++--------- .../CocoaSynchronizationContextAdapter.cs | 27 +- .../Sdk.Mac/CocoaTheoryDiscoverer.cs | 37 ++- 6 files changed, 217 insertions(+), 223 deletions(-) diff --git a/src/Xunit.StaFact/Mac/CocoaFactAttribute.cs b/src/Xunit.StaFact/Mac/CocoaFactAttribute.cs index c632e68e..05269e36 100644 --- a/src/Xunit.StaFact/Mac/CocoaFactAttribute.cs +++ b/src/Xunit.StaFact/Mac/CocoaFactAttribute.cs @@ -4,15 +4,14 @@ using System.Threading; using Xunit.Sdk; -namespace Xunit +namespace Xunit; + +/// +/// Identifies an xunit test that starts on with a +/// running on . +/// +[AttributeUsage(AttributeTargets.Method, AllowMultiple = false)] +[XunitTestCaseDiscoverer("Xunit.Sdk.CocoaFactDiscoverer", ThisAssembly.AssemblyName)] +public class CocoaFactAttribute : FactAttribute { - /// - /// Identifies an xunit test that starts on with a - /// running on . - /// - [AttributeUsage(AttributeTargets.Method, AllowMultiple = false)] - [XunitTestCaseDiscoverer("Xunit.Sdk.CocoaFactDiscoverer", ThisAssembly.AssemblyName)] - public class CocoaFactAttribute : FactAttribute - { - } } diff --git a/src/Xunit.StaFact/Mac/CocoaTheoryAttribute.cs b/src/Xunit.StaFact/Mac/CocoaTheoryAttribute.cs index d86ac057..e8131c28 100644 --- a/src/Xunit.StaFact/Mac/CocoaTheoryAttribute.cs +++ b/src/Xunit.StaFact/Mac/CocoaTheoryAttribute.cs @@ -4,15 +4,14 @@ using System.Threading; using Xunit.Sdk; -namespace Xunit +namespace Xunit; + +/// +/// Identifies an xunit theory that starts on with a +/// running on +/// +[AttributeUsage(AttributeTargets.Method, AllowMultiple = false)] +[XunitTestCaseDiscoverer("Xunit.Sdk.CocoaTheoryDiscoverer", ThisAssembly.AssemblyName)] +public class CocoaTheoryAttribute : TheoryAttribute { - /// - /// Identifies an xunit theory that starts on with a - /// running on - /// - [AttributeUsage(AttributeTargets.Method, AllowMultiple = false)] - [XunitTestCaseDiscoverer("Xunit.Sdk.CocoaTheoryDiscoverer", ThisAssembly.AssemblyName)] - public class CocoaTheoryAttribute : TheoryAttribute - { - } } diff --git a/src/Xunit.StaFact/Sdk.Mac/CocoaFactDiscoverer.cs b/src/Xunit.StaFact/Sdk.Mac/CocoaFactDiscoverer.cs index 8c2bb9d9..9fd78a33 100644 --- a/src/Xunit.StaFact/Sdk.Mac/CocoaFactDiscoverer.cs +++ b/src/Xunit.StaFact/Sdk.Mac/CocoaFactDiscoverer.cs @@ -7,46 +7,45 @@ using System.Runtime.InteropServices; using Xunit.Abstractions; -namespace Xunit.Sdk +namespace Xunit.Sdk; + +/// +/// The discovery class for . +/// +public class CocoaFactDiscoverer : FactDiscoverer { + private readonly IMessageSink diagnosticMessageSink; + /// - /// The discovery class for . + /// Initializes a new instance of the class. /// - public class CocoaFactDiscoverer : FactDiscoverer + /// The diagnostic message sink. + public CocoaFactDiscoverer(IMessageSink diagnosticMessageSink) + : base(diagnosticMessageSink) { - private readonly IMessageSink diagnosticMessageSink; - - /// - /// Initializes a new instance of the class. - /// - /// The diagnostic message sink. - public CocoaFactDiscoverer(IMessageSink diagnosticMessageSink) - : base(diagnosticMessageSink) - { - this.diagnosticMessageSink = diagnosticMessageSink; - } + this.diagnosticMessageSink = diagnosticMessageSink; + } - class MyMessage: IMessageSinkMessage + class MyMessage: IMessageSinkMessage + { + public string Message { get; set; } + } + + protected override IXunitTestCase CreateTestCase(ITestFrameworkDiscoveryOptions discoveryOptions, ITestMethod testMethod, IAttributeInfo factAttribute) + { + var message = new MyMessage { - public string Message { get; set; } - } + Message = "Hello" + }; - protected override IXunitTestCase CreateTestCase(ITestFrameworkDiscoveryOptions discoveryOptions, ITestMethod testMethod, IAttributeInfo factAttribute) + Console.WriteLine("hello!!"); + diagnosticMessageSink.OnMessage(message); + if (testMethod.Method.ReturnType.Name == "System.Void" && + testMethod.Method.GetCustomAttributes(typeof(AsyncStateMachineAttribute)).Any()) { - var message = new MyMessage - { - Message = "Hello" - }; - - Console.WriteLine("hello!!"); - diagnosticMessageSink.OnMessage(message); - if (testMethod.Method.ReturnType.Name == "System.Void" && - testMethod.Method.GetCustomAttributes(typeof(AsyncStateMachineAttribute)).Any()) - { - return new ExecutionErrorTestCase(this.diagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), TestMethodDisplayOptions.None, testMethod, "Async void methods are not supported."); - } - - return (IXunitTestCase)new UITestCase(UITestCase.SyncContextType.Cocoa, this.diagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), testMethod); + return new ExecutionErrorTestCase(this.diagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), TestMethodDisplayOptions.None, testMethod, "Async void methods are not supported."); } + + return (IXunitTestCase)new UITestCase(UITestCase.SyncContextType.Cocoa, this.diagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), testMethod); } } diff --git a/src/Xunit.StaFact/Sdk.Mac/CocoaSynchronizationContext.cs b/src/Xunit.StaFact/Sdk.Mac/CocoaSynchronizationContext.cs index ebf24467..c9c42803 100644 --- a/src/Xunit.StaFact/Sdk.Mac/CocoaSynchronizationContext.cs +++ b/src/Xunit.StaFact/Sdk.Mac/CocoaSynchronizationContext.cs @@ -5,194 +5,193 @@ using Foundation; -namespace Xunit.Sdk +namespace Xunit.Sdk; + +internal sealed class CocoaSynchronizationContext : SynchronizationContext { - internal sealed class CocoaSynchronizationContext : SynchronizationContext - { - private readonly Queue> messageQueue = new Queue>(); - private readonly int mainThread = Environment.CurrentManagedThreadId; - private readonly AsyncAutoResetEvent workItemDone = new AsyncAutoResetEvent(); - private readonly string name; - private readonly bool shouldSetAsCurrent; - private int activeOperations; - private bool pumping; - private bool pumpingEnded; - private ExceptionAggregator? aggregator; - - /// - /// Initializes a new instance of the class. - /// - public CocoaSynchronizationContext(string name, bool shouldSetAsCurrent) - { - this.name = name; - this.shouldSetAsCurrent = shouldSetAsCurrent; - } + private readonly Queue> messageQueue = new Queue>(); + private readonly int mainThread = Environment.CurrentManagedThreadId; + private readonly AsyncAutoResetEvent workItemDone = new AsyncAutoResetEvent(); + private readonly string name; + private readonly bool shouldSetAsCurrent; + private int activeOperations; + private bool pumping; + private bool pumpingEnded; + private ExceptionAggregator? aggregator; + + /// + /// Initializes a new instance of the class. + /// + public CocoaSynchronizationContext(string name, bool shouldSetAsCurrent) + { + this.name = name; + this.shouldSetAsCurrent = shouldSetAsCurrent; + } - internal bool IsInContext => this.mainThread == Environment.CurrentManagedThreadId; + internal bool IsInContext => this.mainThread == Environment.CurrentManagedThreadId; - private bool AnyMessagesInQueue + private bool AnyMessagesInQueue + { + get { - get + lock (this.messageQueue) { - lock (this.messageQueue) - { - return this.messageQueue.Count > 0; - } + return this.messageQueue.Count > 0; } } + } - private bool AnyPendingOperations => Volatile.Read(ref this.activeOperations) > 0; + private bool AnyPendingOperations => Volatile.Read(ref this.activeOperations) > 0; - public override SynchronizationContext CreateCopy() - => new CocoaSynchronizationContext(name, shouldSetAsCurrent); + public override SynchronizationContext CreateCopy() + => new CocoaSynchronizationContext(name, shouldSetAsCurrent); - public override void Post(SendOrPostCallback d, object state) - => NSRunLoop.Main.BeginInvokeOnMainThread(() => d(state)); + public override void Post(SendOrPostCallback d, object state) + => NSRunLoop.Main.BeginInvokeOnMainThread(() => d(state)); - public override void Send(SendOrPostCallback d, object state) - => NSRunLoop.Main.InvokeOnMainThread(() => d(state)); + public override void Send(SendOrPostCallback d, object state) + => NSRunLoop.Main.InvokeOnMainThread(() => d(state)); - /// - /// Blocks the calling thread to pump messages until a task has completed. - /// - /// The task that must complete to break out of the message loop. - public void PumpMessages(Task untilCompleted) - { - this.VerifyState(); + /// + /// Blocks the calling thread to pump messages until a task has completed. + /// + /// The task that must complete to break out of the message loop. + public void PumpMessages(Task untilCompleted) + { + this.VerifyState(); - this.pumping = true; - try - { - // Arrange to wake up immediately when the task completes. - untilCompleted.ContinueWith( - _ => - { - lock (this.messageQueue) - { - Monitor.Pulse(this.messageQueue); - } - }, - TaskScheduler.Default); - - // Now run the message loop until the task completes. - while (!untilCompleted.IsCompleted) + this.pumping = true; + try + { + // Arrange to wake up immediately when the task completes. + untilCompleted.ContinueWith( + _ => { - this.TryOneWorkItem(); - } - } - finally + lock (this.messageQueue) + { + Monitor.Pulse(this.messageQueue); + } + }, + TaskScheduler.Default); + + // Now run the message loop until the task completes. + while (!untilCompleted.IsCompleted) { - this.pumping = false; - this.pumpingEnded = true; + this.TryOneWorkItem(); } } + finally + { + this.pumping = false; + this.pumpingEnded = true; + } + } + + public async Task WaitForOperationCompletionAsync() + { + while (this.AnyPendingOperations || this.AnyMessagesInQueue) + { + await this.workItemDone.WaitAsync().ConfigureAwait(false); + } + } - public async Task WaitForOperationCompletionAsync() + /// + /// Pump messages until all pending operations have completed + /// and the message queue is empty. + /// + public void CompleteOperations() + { + this.VerifyState(); + this.pumping = true; + try { while (this.AnyPendingOperations || this.AnyMessagesInQueue) { - await this.workItemDone.WaitAsync().ConfigureAwait(false); + this.TryOneWorkItem(); } } + finally + { + this.pumping = false; + } + } + + /// + public override void OperationStarted() + { + Interlocked.Increment(ref this.activeOperations); + } - /// - /// Pump messages until all pending operations have completed - /// and the message queue is empty. - /// - public void CompleteOperations() + /// + public override void OperationCompleted() + { + int result = Interlocked.Decrement(ref this.activeOperations); + if (result == 0) { - this.VerifyState(); - this.pumping = true; - try - { - while (this.AnyPendingOperations || this.AnyMessagesInQueue) - { - this.TryOneWorkItem(); - } - } - finally + // Give any message waiter a heads up that the operation count has reached zero, + // in case the queue is empty at the same time the operation count is, which + // is usually a sign to return to its caller. + lock (this.messageQueue) { - this.pumping = false; + Monitor.Pulse(this.messageQueue); } } + } + + internal void SetExceptionAggregator(ExceptionAggregator aggregator) + { + this.aggregator = aggregator; + } - /// - public override void OperationStarted() + private void VerifyState() + { + if (Environment.CurrentManagedThreadId != this.mainThread) { - Interlocked.Increment(ref this.activeOperations); + throw new InvalidOperationException("Wrong thread"); } - /// - public override void OperationCompleted() + if (Current != this && this.shouldSetAsCurrent) { - int result = Interlocked.Decrement(ref this.activeOperations); - if (result == 0) - { - // Give any message waiter a heads up that the operation count has reached zero, - // in case the queue is empty at the same time the operation count is, which - // is usually a sign to return to its caller. - lock (this.messageQueue) - { - Monitor.Pulse(this.messageQueue); - } - } + throw new InvalidOperationException("Wrong sync context"); } - internal void SetExceptionAggregator(ExceptionAggregator aggregator) + if (this.pumping) { - this.aggregator = aggregator; + throw new InvalidOperationException("Already pumping"); } + } - private void VerifyState() + private bool TryOneWorkItem() + { + KeyValuePair work = default; + lock (this.messageQueue) { - if (Environment.CurrentManagedThreadId != this.mainThread) - { - throw new InvalidOperationException("Wrong thread"); - } - - if (Current != this && this.shouldSetAsCurrent) + if (this.messageQueue.Count == 0) { - throw new InvalidOperationException("Wrong sync context"); + Monitor.Wait(this.messageQueue); + return false; } - if (this.pumping) - { - throw new InvalidOperationException("Already pumping"); - } + work = this.messageQueue.Dequeue(); } - private bool TryOneWorkItem() + try { - KeyValuePair work = default; - lock (this.messageQueue) - { - if (this.messageQueue.Count == 0) - { - Monitor.Wait(this.messageQueue); - return false; - } - - work = this.messageQueue.Dequeue(); - } - - try + if (this.aggregator is object) { - if (this.aggregator is object) - { - this.aggregator.Run(() => work.Key(work.Value)); - } - else - { - work.Key(work.Value); - } - - return true; + this.aggregator.Run(() => work.Key(work.Value)); } - finally + else { - this.workItemDone.Set(); + work.Key(work.Value); } + + return true; + } + finally + { + this.workItemDone.Set(); } } } diff --git a/src/Xunit.StaFact/Sdk.Mac/CocoaSynchronizationContextAdapter.cs b/src/Xunit.StaFact/Sdk.Mac/CocoaSynchronizationContextAdapter.cs index cbf6bbaa..ea85b716 100644 --- a/src/Xunit.StaFact/Sdk.Mac/CocoaSynchronizationContextAdapter.cs +++ b/src/Xunit.StaFact/Sdk.Mac/CocoaSynchronizationContextAdapter.cs @@ -7,25 +7,24 @@ using Foundation; -namespace Xunit.Sdk +namespace Xunit.Sdk; + +internal class CocoaSynchronizationContextAdapter : SyncContextAdapter { - internal class CocoaSynchronizationContextAdapter : SyncContextAdapter - { - internal static readonly SyncContextAdapter Default = new CocoaSynchronizationContextAdapter(); + internal static readonly SyncContextAdapter Default = new CocoaSynchronizationContextAdapter(); - private CocoaSynchronizationContextAdapter() - { - } + private CocoaSynchronizationContextAdapter() + { + } - internal override bool CanCompleteOperations => true; + internal override bool CanCompleteOperations => true; - internal override SynchronizationContext Create(string name) => new CocoaSynchronizationContext(name, this.ShouldSetAsCurrent); + internal override SynchronizationContext Create(string name) => new CocoaSynchronizationContext(name, this.ShouldSetAsCurrent); - internal override Task WaitForOperationCompletionAsync(SynchronizationContext syncContext) => ((CocoaSynchronizationContext)syncContext).WaitForOperationCompletionAsync(); + internal override Task WaitForOperationCompletionAsync(SynchronizationContext syncContext) => ((CocoaSynchronizationContext)syncContext).WaitForOperationCompletionAsync(); - internal override void PumpTill(SynchronizationContext synchronizationContext, Task task) - { - ((CocoaSynchronizationContext)synchronizationContext).PumpMessages(task); - } + internal override void PumpTill(SynchronizationContext synchronizationContext, Task task) + { + ((CocoaSynchronizationContext)synchronizationContext).PumpMessages(task); } } diff --git a/src/Xunit.StaFact/Sdk.Mac/CocoaTheoryDiscoverer.cs b/src/Xunit.StaFact/Sdk.Mac/CocoaTheoryDiscoverer.cs index 9f476643..d1246116 100644 --- a/src/Xunit.StaFact/Sdk.Mac/CocoaTheoryDiscoverer.cs +++ b/src/Xunit.StaFact/Sdk.Mac/CocoaTheoryDiscoverer.cs @@ -5,30 +5,29 @@ using System.Runtime.InteropServices; using Xunit.Abstractions; -namespace Xunit.Sdk +namespace Xunit.Sdk; + +/// +/// The discovery class for . +/// +public class CocoaTheoryDiscoverer : TheoryDiscoverer { /// - /// The discovery class for . + /// Initializes a new instance of the class. /// - public class CocoaTheoryDiscoverer : TheoryDiscoverer + /// The diagnostic message sink. + public CocoaTheoryDiscoverer(IMessageSink diagnosticMessageSink) + : base(diagnosticMessageSink) { - /// - /// Initializes a new instance of the class. - /// - /// The diagnostic message sink. - public CocoaTheoryDiscoverer(IMessageSink diagnosticMessageSink) - : base(diagnosticMessageSink) - { - } + } - protected override IEnumerable CreateTestCasesForDataRow(ITestFrameworkDiscoveryOptions discoveryOptions, ITestMethod testMethod, IAttributeInfo theoryAttribute, object[] dataRow) - { - yield return (IXunitTestCase)new UITestCase(UITestCase.SyncContextType.Cocoa, this.DiagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), testMethod, dataRow); - } + protected override IEnumerable CreateTestCasesForDataRow(ITestFrameworkDiscoveryOptions discoveryOptions, ITestMethod testMethod, IAttributeInfo theoryAttribute, object[] dataRow) + { + yield return (IXunitTestCase)new UITestCase(UITestCase.SyncContextType.Cocoa, this.DiagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), testMethod, dataRow); + } - protected override IEnumerable CreateTestCasesForTheory(ITestFrameworkDiscoveryOptions discoveryOptions, ITestMethod testMethod, IAttributeInfo theoryAttribute) - { - yield return (IXunitTestCase)new UITheoryTestCase(UITestCase.SyncContextType.Cocoa, this.DiagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), TestMethodDisplayOptions.None, testMethod); - } + protected override IEnumerable CreateTestCasesForTheory(ITestFrameworkDiscoveryOptions discoveryOptions, ITestMethod testMethod, IAttributeInfo theoryAttribute) + { + yield return (IXunitTestCase)new UITheoryTestCase(UITestCase.SyncContextType.Cocoa, this.DiagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), TestMethodDisplayOptions.None, testMethod); } } From 77e685488bf8a2a7e67b537c79a646dd26c1158a Mon Sep 17 00:00:00 2001 From: Sandy Armstrong Date: Wed, 18 Jan 2023 13:15:04 -0800 Subject: [PATCH 16/92] Cleanup --- src/Xunit.StaFact/Mac/CocoaFactAttribute.cs | 5 +- src/Xunit.StaFact/Mac/CocoaTheoryAttribute.cs | 7 +-- .../Sdk.Mac/CocoaFactDiscoverer.cs | 20 +------ .../Sdk.Mac/CocoaSynchronizationContext.cs | 21 +++---- .../CocoaSynchronizationContextAdapter.cs | 10 +--- .../Sdk.Mac/CocoaTheoryDiscoverer.cs | 10 +--- src/Xunit.StaFact/Xunit.StaFact.csproj | 1 - .../net6.0-macos10.15/PublicAPI.Unshipped.txt | 55 +++++++++++++++++++ 8 files changed, 74 insertions(+), 55 deletions(-) diff --git a/src/Xunit.StaFact/Mac/CocoaFactAttribute.cs b/src/Xunit.StaFact/Mac/CocoaFactAttribute.cs index 05269e36..32f34f5b 100644 --- a/src/Xunit.StaFact/Mac/CocoaFactAttribute.cs +++ b/src/Xunit.StaFact/Mac/CocoaFactAttribute.cs @@ -1,7 +1,6 @@ // Copyright (c) Andrew Arnott. All rights reserved. -// Licensed under the Ms-PL license. See LICENSE.txt file in the project root for full license information. -using System; -using System.Threading; +// Licensed under the Ms-PL license. See LICENSE file in the project root for full license information. + using Xunit.Sdk; namespace Xunit; diff --git a/src/Xunit.StaFact/Mac/CocoaTheoryAttribute.cs b/src/Xunit.StaFact/Mac/CocoaTheoryAttribute.cs index e8131c28..7a2ec440 100644 --- a/src/Xunit.StaFact/Mac/CocoaTheoryAttribute.cs +++ b/src/Xunit.StaFact/Mac/CocoaTheoryAttribute.cs @@ -1,14 +1,13 @@ // Copyright (c) Andrew Arnott. All rights reserved. -// Licensed under the Ms-PL license. See LICENSE.txt file in the project root for full license information. -using System; -using System.Threading; +// Licensed under the Ms-PL license. See LICENSE file in the project root for full license information. + using Xunit.Sdk; namespace Xunit; /// /// Identifies an xunit theory that starts on with a -/// running on +/// running on . /// [AttributeUsage(AttributeTargets.Method, AllowMultiple = false)] [XunitTestCaseDiscoverer("Xunit.Sdk.CocoaTheoryDiscoverer", ThisAssembly.AssemblyName)] diff --git a/src/Xunit.StaFact/Sdk.Mac/CocoaFactDiscoverer.cs b/src/Xunit.StaFact/Sdk.Mac/CocoaFactDiscoverer.cs index 9fd78a33..121dded5 100644 --- a/src/Xunit.StaFact/Sdk.Mac/CocoaFactDiscoverer.cs +++ b/src/Xunit.StaFact/Sdk.Mac/CocoaFactDiscoverer.cs @@ -1,11 +1,7 @@ // Copyright (c) Andrew Arnott. All rights reserved. -// Licensed under the Ms-PL license. See LICENSE.txt file in the project root for full license information. +// Licensed under the Ms-PL license. See LICENSE file in the project root for full license information. -using System; -using System.Linq; using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; -using Xunit.Abstractions; namespace Xunit.Sdk; @@ -26,26 +22,14 @@ public CocoaFactDiscoverer(IMessageSink diagnosticMessageSink) this.diagnosticMessageSink = diagnosticMessageSink; } - class MyMessage: IMessageSinkMessage - { - public string Message { get; set; } - } - protected override IXunitTestCase CreateTestCase(ITestFrameworkDiscoveryOptions discoveryOptions, ITestMethod testMethod, IAttributeInfo factAttribute) { - var message = new MyMessage - { - Message = "Hello" - }; - - Console.WriteLine("hello!!"); - diagnosticMessageSink.OnMessage(message); if (testMethod.Method.ReturnType.Name == "System.Void" && testMethod.Method.GetCustomAttributes(typeof(AsyncStateMachineAttribute)).Any()) { return new ExecutionErrorTestCase(this.diagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), TestMethodDisplayOptions.None, testMethod, "Async void methods are not supported."); } - return (IXunitTestCase)new UITestCase(UITestCase.SyncContextType.Cocoa, this.diagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), testMethod); + return new UITestCase(UITestCase.SyncContextType.Cocoa, this.diagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), testMethod); } } diff --git a/src/Xunit.StaFact/Sdk.Mac/CocoaSynchronizationContext.cs b/src/Xunit.StaFact/Sdk.Mac/CocoaSynchronizationContext.cs index c9c42803..85290a59 100644 --- a/src/Xunit.StaFact/Sdk.Mac/CocoaSynchronizationContext.cs +++ b/src/Xunit.StaFact/Sdk.Mac/CocoaSynchronizationContext.cs @@ -1,23 +1,17 @@ -// Copyright (c) Aaron Bockover. All rights reserved. -// Licensed under the Ms-PL license. See LICENSE.txt file in the project root for full license information. - -using System.Threading; - -using Foundation; +// Copyright (c) Andrew Arnott. All rights reserved. +// Licensed under the Ms-PL license. See LICENSE file in the project root for full license information. namespace Xunit.Sdk; internal sealed class CocoaSynchronizationContext : SynchronizationContext { - - private readonly Queue> messageQueue = new Queue>(); + private readonly Queue> messageQueue = new(); private readonly int mainThread = Environment.CurrentManagedThreadId; - private readonly AsyncAutoResetEvent workItemDone = new AsyncAutoResetEvent(); + private readonly AsyncAutoResetEvent workItemDone = new(); private readonly string name; private readonly bool shouldSetAsCurrent; private int activeOperations; private bool pumping; - private bool pumpingEnded; private ExceptionAggregator? aggregator; /// @@ -45,12 +39,12 @@ private bool AnyMessagesInQueue private bool AnyPendingOperations => Volatile.Read(ref this.activeOperations) > 0; public override SynchronizationContext CreateCopy() - => new CocoaSynchronizationContext(name, shouldSetAsCurrent); + => new CocoaSynchronizationContext(this.name, this.shouldSetAsCurrent); - public override void Post(SendOrPostCallback d, object state) + public override void Post(SendOrPostCallback d, object? state) => NSRunLoop.Main.BeginInvokeOnMainThread(() => d(state)); - public override void Send(SendOrPostCallback d, object state) + public override void Send(SendOrPostCallback d, object? state) => NSRunLoop.Main.InvokeOnMainThread(() => d(state)); /// @@ -84,7 +78,6 @@ public void PumpMessages(Task untilCompleted) finally { this.pumping = false; - this.pumpingEnded = true; } } diff --git a/src/Xunit.StaFact/Sdk.Mac/CocoaSynchronizationContextAdapter.cs b/src/Xunit.StaFact/Sdk.Mac/CocoaSynchronizationContextAdapter.cs index ea85b716..b474c46f 100644 --- a/src/Xunit.StaFact/Sdk.Mac/CocoaSynchronizationContextAdapter.cs +++ b/src/Xunit.StaFact/Sdk.Mac/CocoaSynchronizationContextAdapter.cs @@ -1,11 +1,5 @@ -// Copyright (c) Aaron Bockover. All rights reserved. -// Licensed under the Ms-PL license. See LICENSE.txt file in the project root for full license information. - -using System; -using System.Threading; -using System.Threading.Tasks; - -using Foundation; +// Copyright (c) Andrew Arnott. All rights reserved. +// Licensed under the Ms-PL license. See LICENSE file in the project root for full license information. namespace Xunit.Sdk; diff --git a/src/Xunit.StaFact/Sdk.Mac/CocoaTheoryDiscoverer.cs b/src/Xunit.StaFact/Sdk.Mac/CocoaTheoryDiscoverer.cs index d1246116..7ce9e4cf 100644 --- a/src/Xunit.StaFact/Sdk.Mac/CocoaTheoryDiscoverer.cs +++ b/src/Xunit.StaFact/Sdk.Mac/CocoaTheoryDiscoverer.cs @@ -1,9 +1,5 @@ // Copyright (c) Andrew Arnott. All rights reserved. -// Licensed under the Ms-PL license. See LICENSE.txt file in the project root for full license information. - -using System.Collections.Generic; -using System.Runtime.InteropServices; -using Xunit.Abstractions; +// Licensed under the Ms-PL license. See LICENSE file in the project root for full license information. namespace Xunit.Sdk; @@ -23,11 +19,11 @@ public CocoaTheoryDiscoverer(IMessageSink diagnosticMessageSink) protected override IEnumerable CreateTestCasesForDataRow(ITestFrameworkDiscoveryOptions discoveryOptions, ITestMethod testMethod, IAttributeInfo theoryAttribute, object[] dataRow) { - yield return (IXunitTestCase)new UITestCase(UITestCase.SyncContextType.Cocoa, this.DiagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), testMethod, dataRow); + yield return new UITestCase(UITestCase.SyncContextType.Cocoa, this.DiagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), testMethod, dataRow); } protected override IEnumerable CreateTestCasesForTheory(ITestFrameworkDiscoveryOptions discoveryOptions, ITestMethod testMethod, IAttributeInfo theoryAttribute) { - yield return (IXunitTestCase)new UITheoryTestCase(UITestCase.SyncContextType.Cocoa, this.DiagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), TestMethodDisplayOptions.None, testMethod); + yield return new UITheoryTestCase(UITestCase.SyncContextType.Cocoa, this.DiagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), TestMethodDisplayOptions.None, testMethod); } } diff --git a/src/Xunit.StaFact/Xunit.StaFact.csproj b/src/Xunit.StaFact/Xunit.StaFact.csproj index dab95daa..823e9552 100644 --- a/src/Xunit.StaFact/Xunit.StaFact.csproj +++ b/src/Xunit.StaFact/Xunit.StaFact.csproj @@ -1,7 +1,6 @@  net472;netstandard2.0;net6.0;net6.0-windows;net6.0-macos10.15 - Xunit Run your xunit-based tests on an STA thread with the WPF Dispatcher, a WinForms SynchronizationContext, or even a cross-platform generic UI thread emulation with a SynchronizationContext that keeps code running on a "main thread" for that test. diff --git a/src/Xunit.StaFact/net6.0-macos10.15/PublicAPI.Unshipped.txt b/src/Xunit.StaFact/net6.0-macos10.15/PublicAPI.Unshipped.txt index e69de29b..5ce3afb1 100644 --- a/src/Xunit.StaFact/net6.0-macos10.15/PublicAPI.Unshipped.txt +++ b/src/Xunit.StaFact/net6.0-macos10.15/PublicAPI.Unshipped.txt @@ -0,0 +1,55 @@ +#nullable enable +override Xunit.Sdk.CocoaFactDiscoverer.CreateTestCase(Xunit.Abstractions.ITestFrameworkDiscoveryOptions! discoveryOptions, Xunit.Abstractions.ITestMethod! testMethod, Xunit.Abstractions.IAttributeInfo! factAttribute) -> Xunit.Sdk.IXunitTestCase! +override Xunit.Sdk.CocoaTheoryDiscoverer.CreateTestCasesForDataRow(Xunit.Abstractions.ITestFrameworkDiscoveryOptions! discoveryOptions, Xunit.Abstractions.ITestMethod! testMethod, Xunit.Abstractions.IAttributeInfo! theoryAttribute, object![]! dataRow) -> System.Collections.Generic.IEnumerable! +override Xunit.Sdk.CocoaTheoryDiscoverer.CreateTestCasesForTheory(Xunit.Abstractions.ITestFrameworkDiscoveryOptions! discoveryOptions, Xunit.Abstractions.ITestMethod! testMethod, Xunit.Abstractions.IAttributeInfo! theoryAttribute) -> System.Collections.Generic.IEnumerable! +override Xunit.Sdk.StaFactDiscoverer.CreateTestCase(Xunit.Abstractions.ITestFrameworkDiscoveryOptions! discoveryOptions, Xunit.Abstractions.ITestMethod! testMethod, Xunit.Abstractions.IAttributeInfo! factAttribute) -> Xunit.Sdk.IXunitTestCase! +override Xunit.Sdk.StaTheoryDiscoverer.CreateTestCasesForDataRow(Xunit.Abstractions.ITestFrameworkDiscoveryOptions! discoveryOptions, Xunit.Abstractions.ITestMethod! testMethod, Xunit.Abstractions.IAttributeInfo! theoryAttribute, object![]! dataRow) -> System.Collections.Generic.IEnumerable! +override Xunit.Sdk.StaTheoryDiscoverer.CreateTestCasesForTheory(Xunit.Abstractions.ITestFrameworkDiscoveryOptions! discoveryOptions, Xunit.Abstractions.ITestMethod! testMethod, Xunit.Abstractions.IAttributeInfo! theoryAttribute) -> System.Collections.Generic.IEnumerable! +override Xunit.Sdk.UIFactDiscoverer.CreateTestCase(Xunit.Abstractions.ITestFrameworkDiscoveryOptions! discoveryOptions, Xunit.Abstractions.ITestMethod! testMethod, Xunit.Abstractions.IAttributeInfo! factAttribute) -> Xunit.Sdk.IXunitTestCase! +override Xunit.Sdk.UITestCase.Deserialize(Xunit.Abstractions.IXunitSerializationInfo! data) -> void +override Xunit.Sdk.UITestCase.RunAsync(Xunit.Abstractions.IMessageSink! diagnosticMessageSink, Xunit.Sdk.IMessageBus! messageBus, object![]! constructorArguments, Xunit.Sdk.ExceptionAggregator! aggregator, System.Threading.CancellationTokenSource! cancellationTokenSource) -> System.Threading.Tasks.Task! +override Xunit.Sdk.UITestCase.Serialize(Xunit.Abstractions.IXunitSerializationInfo! data) -> void +override Xunit.Sdk.UITheoryDiscoverer.CreateTestCasesForDataRow(Xunit.Abstractions.ITestFrameworkDiscoveryOptions! discoveryOptions, Xunit.Abstractions.ITestMethod! testMethod, Xunit.Abstractions.IAttributeInfo! theoryAttribute, object![]! dataRow) -> System.Collections.Generic.IEnumerable! +override Xunit.Sdk.UITheoryDiscoverer.CreateTestCasesForTheory(Xunit.Abstractions.ITestFrameworkDiscoveryOptions! discoveryOptions, Xunit.Abstractions.ITestMethod! testMethod, Xunit.Abstractions.IAttributeInfo! theoryAttribute) -> System.Collections.Generic.IEnumerable! +override Xunit.Sdk.UITheoryTestCase.Deserialize(Xunit.Abstractions.IXunitSerializationInfo! data) -> void +override Xunit.Sdk.UITheoryTestCase.RunAsync(Xunit.Abstractions.IMessageSink! diagnosticMessageSink, Xunit.Sdk.IMessageBus! messageBus, object![]! constructorArguments, Xunit.Sdk.ExceptionAggregator! aggregator, System.Threading.CancellationTokenSource! cancellationTokenSource) -> System.Threading.Tasks.Task! +override Xunit.Sdk.UITheoryTestCase.Serialize(Xunit.Abstractions.IXunitSerializationInfo! data) -> void +Xunit.CocoaFactAttribute +Xunit.CocoaFactAttribute.CocoaFactAttribute() -> void +Xunit.CocoaTheoryAttribute +Xunit.CocoaTheoryAttribute.CocoaTheoryAttribute() -> void +Xunit.Sdk.CocoaFactDiscoverer +Xunit.Sdk.CocoaFactDiscoverer.CocoaFactDiscoverer(Xunit.Abstractions.IMessageSink! diagnosticMessageSink) -> void +Xunit.Sdk.CocoaTheoryDiscoverer +Xunit.Sdk.CocoaTheoryDiscoverer.CocoaTheoryDiscoverer(Xunit.Abstractions.IMessageSink! diagnosticMessageSink) -> void +Xunit.Sdk.StaFactDiscoverer +Xunit.Sdk.StaFactDiscoverer.StaFactDiscoverer(Xunit.Abstractions.IMessageSink! diagnosticMessageSink) -> void +Xunit.Sdk.StaTheoryDiscoverer +Xunit.Sdk.StaTheoryDiscoverer.StaTheoryDiscoverer(Xunit.Abstractions.IMessageSink! diagnosticMessageSink) -> void +Xunit.Sdk.UIFactDiscoverer +Xunit.Sdk.UIFactDiscoverer.UIFactDiscoverer(Xunit.Abstractions.IMessageSink! diagnosticMessageSink) -> void +Xunit.Sdk.UITestCase +Xunit.Sdk.UITestCase.SyncContextType +Xunit.Sdk.UITestCase.SyncContextType.Cocoa = 2 -> Xunit.Sdk.UITestCase.SyncContextType +Xunit.Sdk.UITestCase.SyncContextType.None = 0 -> Xunit.Sdk.UITestCase.SyncContextType +Xunit.Sdk.UITestCase.SyncContextType.Portable = 1 -> Xunit.Sdk.UITestCase.SyncContextType +Xunit.Sdk.UITestCase.UITestCase() -> void +Xunit.Sdk.UITestCase.UITestCase(Xunit.Sdk.UITestCase.SyncContextType synchronizationContextType, Xunit.Abstractions.IMessageSink! diagnosticMessageSink, Xunit.Sdk.TestMethodDisplay defaultMethodDisplay, Xunit.Abstractions.ITestMethod! testMethod, object?[]? testMethodArguments = null) -> void +Xunit.Sdk.UITestCaseRunner +Xunit.Sdk.UITestInvoker +Xunit.Sdk.UITestInvoker.RunAsync() -> System.Threading.Tasks.Task! +Xunit.Sdk.UITestRunner +Xunit.Sdk.UITheoryDiscoverer +Xunit.Sdk.UITheoryDiscoverer.UITheoryDiscoverer(Xunit.Abstractions.IMessageSink! diagnosticMessageSink) -> void +Xunit.Sdk.UITheoryTestCase +Xunit.Sdk.UITheoryTestCase.UITheoryTestCase() -> void +Xunit.Sdk.UITheoryTestCase.UITheoryTestCase(Xunit.Sdk.UITestCase.SyncContextType synchronizationContextType, Xunit.Abstractions.IMessageSink! diagnosticMessageSink, Xunit.Sdk.TestMethodDisplay defaultMethodDisplay, Xunit.Sdk.TestMethodDisplayOptions defaultMethodDisplayOptions, Xunit.Abstractions.ITestMethod! testMethod) -> void +Xunit.Sdk.UITheoryTestCaseRunner +Xunit.StaFactAttribute +Xunit.StaFactAttribute.StaFactAttribute() -> void +Xunit.StaTheoryAttribute +Xunit.StaTheoryAttribute.StaTheoryAttribute() -> void +Xunit.UIFactAttribute +Xunit.UIFactAttribute.UIFactAttribute() -> void +Xunit.UITheoryAttribute +Xunit.UITheoryAttribute.UITheoryAttribute() -> void From a7cc92c8616c6904da5fe94e5777b93fea832fec Mon Sep 17 00:00:00 2001 From: Sandy Armstrong Date: Wed, 18 Jan 2023 13:25:08 -0800 Subject: [PATCH 17/92] Address a few extraneous warnings --- .../Xunit.StaFact.Tests.Mac.csproj | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj b/test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj index ba6da0ab..d19d2ae7 100644 --- a/test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj +++ b/test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj @@ -16,7 +16,7 @@ - + @@ -25,4 +25,14 @@ + + + + + + + From 57276710592ed8eb33019b3f58d1f764c1d7f7ee Mon Sep 17 00:00:00 2001 From: Sandy Armstrong Date: Wed, 18 Jan 2023 13:49:19 -0800 Subject: [PATCH 18/92] Only build Xunit.StaFact.Tests.Mac in *Mac configurations --- Xunit.StaFact.sln | 18 +++++++++++++++--- azure-pipelines/build.yml | 2 ++ 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/Xunit.StaFact.sln b/Xunit.StaFact.sln index 80131053..c83e7997 100644 --- a/Xunit.StaFact.sln +++ b/Xunit.StaFact.sln @@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 17 VisualStudioVersion = 17.0.31314.41 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Xunit.StaFact", "src\Xunit.StaFact\Xunit.StaFact.csproj", "{8C500C20-0CD6-4257-A9ED-C571DA6E68D6}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Xunit.StaFact", "src\Xunit.StaFact\Xunit.StaFact.csproj", "{8C500C20-0CD6-4257-A9ED-C571DA6E68D6}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{3DC2EEF3-BA28-4C7A-B4F4-FCA18FBABE99}" ProjectSection(SolutionItems) = preProject @@ -41,20 +41,32 @@ Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU Release|Any CPU = Release|Any CPU + DebugMac|Any CPU = DebugMac|Any CPU + ReleaseMac|Any CPU = ReleaseMac|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {8C500C20-0CD6-4257-A9ED-C571DA6E68D6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {8C500C20-0CD6-4257-A9ED-C571DA6E68D6}.Debug|Any CPU.Build.0 = Debug|Any CPU {8C500C20-0CD6-4257-A9ED-C571DA6E68D6}.Release|Any CPU.ActiveCfg = Release|Any CPU {8C500C20-0CD6-4257-A9ED-C571DA6E68D6}.Release|Any CPU.Build.0 = Release|Any CPU + {8C500C20-0CD6-4257-A9ED-C571DA6E68D6}.DebugMac|Any CPU.ActiveCfg = Debug|Any CPU + {8C500C20-0CD6-4257-A9ED-C571DA6E68D6}.DebugMac|Any CPU.Build.0 = Debug|Any CPU + {8C500C20-0CD6-4257-A9ED-C571DA6E68D6}.ReleaseMac|Any CPU.ActiveCfg = Release|Any CPU + {8C500C20-0CD6-4257-A9ED-C571DA6E68D6}.ReleaseMac|Any CPU.Build.0 = Release|Any CPU {9F99EC1E-7FF7-419D-84F7-3CE96D653C2E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {9F99EC1E-7FF7-419D-84F7-3CE96D653C2E}.Debug|Any CPU.Build.0 = Debug|Any CPU {9F99EC1E-7FF7-419D-84F7-3CE96D653C2E}.Release|Any CPU.ActiveCfg = Release|Any CPU {9F99EC1E-7FF7-419D-84F7-3CE96D653C2E}.Release|Any CPU.Build.0 = Release|Any CPU + {9F99EC1E-7FF7-419D-84F7-3CE96D653C2E}.DebugMac|Any CPU.ActiveCfg = Debug|Any CPU + {9F99EC1E-7FF7-419D-84F7-3CE96D653C2E}.DebugMac|Any CPU.Build.0 = Debug|Any CPU + {9F99EC1E-7FF7-419D-84F7-3CE96D653C2E}.ReleaseMac|Any CPU.ActiveCfg = Release|Any CPU + {9F99EC1E-7FF7-419D-84F7-3CE96D653C2E}.ReleaseMac|Any CPU.Build.0 = Release|Any CPU {077DFB77-0E63-4399-BD0B-4F9D9AC80495}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {077DFB77-0E63-4399-BD0B-4F9D9AC80495}.Debug|Any CPU.Build.0 = Debug|Any CPU {077DFB77-0E63-4399-BD0B-4F9D9AC80495}.Release|Any CPU.ActiveCfg = Release|Any CPU - {077DFB77-0E63-4399-BD0B-4F9D9AC80495}.Release|Any CPU.Build.0 = Release|Any CPU + {077DFB77-0E63-4399-BD0B-4F9D9AC80495}.DebugMac|Any CPU.ActiveCfg = Debug|Any CPU + {077DFB77-0E63-4399-BD0B-4F9D9AC80495}.DebugMac|Any CPU.Build.0 = Debug|Any CPU + {077DFB77-0E63-4399-BD0B-4F9D9AC80495}.ReleaseMac|Any CPU.ActiveCfg = Release|Any CPU + {077DFB77-0E63-4399-BD0B-4F9D9AC80495}.ReleaseMac|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/azure-pipelines/build.yml b/azure-pipelines/build.yml index 56169012..e7cc6988 100644 --- a/azure-pipelines/build.yml +++ b/azure-pipelines/build.yml @@ -38,6 +38,8 @@ jobs: - job: macOS condition: ${{ parameters.includeMacOS }} + variables: + BuildConfiguration: ReleaseMac pool: vmImage: macOS-12 steps: From 3cf676c878c59f548eb52f557fef44027561b152 Mon Sep 17 00:00:00 2001 From: Sandy Armstrong Date: Wed, 18 Jan 2023 14:12:44 -0800 Subject: [PATCH 19/92] Pass configuration when restoring on Mac --- init.ps1 | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/init.ps1 b/init.ps1 index 6d3a30b3..1d08ef64 100755 --- a/init.ps1 +++ b/init.ps1 @@ -79,7 +79,10 @@ try { if (!$NoRestore -and $PSCmdlet.ShouldProcess("NuGet packages", "Restore")) { Write-Host "Restoring NuGet packages" -ForegroundColor $HeaderColor - dotnet restore + if ($IsMacOS) { + $restoreArgs = "/p:Configuration=DebugMac" + } + dotnet restore $restoreArgs if ($lastexitcode -ne 0) { throw "Failure while restoring packages." } From b13aa1d2828bfcf86c81ce9495205147e7c35fed Mon Sep 17 00:00:00 2001 From: Sandy Armstrong Date: Wed, 18 Jan 2023 15:20:50 -0800 Subject: [PATCH 20/92] Basic workload-from-rollback provisioning This allows building on macOS 12 and easily consuming the nupkg from projects still using older workload versions. --- init.ps1 | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/init.ps1 b/init.ps1 index 1d08ef64..01a03e21 100755 --- a/init.ps1 +++ b/init.ps1 @@ -66,7 +66,18 @@ if (!$NoPrerequisites) { $EnvVars['PROCDUMP_PATH'] = & "$PSScriptRoot\azure-pipelines\Get-ProcDump.ps1" } - dotnet workload install macos + # Install specific macOS workload version in order to support usage on older .NET and macOS + $rollbackFile = Join-Path ([System.IO.Path]::GetTempPath()) ([System.Guid]::NewGuid()) + @{ + "microsoft.net.sdk.macos" = "12.3.2372/7.0.100" + } | ConvertTo-Json | Set-Content -Path $rollbackFile + + try { + dotnet workload install macos --from-rollback-file $rollbackFile + } + finally { + Remove-Item $rollbackFile + } } # Workaround nuget credential provider bug that causes very unreliable package restores on Azure Pipelines From 153f2ec4873cb432bff1b8a769bfb25066a3dc9f Mon Sep 17 00:00:00 2001 From: Sandy Armstrong Date: Wed, 18 Jan 2023 15:30:26 -0800 Subject: [PATCH 21/92] Move Xunit.StaFact.Tests.Mac to .NET 6 --- test/Xunit.StaFact.Tests.Mac/AppDelegate.cs | 6 +++--- test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/test/Xunit.StaFact.Tests.Mac/AppDelegate.cs b/test/Xunit.StaFact.Tests.Mac/AppDelegate.cs index 7c04be57..77ae938a 100644 --- a/test/Xunit.StaFact.Tests.Mac/AppDelegate.cs +++ b/test/Xunit.StaFact.Tests.Mac/AppDelegate.cs @@ -6,7 +6,7 @@ namespace Xunit.StaFact.Tests.Mac; [Register("AppDelegate")] -public partial class AppDelegate : NSApplicationDelegate +public class AppDelegate : NSApplicationDelegate { public override void DidFinishLaunching(NSNotification notification) => ThreadPool.QueueUserWorkItem( @@ -18,8 +18,8 @@ public override void DidFinishLaunching(NSNotification notification) "denied", }))); - [LibraryImport(ObjCRuntime.Constants.libcLibrary)] + [DllImport(ObjCRuntime.Constants.libcLibrary)] #pragma warning disable SA1300 // Element should begin with upper-case letter - private static partial void _exit(int exitCode); + private static extern void _exit(int exitCode); #pragma warning restore SA1300 // Element should begin with upper-case letter } diff --git a/test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj b/test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj index d19d2ae7..91c8c6af 100644 --- a/test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj +++ b/test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj @@ -1,6 +1,6 @@ - net7.0-macos + net6.0-macos Exe enable true From cf8b3a6fe0b35c29b1a16b2d8aa9712288317919 Mon Sep 17 00:00:00 2001 From: Sandy Armstrong Date: Wed, 18 Jan 2023 15:44:47 -0800 Subject: [PATCH 22/92] Do not build for Mac on Linux --- src/Xunit.StaFact/Xunit.StaFact.csproj | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Xunit.StaFact/Xunit.StaFact.csproj b/src/Xunit.StaFact/Xunit.StaFact.csproj index 823e9552..cc9375ba 100644 --- a/src/Xunit.StaFact/Xunit.StaFact.csproj +++ b/src/Xunit.StaFact/Xunit.StaFact.csproj @@ -1,6 +1,7 @@  - net472;netstandard2.0;net6.0;net6.0-windows;net6.0-macos10.15 + net472;netstandard2.0;net6.0;net6.0-windows + $(TargetFrameworks);net6.0-macos10.15 Xunit Run your xunit-based tests on an STA thread with the WPF Dispatcher, a WinForms SynchronizationContext, or even a cross-platform generic UI thread emulation with a SynchronizationContext that keeps code running on a "main thread" for that test. From 565faf6f3512f7ea66dac71b5e4b9e97b10c57f8 Mon Sep 17 00:00:00 2001 From: Sandy Armstrong Date: Wed, 18 Jan 2023 16:06:37 -0800 Subject: [PATCH 23/92] Minor fixes --- Directory.Build.props | 2 +- global.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Directory.Build.props b/Directory.Build.props index f7c277db..17232cc4 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -14,7 +14,7 @@ true true true - true + true true diff --git a/global.json b/global.json index e5187f36..cc08211e 100644 --- a/global.json +++ b/global.json @@ -1,6 +1,6 @@ { "sdk": { - "version": "7.0.100", + "version": "7.0.101", "rollForward": "patch", "allowPrerelease": false } From 13063f2cab1702bd9a35e370a142de4b5dcda928 Mon Sep 17 00:00:00 2001 From: Siyu Mao Date: Thu, 19 Jan 2023 13:51:24 -0800 Subject: [PATCH 24/92] Testing new added TargetPath --- .../Xunit.StaFact.Tests.Mac.csproj | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj b/test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj index 91c8c6af..047345eb 100644 --- a/test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj +++ b/test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj @@ -18,6 +18,14 @@ + + $(MSBuildThisFileDirectory)..\..bin + + Microsoft.VisualStudio.Platform.VSEditor.Interop + $(RootNamespace).DesignTime + $(CustomOutDir)\$(AssemblyName).dll + + <_AppExePath>$(MSBuildThisFileDirectory)..\..\bin\Xunit.StaFact.Tests.Mac\$(Configuration)\$(TargetFramework)\Xunit.StaFact.Tests.Mac.app\Contents\MacOS\Xunit.StaFact.Tests.Mac From c2531a3b083ed4628f2515dd7f1d56ec37978a3b Mon Sep 17 00:00:00 2001 From: Sandy Armstrong Date: Thu, 19 Jan 2023 14:48:12 -0800 Subject: [PATCH 25/92] Fix Mac files not showing up in VSMac solution pad --- src/Xunit.StaFact/Xunit.StaFact.csproj | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Xunit.StaFact/Xunit.StaFact.csproj b/src/Xunit.StaFact/Xunit.StaFact.csproj index cc9375ba..0d788046 100644 --- a/src/Xunit.StaFact/Xunit.StaFact.csproj +++ b/src/Xunit.StaFact/Xunit.StaFact.csproj @@ -1,7 +1,10 @@  - net472;netstandard2.0;net6.0;net6.0-windows - $(TargetFrameworks);net6.0-macos10.15 + + net6.0-macos10.15 + $(TargetFrameworks);net472;netstandard2.0;net6.0;net6.0-windows Xunit Run your xunit-based tests on an STA thread with the WPF Dispatcher, a WinForms SynchronizationContext, or even a cross-platform generic UI thread emulation with a SynchronizationContext that keeps code running on a "main thread" for that test. From 3d32350f67b9c8de2b47bbdc82c7649a919a821a Mon Sep 17 00:00:00 2001 From: Siyu Mao Date: Thu, 19 Jan 2023 16:07:54 -0800 Subject: [PATCH 26/92] Modify TargetPath more. --- test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj b/test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj index 047345eb..1379d8f6 100644 --- a/test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj +++ b/test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj @@ -19,10 +19,10 @@ - $(MSBuildThisFileDirectory)..\..bin + bin\Xunit.StaFact.Tests.Mac\Release\net6.0-macos\os-x64 - Microsoft.VisualStudio.Platform.VSEditor.Interop - $(RootNamespace).DesignTime + Xunit.StaFact.Tests.Mac + $(RootNamespace) $(CustomOutDir)\$(AssemblyName).dll From d03833ab2423620b8d37d3aea1e27bfa4b325eb8 Mon Sep 17 00:00:00 2001 From: Siyu Mao Date: Thu, 19 Jan 2023 16:25:37 -0800 Subject: [PATCH 27/92] Make another change to test TargetPath --- test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj b/test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj index 1379d8f6..ee4fa99d 100644 --- a/test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj +++ b/test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj @@ -19,7 +19,7 @@ - bin\Xunit.StaFact.Tests.Mac\Release\net6.0-macos\os-x64 + \Users\runner\work\1\s\bin\Xunit.StaFact.Tests.Mac\Release\net6.0-macos\os-x64 Xunit.StaFact.Tests.Mac $(RootNamespace) From 3871190f1984cdad28cb0dc5b2dc4026aa494d63 Mon Sep 17 00:00:00 2001 From: Sandy Armstrong Date: Fri, 20 Jan 2023 08:46:35 -0800 Subject: [PATCH 28/92] Trying to get macos build working on Linux --- src/Xunit.StaFact/Xunit.StaFact.csproj | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Xunit.StaFact/Xunit.StaFact.csproj b/src/Xunit.StaFact/Xunit.StaFact.csproj index 0d788046..bedb4a5e 100644 --- a/src/Xunit.StaFact/Xunit.StaFact.csproj +++ b/src/Xunit.StaFact/Xunit.StaFact.csproj @@ -1,10 +1,10 @@  - + net6.0-macos10.15;net472;netstandard2.0;net6.0;net6.0-windows + - net6.0-macos10.15 - $(TargetFrameworks);net472;netstandard2.0;net6.0;net6.0-windows + $([MSBuild]::IsOSPlatform('macOS')) Xunit Run your xunit-based tests on an STA thread with the WPF Dispatcher, a WinForms SynchronizationContext, or even a cross-platform generic UI thread emulation with a SynchronizationContext that keeps code running on a "main thread" for that test. From 715bbfc131ecb061523897658f6a9b42e41e7f4f Mon Sep 17 00:00:00 2001 From: Sandy Armstrong Date: Fri, 20 Jan 2023 08:53:53 -0800 Subject: [PATCH 29/92] Revert "Trying to get macos build working on Linux" This reverts commit 3871190f1984cdad28cb0dc5b2dc4026aa494d63. --- src/Xunit.StaFact/Xunit.StaFact.csproj | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Xunit.StaFact/Xunit.StaFact.csproj b/src/Xunit.StaFact/Xunit.StaFact.csproj index bedb4a5e..0d788046 100644 --- a/src/Xunit.StaFact/Xunit.StaFact.csproj +++ b/src/Xunit.StaFact/Xunit.StaFact.csproj @@ -1,10 +1,10 @@  - - net6.0-macos10.15;net472;netstandard2.0;net6.0;net6.0-windows - - $([MSBuild]::IsOSPlatform('macOS')) + net6.0-macos10.15 + $(TargetFrameworks);net472;netstandard2.0;net6.0;net6.0-windows Xunit Run your xunit-based tests on an STA thread with the WPF Dispatcher, a WinForms SynchronizationContext, or even a cross-platform generic UI thread emulation with a SynchronizationContext that keeps code running on a "main thread" for that test. From 4eb7a713114a8d2aa3d976d690dcdc26d9afd2b3 Mon Sep 17 00:00:00 2001 From: Siyu Mao Date: Tue, 24 Jan 2023 09:12:38 -0800 Subject: [PATCH 30/92] Tests the CocoaFact unit tests in the DevOps Pipeline --- Xunit.StaFact.sln | 4 ++-- .../Xunit.StaFact.Tests.Mac.csproj | 17 +++++++---------- 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/Xunit.StaFact.sln b/Xunit.StaFact.sln index c83e7997..4b8495f1 100644 --- a/Xunit.StaFact.sln +++ b/Xunit.StaFact.sln @@ -21,6 +21,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Xunit.StaFact.Tests", "test\Xunit.StaFact.Tests\Xunit.StaFact.Tests.csproj", "{9F99EC1E-7FF7-419D-84F7-3CE96D653C2E}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Xunit.StaFact.Tests.Mac", "test\Xunit.StaFact.Tests.Mac\Xunit.StaFact.Tests.Mac.csproj", "{077DFB77-0E63-4399-BD0B-4F9D9AC80495}" +EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{B9635B8C-19E8-4D04-ACA4-A391D558D80A}" ProjectSection(SolutionItems) = preProject src\.editorconfig = src\.editorconfig @@ -35,8 +37,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{1E94DC16-5 test\Directory.Build.targets = test\Directory.Build.targets EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Xunit.StaFact.Tests.Mac", "test\Xunit.StaFact.Tests.Mac\Xunit.StaFact.Tests.Mac.csproj", "{077DFB77-0E63-4399-BD0B-4F9D9AC80495}" -EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU diff --git a/test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj b/test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj index ee4fa99d..296b6fca 100644 --- a/test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj +++ b/test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj @@ -6,6 +6,7 @@ true 10.15 true + true @@ -18,22 +19,18 @@ - - \Users\runner\work\1\s\bin\Xunit.StaFact.Tests.Mac\Release\net6.0-macos\os-x64 - - Xunit.StaFact.Tests.Mac - $(RootNamespace) - $(CustomOutDir)\$(AssemblyName).dll - - - + - <_AppExePath>$(MSBuildThisFileDirectory)..\..\bin\Xunit.StaFact.Tests.Mac\$(Configuration)\$(TargetFramework)\Xunit.StaFact.Tests.Mac.app\Contents\MacOS\Xunit.StaFact.Tests.Mac + <_AppExePath>$(MSBuildThisFileDirectory)..\..\bin\Xunit.StaFact.Tests.Mac\$(Configuration)\$(TargetFramework)\osx-x64\Xunit.StaFact.Tests.Mac.app\Contents\MacOS\Xunit.StaFact.Tests.Mac + + + + From bdb092f1d84e8051ab9ea0f3b2a0939466f63b84 Mon Sep 17 00:00:00 2001 From: Siyu Mao Date: Tue, 24 Jan 2023 09:32:32 -0800 Subject: [PATCH 31/92] Replace TargetPath with another path --- test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj b/test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj index 296b6fca..2388dbc7 100644 --- a/test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj +++ b/test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj @@ -21,10 +21,11 @@ - <_AppExePath>$(MSBuildThisFileDirectory)..\..\bin\Xunit.StaFact.Tests.Mac\$(Configuration)\$(TargetFramework)\osx-x64\Xunit.StaFact.Tests.Mac.app\Contents\MacOS\Xunit.StaFact.Tests.Mac + <_PartalAppExePath>$(MSBuildThisFileDirectory)..\..\bin\Xunit.StaFact.Tests.Mac\$(Configuration)\$(TargetFramework)\osx-x64 + <_AppExePath>$(_PartalAppExePath)\Xunit.StaFact.Tests.Mac.app\Contents\MacOS\Xunit.StaFact.Tests.Mac - + From f4f07b82f891a29e4c512184de3cb49a8c99fd8d Mon Sep 17 00:00:00 2001 From: Siyu Mao Date: Tue, 24 Jan 2023 11:12:00 -0800 Subject: [PATCH 32/92] Testing --- Xunit.StaFact.sln | 2 -- test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj | 4 ---- 2 files changed, 6 deletions(-) diff --git a/Xunit.StaFact.sln b/Xunit.StaFact.sln index 4b8495f1..1d2a0ed8 100644 --- a/Xunit.StaFact.sln +++ b/Xunit.StaFact.sln @@ -61,8 +61,6 @@ Global {9F99EC1E-7FF7-419D-84F7-3CE96D653C2E}.DebugMac|Any CPU.Build.0 = Debug|Any CPU {9F99EC1E-7FF7-419D-84F7-3CE96D653C2E}.ReleaseMac|Any CPU.ActiveCfg = Release|Any CPU {9F99EC1E-7FF7-419D-84F7-3CE96D653C2E}.ReleaseMac|Any CPU.Build.0 = Release|Any CPU - {077DFB77-0E63-4399-BD0B-4F9D9AC80495}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {077DFB77-0E63-4399-BD0B-4F9D9AC80495}.Release|Any CPU.ActiveCfg = Release|Any CPU {077DFB77-0E63-4399-BD0B-4F9D9AC80495}.DebugMac|Any CPU.ActiveCfg = Debug|Any CPU {077DFB77-0E63-4399-BD0B-4F9D9AC80495}.DebugMac|Any CPU.Build.0 = Debug|Any CPU {077DFB77-0E63-4399-BD0B-4F9D9AC80495}.ReleaseMac|Any CPU.ActiveCfg = Release|Any CPU diff --git a/test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj b/test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj index 2388dbc7..9edcd914 100644 --- a/test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj +++ b/test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj @@ -28,10 +28,6 @@ - - - - From f0817053eba7d8b7145f53da2d825e9e6ebc7437 Mon Sep 17 00:00:00 2001 From: Siyu Mao Date: Tue, 24 Jan 2023 12:56:06 -0800 Subject: [PATCH 33/92] Edit TargetPath --- Xunit.StaFact.sln | 2 ++ .../Xunit.StaFact.Tests.Mac.csproj | 10 +++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/Xunit.StaFact.sln b/Xunit.StaFact.sln index 1d2a0ed8..4b8495f1 100644 --- a/Xunit.StaFact.sln +++ b/Xunit.StaFact.sln @@ -61,6 +61,8 @@ Global {9F99EC1E-7FF7-419D-84F7-3CE96D653C2E}.DebugMac|Any CPU.Build.0 = Debug|Any CPU {9F99EC1E-7FF7-419D-84F7-3CE96D653C2E}.ReleaseMac|Any CPU.ActiveCfg = Release|Any CPU {9F99EC1E-7FF7-419D-84F7-3CE96D653C2E}.ReleaseMac|Any CPU.Build.0 = Release|Any CPU + {077DFB77-0E63-4399-BD0B-4F9D9AC80495}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {077DFB77-0E63-4399-BD0B-4F9D9AC80495}.Release|Any CPU.ActiveCfg = Release|Any CPU {077DFB77-0E63-4399-BD0B-4F9D9AC80495}.DebugMac|Any CPU.ActiveCfg = Debug|Any CPU {077DFB77-0E63-4399-BD0B-4F9D9AC80495}.DebugMac|Any CPU.Build.0 = Debug|Any CPU {077DFB77-0E63-4399-BD0B-4F9D9AC80495}.ReleaseMac|Any CPU.ActiveCfg = Release|Any CPU diff --git a/test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj b/test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj index 9edcd914..6fcec955 100644 --- a/test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj +++ b/test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj @@ -19,13 +19,17 @@ + + $(MSBuildThisFileDirectory)..\..\bin\Xunit.StaFact.Tests.Mac\$(Configuration)\$(TargetFramework)\osx-x64 + $(PartialTargetPath)\$(TargetName).dll + + - <_PartalAppExePath>$(MSBuildThisFileDirectory)..\..\bin\Xunit.StaFact.Tests.Mac\$(Configuration)\$(TargetFramework)\osx-x64 - <_AppExePath>$(_PartalAppExePath)\Xunit.StaFact.Tests.Mac.app\Contents\MacOS\Xunit.StaFact.Tests.Mac + <_AppExePath>$(PartialTargetPath)\Xunit.StaFact.Tests.Mac.app\Contents\MacOS\Xunit.StaFact.Tests.Mac - + From d5f36c7f063120dba2ead45a3b33322f7f0203c8 Mon Sep 17 00:00:00 2001 From: Siyu Mao Date: Tue, 24 Jan 2023 13:05:22 -0800 Subject: [PATCH 34/92] Change the TargetFramework for MacOS --- azure-pipelines/dotnet-test-cloud.ps1 | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/azure-pipelines/dotnet-test-cloud.ps1 b/azure-pipelines/dotnet-test-cloud.ps1 index b5a8a54e..295d4c18 100644 --- a/azure-pipelines/dotnet-test-cloud.ps1 +++ b/azure-pipelines/dotnet-test-cloud.ps1 @@ -45,10 +45,15 @@ if ($x86) { } $frameworks = @() -if ($IsMacOS -or $IsLinux) { +if ($IsLinux) { $frameworks += '-f','net6.0' } +$frameworks = @() +if ($IsMacOS -or) { + $frameworks += '-f','net6.0-macos' +} + & $dotnet test $RepoRoot ` --no-build ` -c $Configuration ` From 8110c72ec0aa3cc1c0ee3e1fd029c0229408b763 Mon Sep 17 00:00:00 2001 From: Siyu Mao Date: Tue, 24 Jan 2023 13:06:42 -0800 Subject: [PATCH 35/92] .yml file clean up --- azure-pipelines/dotnet-test-cloud.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines/dotnet-test-cloud.ps1 b/azure-pipelines/dotnet-test-cloud.ps1 index 295d4c18..bfe9c641 100644 --- a/azure-pipelines/dotnet-test-cloud.ps1 +++ b/azure-pipelines/dotnet-test-cloud.ps1 @@ -50,7 +50,7 @@ if ($IsLinux) { } $frameworks = @() -if ($IsMacOS -or) { +if ($IsMacOS) { $frameworks += '-f','net6.0-macos' } From 8a3a3b61c46b93ad3492acd13dda2262304e4587 Mon Sep 17 00:00:00 2001 From: Siyu Mao Date: Tue, 24 Jan 2023 13:22:25 -0800 Subject: [PATCH 36/92] Another attempt for running CocoaFact unit tests --- azure-pipelines/dotnet-test-cloud.ps1 | 2 -- test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/azure-pipelines/dotnet-test-cloud.ps1 b/azure-pipelines/dotnet-test-cloud.ps1 index bfe9c641..9715c79e 100644 --- a/azure-pipelines/dotnet-test-cloud.ps1 +++ b/azure-pipelines/dotnet-test-cloud.ps1 @@ -48,8 +48,6 @@ $frameworks = @() if ($IsLinux) { $frameworks += '-f','net6.0' } - -$frameworks = @() if ($IsMacOS) { $frameworks += '-f','net6.0-macos' } diff --git a/test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj b/test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj index 6fcec955..d537c479 100644 --- a/test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj +++ b/test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj @@ -21,7 +21,7 @@ $(MSBuildThisFileDirectory)..\..\bin\Xunit.StaFact.Tests.Mac\$(Configuration)\$(TargetFramework)\osx-x64 - $(PartialTargetPath)\$(TargetName).dll + $(PartialTargetPath)\Xunit.StaFact.Tests.Mac.dll From 8e75d0c06b06369403ecccc3b48b9f5dde459e6d Mon Sep 17 00:00:00 2001 From: Siyu Mao Date: Tue, 24 Jan 2023 14:02:57 -0800 Subject: [PATCH 37/92] Another modification for the TargetPath --- test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj b/test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj index d537c479..c07eebb0 100644 --- a/test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj +++ b/test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj @@ -20,7 +20,7 @@ - $(MSBuildThisFileDirectory)..\..\bin\Xunit.StaFact.Tests.Mac\$(Configuration)\$(TargetFramework)\osx-x64 + $(RepoRootPath)\bin\Xunit.StaFact.Tests.Mac\$(Configuration)\$(TargetFramework)\osx-x64 $(PartialTargetPath)\Xunit.StaFact.Tests.Mac.dll @@ -32,6 +32,10 @@ + + From 30036b3cc3203d270f465408d384100d3a029ca4 Mon Sep 17 00:00:00 2001 From: Siyu Mao Date: Tue, 24 Jan 2023 14:18:30 -0800 Subject: [PATCH 38/92] Fix Dotnet Test System.IO.FileNotFoundException --- test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj b/test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj index c07eebb0..cc65d98c 100644 --- a/test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj +++ b/test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj @@ -7,6 +7,8 @@ 10.15 true true + false + true From 696daacf1dfb664b10c713aaa3430095f364298c Mon Sep 17 00:00:00 2001 From: Siyu Mao Date: Tue, 24 Jan 2023 14:46:37 -0800 Subject: [PATCH 39/92] Fix libhostpolicy.dylib is not found issue --- test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj | 1 + 1 file changed, 1 insertion(+) diff --git a/test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj b/test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj index cc65d98c..1a112d99 100644 --- a/test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj +++ b/test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj @@ -9,6 +9,7 @@ true false true + true From bb80ec5daa08c2721492abe82db388f65f545861 Mon Sep 17 00:00:00 2001 From: Siyu Mao Date: Tue, 24 Jan 2023 15:13:22 -0800 Subject: [PATCH 40/92] Adding RuntimeIdentifier to solve libhostpolicy.dylib can't be found --- test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj | 1 + 1 file changed, 1 insertion(+) diff --git a/test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj b/test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj index 1a112d99..8faa7d2e 100644 --- a/test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj +++ b/test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj @@ -7,6 +7,7 @@ 10.15 true true + osx-x64 false true true From 09fe7b4a1c154a8014bfbe0c8a351d39bbdb7127 Mon Sep 17 00:00:00 2001 From: Siyu Mao Date: Tue, 24 Jan 2023 17:36:03 -0800 Subject: [PATCH 41/92] Testing if the test can find libhostpolicy.dylib --- .../Xunit.StaFact.Tests.Mac.csproj | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj b/test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj index 8faa7d2e..b662b886 100644 --- a/test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj +++ b/test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj @@ -7,7 +7,7 @@ 10.15 true true - osx-x64 + osx-x64 false true true @@ -22,6 +22,13 @@ + + + $(PartialTargetPath) + true + + $(RepoRootPath)\bin\Xunit.StaFact.Tests.Mac\$(Configuration)\$(TargetFramework)\osx-x64 From 1de23a6a10de00f56b6f177e63b3c3227a428c2a Mon Sep 17 00:00:00 2001 From: Siyu Mao Date: Tue, 24 Jan 2023 18:06:43 -0800 Subject: [PATCH 42/92] Replace RuntimeIdentifiers with RuntimeIdentifier --- .../Xunit.StaFact.Tests.Mac.csproj | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj b/test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj index b662b886..74c3ee25 100644 --- a/test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj +++ b/test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj @@ -7,7 +7,7 @@ 10.15 true true - osx-x64 + osx-x64 false true true @@ -24,7 +24,7 @@ + Include="$(libPath)"> $(PartialTargetPath) true @@ -33,6 +33,7 @@ $(RepoRootPath)\bin\Xunit.StaFact.Tests.Mac\$(Configuration)\$(TargetFramework)\osx-x64 $(PartialTargetPath)\Xunit.StaFact.Tests.Mac.dll + /Users/siyumao/Xunit.StaFact//bin/Xunit.StaFact.Tests.Mac/Debug/net6.0-macos\osx-x64\Xunit.StaFact.Tests.Mac.app\Contents\MonoBundle\libhostpolicy.dylib @@ -43,9 +44,9 @@ - + + + From 643e8bf7c2d6dbf4e779ab2ece3711d5d2c75458 Mon Sep 17 00:00:00 2001 From: Siyu Mao Date: Tue, 24 Jan 2023 18:11:26 -0800 Subject: [PATCH 43/92] Code clean up --- .../Xunit.StaFact.Tests.Mac.csproj | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj b/test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj index 74c3ee25..aebdd4e3 100644 --- a/test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj +++ b/test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj @@ -24,7 +24,7 @@ + Include="$(RepoRootPath)\bin\Xunit.StaFact.Tests.Mac\$(Configuration)\$(TargetFramework)\osx-x64\Xunit.StaFact.Tests.Mac.app\Contents\MonoBundle\libhostpolicy.dylib"> $(PartialTargetPath) true @@ -33,7 +33,6 @@ $(RepoRootPath)\bin\Xunit.StaFact.Tests.Mac\$(Configuration)\$(TargetFramework)\osx-x64 $(PartialTargetPath)\Xunit.StaFact.Tests.Mac.dll - /Users/siyumao/Xunit.StaFact//bin/Xunit.StaFact.Tests.Mac/Debug/net6.0-macos\osx-x64\Xunit.StaFact.Tests.Mac.app\Contents\MonoBundle\libhostpolicy.dylib @@ -44,9 +43,9 @@ - - - + From 7c62d1b04d00f25342e65fdacb7a702d994ef3bc Mon Sep 17 00:00:00 2001 From: Siyu Mao Date: Tue, 24 Jan 2023 18:13:17 -0800 Subject: [PATCH 44/92] Use RuntimeIdentifer instead of RuntimeIdentifiers --- test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj b/test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj index aebdd4e3..b662b886 100644 --- a/test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj +++ b/test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj @@ -7,7 +7,7 @@ 10.15 true true - osx-x64 + osx-x64 false true true From 676ed175259fa2de1a0494eab5328cdc9e08258a Mon Sep 17 00:00:00 2001 From: Siyu Mao Date: Thu, 26 Jan 2023 10:12:33 -0800 Subject: [PATCH 45/92] Testing the build pipeline for the new step --- azure-pipelines/dotnet.yml | 9 +++- test/Xunit.StaFact.Tests.Mac/AppDelegate.cs | 43 +++++++++++++++---- .../Xunit.StaFact.Tests.Mac.csproj | 11 +++-- 3 files changed, 50 insertions(+), 13 deletions(-) diff --git a/azure-pipelines/dotnet.yml b/azure-pipelines/dotnet.yml index 79babd4d..4a5c628d 100644 --- a/azure-pipelines/dotnet.yml +++ b/azure-pipelines/dotnet.yml @@ -6,9 +6,16 @@ steps: - script: dotnet build -t:build,pack --no-restore -c $(BuildConfiguration) /bl:"$(Build.ArtifactStagingDirectory)/build_logs/build.binlog" displayName: 🛠 dotnet build +# We might also need to try to make this command not run the Mac unit tests - powershell: azure-pipelines/dotnet-test-cloud.ps1 -Configuration $(BuildConfiguration) -Agent $(Agent.JobName) -PublishResults displayName: 🧪 dotnet test - condition: and(succeeded(), ${{ parameters.RunTests }}) + condition: and(succeeded(), ${{ parameters.RunTests }}), !eq(variables['BuildConfiguration'], 'ReleaseMac')) + +- script: + # Somehow get the Artifact Staging Directory + dotnet build $(RepoRootPath)/test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj /t:Test /bl:"$(RepoArtifactsPath)/build_logs/build.binlog" #pass in the artifact stagng directory, so we can output the results in xml + displayName: 🧪 Mac-specific tests + Condition: eq(variables['BuildConfiguration'], 'ReleaseMac') - powershell: azure-pipelines/variables/_pipelines.ps1 failOnStderr: true diff --git a/test/Xunit.StaFact.Tests.Mac/AppDelegate.cs b/test/Xunit.StaFact.Tests.Mac/AppDelegate.cs index 77ae938a..9eb2f638 100644 --- a/test/Xunit.StaFact.Tests.Mac/AppDelegate.cs +++ b/test/Xunit.StaFact.Tests.Mac/AppDelegate.cs @@ -8,15 +8,42 @@ namespace Xunit.StaFact.Tests.Mac; [Register("AppDelegate")] public class AppDelegate : NSApplicationDelegate { + readonly List unitTestDriverArguments = new List(); + + public AppDelegate() + { + var args = NSProcessInfo.ProcessInfo.Arguments; + for (int i = 1; i < args.Length; i++) + { + var arg = args[i]; + + unitTestDriverArguments.Add(arg); + } + } public override void DidFinishLaunching(NSNotification notification) - => ThreadPool.QueueUserWorkItem( - o => _exit( - Xunit.ConsoleClient.Program.Main(new[] - { - typeof(AppDelegate).Assembly.Location, - "-appdomains", - "denied", - }))); + { + // if we've been given at least one non-help argument, append + // disable AppDomain support since we need all tests to run + // in the main app domain to be able to run on or dispatch to + // the main thread. + var thisAssemblyLocation = typeof(AppDelegate).Assembly.Location; + unitTestDriverArguments.Add(thisAssemblyLocation); + unitTestDriverArguments.Add("-appdomains"); + unitTestDriverArguments.Add("denied"); + + // We also cannot run tests in parallel since our tests depend + // on ordered execution on the main thread. + unitTestDriverArguments.Add("-parallel"); + unitTestDriverArguments.Add("none"); + + var args = unitTestDriverArguments.ToArray(); + + ThreadPool.QueueUserWorkItem(o => + { + var exitCode = Xunit.ConsoleClient.Program.Main(args); + _exit(exitCode); + }); + } [DllImport(ObjCRuntime.Constants.libcLibrary)] #pragma warning disable SA1300 // Element should begin with upper-case letter diff --git a/test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj b/test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj index b662b886..07adbab2 100644 --- a/test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj +++ b/test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj @@ -33,6 +33,9 @@ $(RepoRootPath)\bin\Xunit.StaFact.Tests.Mac\$(Configuration)\$(TargetFramework)\osx-x64 $(PartialTargetPath)\Xunit.StaFact.Tests.Mac.dll + $(BUILD_ARTIFACTSTAGINGDIRECTORY) + $([MSBuild]::EnsureTrailingSlash('$(AzureDevOpsArtifactsStagingDirectory)')) + $(RepoRoot)_artifacts\ @@ -40,12 +43,12 @@ <_AppExePath>$(PartialTargetPath)\Xunit.StaFact.Tests.Mac.app\Contents\MacOS\Xunit.StaFact.Tests.Mac - + - + + + From 9f0cb714f75fa2b18822055fe35762f2c61f16e1 Mon Sep 17 00:00:00 2001 From: Siyu Mao Date: Thu, 26 Jan 2023 10:20:52 -0800 Subject: [PATCH 46/92] Testing pipeline test build --- azure-pipelines/dotnet.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines/dotnet.yml b/azure-pipelines/dotnet.yml index 4a5c628d..71a3d06f 100644 --- a/azure-pipelines/dotnet.yml +++ b/azure-pipelines/dotnet.yml @@ -9,7 +9,7 @@ steps: # We might also need to try to make this command not run the Mac unit tests - powershell: azure-pipelines/dotnet-test-cloud.ps1 -Configuration $(BuildConfiguration) -Agent $(Agent.JobName) -PublishResults displayName: 🧪 dotnet test - condition: and(succeeded(), ${{ parameters.RunTests }}), !eq(variables['BuildConfiguration'], 'ReleaseMac')) + condition: and(succeeded(), ${{ parameters.RunTests }}) - script: # Somehow get the Artifact Staging Directory From 90dae75e72a25310e7e75e63f1f7e2279b39fa96 Mon Sep 17 00:00:00 2001 From: Siyu Mao Date: Thu, 26 Jan 2023 10:22:38 -0800 Subject: [PATCH 47/92] Test if the dotnet.yml stopped the pipeline run --- azure-pipelines/dotnet.yml | 7 ------- 1 file changed, 7 deletions(-) diff --git a/azure-pipelines/dotnet.yml b/azure-pipelines/dotnet.yml index 71a3d06f..79babd4d 100644 --- a/azure-pipelines/dotnet.yml +++ b/azure-pipelines/dotnet.yml @@ -6,17 +6,10 @@ steps: - script: dotnet build -t:build,pack --no-restore -c $(BuildConfiguration) /bl:"$(Build.ArtifactStagingDirectory)/build_logs/build.binlog" displayName: 🛠 dotnet build -# We might also need to try to make this command not run the Mac unit tests - powershell: azure-pipelines/dotnet-test-cloud.ps1 -Configuration $(BuildConfiguration) -Agent $(Agent.JobName) -PublishResults displayName: 🧪 dotnet test condition: and(succeeded(), ${{ parameters.RunTests }}) -- script: - # Somehow get the Artifact Staging Directory - dotnet build $(RepoRootPath)/test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj /t:Test /bl:"$(RepoArtifactsPath)/build_logs/build.binlog" #pass in the artifact stagng directory, so we can output the results in xml - displayName: 🧪 Mac-specific tests - Condition: eq(variables['BuildConfiguration'], 'ReleaseMac') - - powershell: azure-pipelines/variables/_pipelines.ps1 failOnStderr: true displayName: ⚙ Update pipeline variables based on build outputs From 05460dbab963abced8e5a6a7092a379d87e7572a Mon Sep 17 00:00:00 2001 From: Siyu Mao Date: Thu, 26 Jan 2023 10:31:53 -0800 Subject: [PATCH 48/92] Modified dotnet.yml --- azure-pipelines/dotnet.yml | 5 +++++ test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/azure-pipelines/dotnet.yml b/azure-pipelines/dotnet.yml index 79babd4d..91422553 100644 --- a/azure-pipelines/dotnet.yml +++ b/azure-pipelines/dotnet.yml @@ -10,6 +10,11 @@ steps: displayName: 🧪 dotnet test condition: and(succeeded(), ${{ parameters.RunTests }}) +- script: + dotnet build $(RepoRootPath)/test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj /t:Test + displayName: 🧪 Mac-specific tests + Condition: eq(variables['BuildConfiguration'], 'ReleaseMac') + - powershell: azure-pipelines/variables/_pipelines.ps1 failOnStderr: true displayName: ⚙ Update pipeline variables based on build outputs diff --git a/test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj b/test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj index 07adbab2..753da101 100644 --- a/test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj +++ b/test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj @@ -47,7 +47,7 @@ - + From 36b599c7e14c8c4a974d3eaa4030c003b5ff2017 Mon Sep 17 00:00:00 2001 From: Siyu Mao Date: Thu, 26 Jan 2023 10:49:16 -0800 Subject: [PATCH 49/92] Fixed AppDelegate.cs --- azure-pipelines/dotnet.yml | 2 +- test/Xunit.StaFact.Tests.Mac/AppDelegate.cs | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/azure-pipelines/dotnet.yml b/azure-pipelines/dotnet.yml index 91422553..0bea196f 100644 --- a/azure-pipelines/dotnet.yml +++ b/azure-pipelines/dotnet.yml @@ -11,7 +11,7 @@ steps: condition: and(succeeded(), ${{ parameters.RunTests }}) - script: - dotnet build $(RepoRootPath)/test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj /t:Test + dotnet build $(RepoRootPath)/test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj -t:Test displayName: 🧪 Mac-specific tests Condition: eq(variables['BuildConfiguration'], 'ReleaseMac') diff --git a/test/Xunit.StaFact.Tests.Mac/AppDelegate.cs b/test/Xunit.StaFact.Tests.Mac/AppDelegate.cs index 9eb2f638..51b9dbd8 100644 --- a/test/Xunit.StaFact.Tests.Mac/AppDelegate.cs +++ b/test/Xunit.StaFact.Tests.Mac/AppDelegate.cs @@ -16,6 +16,8 @@ public AppDelegate() for (int i = 1; i < args.Length; i++) { var arg = args[i]; + if(arg == "xunit") + continue; unitTestDriverArguments.Add(arg); } From 6dcf89f7014f4c32feb7ef4c3d916537aae3d01f Mon Sep 17 00:00:00 2001 From: Siyu Mao Date: Thu, 26 Jan 2023 13:35:30 -0800 Subject: [PATCH 50/92] Modify the Pipeline build steps --- azure-pipelines/dotnet.yml | 3 ++- .../Xunit.StaFact.Tests.Mac.csproj | 8 ++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/azure-pipelines/dotnet.yml b/azure-pipelines/dotnet.yml index 0bea196f..3f1fb4a4 100644 --- a/azure-pipelines/dotnet.yml +++ b/azure-pipelines/dotnet.yml @@ -9,9 +9,10 @@ steps: - powershell: azure-pipelines/dotnet-test-cloud.ps1 -Configuration $(BuildConfiguration) -Agent $(Agent.JobName) -PublishResults displayName: 🧪 dotnet test condition: and(succeeded(), ${{ parameters.RunTests }}) + # condition: and(and(succeeded(), ${{ parameters.RunTests }}), !eq(variables['BuildConfiguration'], 'ReleaseMac')) - script: - dotnet build $(RepoRootPath)/test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj -t:Test + dotnet build $(RepoRootPath)/test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj -t:Test -bl:"$ArtifactStagingFolder/build_logs/test.binlog" --diag "$ArtifactStagingFolder/test_logs/diag.log;TraceLevel=info" displayName: 🧪 Mac-specific tests Condition: eq(variables['BuildConfiguration'], 'ReleaseMac') diff --git a/test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj b/test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj index 753da101..06ac6382 100644 --- a/test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj +++ b/test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj @@ -35,7 +35,7 @@ $(PartialTargetPath)\Xunit.StaFact.Tests.Mac.dll $(BUILD_ARTIFACTSTAGINGDIRECTORY) $([MSBuild]::EnsureTrailingSlash('$(AzureDevOpsArtifactsStagingDirectory)')) - $(RepoRoot)_artifacts\ + $(RepoRootPath)\bin\Xunit.StaFact.Tests.Mac\$(Configuration)\$(TargetFramework)\osx-x64 @@ -43,11 +43,11 @@ <_AppExePath>$(PartialTargetPath)\Xunit.StaFact.Tests.Mac.app\Contents\MacOS\Xunit.StaFact.Tests.Mac - - + + - + From 30d506accf848bdc0ca2c829f994184cc6fa83f4 Mon Sep 17 00:00:00 2001 From: Siyu Mao Date: Thu, 26 Jan 2023 13:52:21 -0800 Subject: [PATCH 51/92] Create a powerShell script for Mac unit tests --- azure-pipelines/dotnet-test-mac-cloud.ps1 | 91 +++++++++++++++++++ azure-pipelines/dotnet.yml | 5 +- .../Xunit.StaFact.Tests.Mac.csproj | 2 +- 3 files changed, 95 insertions(+), 3 deletions(-) create mode 100644 azure-pipelines/dotnet-test-mac-cloud.ps1 diff --git a/azure-pipelines/dotnet-test-mac-cloud.ps1 b/azure-pipelines/dotnet-test-mac-cloud.ps1 new file mode 100644 index 00000000..8c31b7f1 --- /dev/null +++ b/azure-pipelines/dotnet-test-mac-cloud.ps1 @@ -0,0 +1,91 @@ +#!/usr/bin/env pwsh + +<# +.SYNOPSIS + Runs tests as they are run in cloud test runs. +.PARAMETER Configuration + The configuration within which to run tests +.PARAMETER Agent + The name of the agent. This is used in preparing test run titles. +.PARAMETER PublishResults + A switch to publish results to Azure Pipelines. +.PARAMETER x86 + A switch to run the tests in an x86 process. +.PARAMETER dotnet32 + The path to a 32-bit dotnet executable to use. +#> +[CmdletBinding()] +Param( + [string]$Configuration='Debug', + [string]$Agent='Local', + [switch]$PublishResults, + [switch]$x86, + [string]$dotnet32 +) + +$RepoRoot = (Resolve-Path "$PSScriptRoot/..").Path +$ArtifactStagingFolder = & "$PSScriptRoot/Get-ArtifactsStagingDirectory.ps1" + +$dotnet = 'dotnet' +if ($x86) { + $x86RunTitleSuffix = ", x86" + if ($dotnet32) { + $dotnet = $dotnet32 + } else { + $dotnet32Possibilities = "$PSScriptRoot\../obj/tools/x86/.dotnet/dotnet.exe", "$env:AGENT_TOOLSDIRECTORY/x86/dotnet/dotnet.exe", "${env:ProgramFiles(x86)}\dotnet\dotnet.exe" + $dotnet32Matches = $dotnet32Possibilities |? { Test-Path $_ } + if ($dotnet32Matches) { + $dotnet = Resolve-Path @($dotnet32Matches)[0] + Write-Host "Running tests using `"$dotnet`"" -ForegroundColor DarkGray + } else { + Write-Error "Unable to find 32-bit dotnet.exe" + return 1 + } + } +} + +$frameworks = @() +if ($IsLinux) { + $frameworks += '-f','net6.0' +} +if ($IsMacOS) { + $frameworks += '-f','net6.0-macos' +} + +& $dotnet build "$RepoRoot/test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj" /t:Test` + -c $Configuration ` + --filter "TestCategory!=FailsInCloudTest & TestCategory!=FailureExpected" ` + --collect "Code Coverage;Format=cobertura" ` + --settings "$PSScriptRoot/test.runsettings" ` + --blame-hang-timeout 60s ` + --blame-crash ` + -bl:"$ArtifactStagingFolder/build_logs/test.binlog" ` + --diag "$ArtifactStagingFolder/test_logs/diag.log;TraceLevel=info" ` + --logger trx ` + @frameworks ` + +$unknownCounter = 0 +Get-ChildItem -Recurse -Path $RepoRoot\test\*.trx |% { + Copy-Item $_ -Destination $ArtifactStagingFolder/test_logs/ + + if ($PublishResults) { + $x = [xml](Get-Content -Path $_) + $runTitle = $null + if ($x.TestRun.TestDefinitions -and $x.TestRun.TestDefinitions.GetElementsByTagName('UnitTest')) { + $storage = $x.TestRun.TestDefinitions.GetElementsByTagName('UnitTest')[0].storage -replace '\\','/' + if ($storage -match '/(?net[^/]+)/(?:(?[^/]+)/)?(?[^/]+)\.dll$') { + if ($matches.rid) { + $runTitle = "$($matches.lib) ($($matches.tfm), $($matches.rid), $Agent)" + } else { + $runTitle = "$($matches.lib) ($($matches.tfm)$x86RunTitleSuffix, $Agent)" + } + } + } + if (!$runTitle) { + $unknownCounter += 1; + $runTitle = "unknown$unknownCounter ($Agent$x86RunTitleSuffix)"; + } + + Write-Host "##vso[results.publish type=VSTest;runTitle=$runTitle;publishRunAttachments=true;resultFiles=$_;failTaskOnFailedTests=true;testRunSystem=VSTS - PTR;]" + } +} diff --git a/azure-pipelines/dotnet.yml b/azure-pipelines/dotnet.yml index 3f1fb4a4..13e2f661 100644 --- a/azure-pipelines/dotnet.yml +++ b/azure-pipelines/dotnet.yml @@ -11,8 +11,9 @@ steps: condition: and(succeeded(), ${{ parameters.RunTests }}) # condition: and(and(succeeded(), ${{ parameters.RunTests }}), !eq(variables['BuildConfiguration'], 'ReleaseMac')) -- script: - dotnet build $(RepoRootPath)/test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj -t:Test -bl:"$ArtifactStagingFolder/build_logs/test.binlog" --diag "$ArtifactStagingFolder/test_logs/diag.log;TraceLevel=info" +- powershell: azure-pipelines/dotnet-test-mac-cloud.ps1 -Configuration $(BuildConfiguration) -Agent $(Agent.JobName) -PublishResults + script: + dotnet build $(RepoRoot)/test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj -t:Test -bl:"$ArtifactStagingFolder/build_logs/test.binlog" --diag "$ArtifactStagingFolder/test_logs/diag.log;TraceLevel=info" displayName: 🧪 Mac-specific tests Condition: eq(variables['BuildConfiguration'], 'ReleaseMac') diff --git a/test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj b/test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj index 06ac6382..e7de815e 100644 --- a/test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj +++ b/test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj @@ -47,7 +47,7 @@ - + From 41570f868bf1ea9e30d37a526003904874ce5cfa Mon Sep 17 00:00:00 2001 From: Siyu Mao Date: Fri, 27 Jan 2023 08:02:59 -0800 Subject: [PATCH 52/92] Modify dotnet.yml --- azure-pipelines/dotnet.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/azure-pipelines/dotnet.yml b/azure-pipelines/dotnet.yml index 13e2f661..a6af6b81 100644 --- a/azure-pipelines/dotnet.yml +++ b/azure-pipelines/dotnet.yml @@ -12,8 +12,8 @@ steps: # condition: and(and(succeeded(), ${{ parameters.RunTests }}), !eq(variables['BuildConfiguration'], 'ReleaseMac')) - powershell: azure-pipelines/dotnet-test-mac-cloud.ps1 -Configuration $(BuildConfiguration) -Agent $(Agent.JobName) -PublishResults - script: - dotnet build $(RepoRoot)/test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj -t:Test -bl:"$ArtifactStagingFolder/build_logs/test.binlog" --diag "$ArtifactStagingFolder/test_logs/diag.log;TraceLevel=info" + # script: | + # dotnet build $(RepoRoot)/test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj -t:Test -bl:"$ArtifactStagingFolder/build_logs/test.binlog" --diag "$ArtifactStagingFolder/test_logs/diag.log;TraceLevel=info" displayName: 🧪 Mac-specific tests Condition: eq(variables['BuildConfiguration'], 'ReleaseMac') From 2a198ada7dd488cde77e837d436f11b0c5b6d8fc Mon Sep 17 00:00:00 2001 From: Siyu Mao Date: Fri, 27 Jan 2023 08:13:17 -0800 Subject: [PATCH 53/92] Second solution, run script for Mac unit test in dotnet.yml --- azure-pipelines/dotnet.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/azure-pipelines/dotnet.yml b/azure-pipelines/dotnet.yml index a6af6b81..21b82ecd 100644 --- a/azure-pipelines/dotnet.yml +++ b/azure-pipelines/dotnet.yml @@ -11,9 +11,8 @@ steps: condition: and(succeeded(), ${{ parameters.RunTests }}) # condition: and(and(succeeded(), ${{ parameters.RunTests }}), !eq(variables['BuildConfiguration'], 'ReleaseMac')) -- powershell: azure-pipelines/dotnet-test-mac-cloud.ps1 -Configuration $(BuildConfiguration) -Agent $(Agent.JobName) -PublishResults - # script: | - # dotnet build $(RepoRoot)/test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj -t:Test -bl:"$ArtifactStagingFolder/build_logs/test.binlog" --diag "$ArtifactStagingFolder/test_logs/diag.log;TraceLevel=info" +# - powershell: azure-pipelines/dotnet-test-mac-cloud.ps1 -Configuration $(BuildConfiguration) -Agent $(Agent.JobName) -PublishResults +- script: dotnet build $(RepoRoot)/test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj /t:Test -c $(BuildConfiguration) /bl:"$ArtifactStagingFolder/build_logs/test.binlog" displayName: 🧪 Mac-specific tests Condition: eq(variables['BuildConfiguration'], 'ReleaseMac') From 67c4d9214626a8b78a75f4362443521659a7ca7b Mon Sep 17 00:00:00 2001 From: Sandy Armstrong Date: Fri, 27 Jan 2023 10:49:23 -0800 Subject: [PATCH 54/92] XML test results generating locally --- test/Xunit.StaFact.Tests.Mac/AppDelegate.cs | 12 +++--------- .../Xunit.StaFact.Tests.Mac.csproj | 12 +++--------- 2 files changed, 6 insertions(+), 18 deletions(-) diff --git a/test/Xunit.StaFact.Tests.Mac/AppDelegate.cs b/test/Xunit.StaFact.Tests.Mac/AppDelegate.cs index 51b9dbd8..07f1ecdd 100644 --- a/test/Xunit.StaFact.Tests.Mac/AppDelegate.cs +++ b/test/Xunit.StaFact.Tests.Mac/AppDelegate.cs @@ -1,6 +1,7 @@ // Copyright (c) Andrew Arnott. All rights reserved. // Licensed under the Ms-PL license. See LICENSE file in the project root for full license information. + using System.Runtime.InteropServices; namespace Xunit.StaFact.Tests.Mac; @@ -15,21 +16,14 @@ public AppDelegate() var args = NSProcessInfo.ProcessInfo.Arguments; for (int i = 1; i < args.Length; i++) { - var arg = args[i]; - if(arg == "xunit") - continue; - - unitTestDriverArguments.Add(arg); + unitTestDriverArguments.Add(args[i]); } } public override void DidFinishLaunching(NSNotification notification) { - // if we've been given at least one non-help argument, append - // disable AppDomain support since we need all tests to run + // Disable AppDomain support since we need all tests to run // in the main app domain to be able to run on or dispatch to // the main thread. - var thisAssemblyLocation = typeof(AppDelegate).Assembly.Location; - unitTestDriverArguments.Add(thisAssemblyLocation); unitTestDriverArguments.Add("-appdomains"); unitTestDriverArguments.Add("denied"); diff --git a/test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj b/test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj index e7de815e..a263e289 100644 --- a/test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj +++ b/test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj @@ -7,7 +7,6 @@ 10.15 true true - osx-x64 false true true @@ -35,21 +34,16 @@ $(PartialTargetPath)\Xunit.StaFact.Tests.Mac.dll $(BUILD_ARTIFACTSTAGINGDIRECTORY) $([MSBuild]::EnsureTrailingSlash('$(AzureDevOpsArtifactsStagingDirectory)')) - $(RepoRootPath)\bin\Xunit.StaFact.Tests.Mac\$(Configuration)\$(TargetFramework)\osx-x64 + $(RepoRootPath) - + <_AppExePath>$(PartialTargetPath)\Xunit.StaFact.Tests.Mac.app\Contents\MacOS\Xunit.StaFact.Tests.Mac - - + - - - - From 621aeb1c8bc13fcce09cda8580b4bf48b4103b6f Mon Sep 17 00:00:00 2001 From: Siyu Mao Date: Fri, 27 Jan 2023 11:25:25 -0800 Subject: [PATCH 55/92] Modiy the dotnet.yml and add new task to publish the xml --- azure-pipelines/dotnet-test-mac-cloud.ps1 | 91 ----------------------- azure-pipelines/dotnet.yml | 14 +++- 2 files changed, 10 insertions(+), 95 deletions(-) delete mode 100644 azure-pipelines/dotnet-test-mac-cloud.ps1 diff --git a/azure-pipelines/dotnet-test-mac-cloud.ps1 b/azure-pipelines/dotnet-test-mac-cloud.ps1 deleted file mode 100644 index 8c31b7f1..00000000 --- a/azure-pipelines/dotnet-test-mac-cloud.ps1 +++ /dev/null @@ -1,91 +0,0 @@ -#!/usr/bin/env pwsh - -<# -.SYNOPSIS - Runs tests as they are run in cloud test runs. -.PARAMETER Configuration - The configuration within which to run tests -.PARAMETER Agent - The name of the agent. This is used in preparing test run titles. -.PARAMETER PublishResults - A switch to publish results to Azure Pipelines. -.PARAMETER x86 - A switch to run the tests in an x86 process. -.PARAMETER dotnet32 - The path to a 32-bit dotnet executable to use. -#> -[CmdletBinding()] -Param( - [string]$Configuration='Debug', - [string]$Agent='Local', - [switch]$PublishResults, - [switch]$x86, - [string]$dotnet32 -) - -$RepoRoot = (Resolve-Path "$PSScriptRoot/..").Path -$ArtifactStagingFolder = & "$PSScriptRoot/Get-ArtifactsStagingDirectory.ps1" - -$dotnet = 'dotnet' -if ($x86) { - $x86RunTitleSuffix = ", x86" - if ($dotnet32) { - $dotnet = $dotnet32 - } else { - $dotnet32Possibilities = "$PSScriptRoot\../obj/tools/x86/.dotnet/dotnet.exe", "$env:AGENT_TOOLSDIRECTORY/x86/dotnet/dotnet.exe", "${env:ProgramFiles(x86)}\dotnet\dotnet.exe" - $dotnet32Matches = $dotnet32Possibilities |? { Test-Path $_ } - if ($dotnet32Matches) { - $dotnet = Resolve-Path @($dotnet32Matches)[0] - Write-Host "Running tests using `"$dotnet`"" -ForegroundColor DarkGray - } else { - Write-Error "Unable to find 32-bit dotnet.exe" - return 1 - } - } -} - -$frameworks = @() -if ($IsLinux) { - $frameworks += '-f','net6.0' -} -if ($IsMacOS) { - $frameworks += '-f','net6.0-macos' -} - -& $dotnet build "$RepoRoot/test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj" /t:Test` - -c $Configuration ` - --filter "TestCategory!=FailsInCloudTest & TestCategory!=FailureExpected" ` - --collect "Code Coverage;Format=cobertura" ` - --settings "$PSScriptRoot/test.runsettings" ` - --blame-hang-timeout 60s ` - --blame-crash ` - -bl:"$ArtifactStagingFolder/build_logs/test.binlog" ` - --diag "$ArtifactStagingFolder/test_logs/diag.log;TraceLevel=info" ` - --logger trx ` - @frameworks ` - -$unknownCounter = 0 -Get-ChildItem -Recurse -Path $RepoRoot\test\*.trx |% { - Copy-Item $_ -Destination $ArtifactStagingFolder/test_logs/ - - if ($PublishResults) { - $x = [xml](Get-Content -Path $_) - $runTitle = $null - if ($x.TestRun.TestDefinitions -and $x.TestRun.TestDefinitions.GetElementsByTagName('UnitTest')) { - $storage = $x.TestRun.TestDefinitions.GetElementsByTagName('UnitTest')[0].storage -replace '\\','/' - if ($storage -match '/(?net[^/]+)/(?:(?[^/]+)/)?(?[^/]+)\.dll$') { - if ($matches.rid) { - $runTitle = "$($matches.lib) ($($matches.tfm), $($matches.rid), $Agent)" - } else { - $runTitle = "$($matches.lib) ($($matches.tfm)$x86RunTitleSuffix, $Agent)" - } - } - } - if (!$runTitle) { - $unknownCounter += 1; - $runTitle = "unknown$unknownCounter ($Agent$x86RunTitleSuffix)"; - } - - Write-Host "##vso[results.publish type=VSTest;runTitle=$runTitle;publishRunAttachments=true;resultFiles=$_;failTaskOnFailedTests=true;testRunSystem=VSTS - PTR;]" - } -} diff --git a/azure-pipelines/dotnet.yml b/azure-pipelines/dotnet.yml index 21b82ecd..fa9176ec 100644 --- a/azure-pipelines/dotnet.yml +++ b/azure-pipelines/dotnet.yml @@ -8,14 +8,20 @@ steps: - powershell: azure-pipelines/dotnet-test-cloud.ps1 -Configuration $(BuildConfiguration) -Agent $(Agent.JobName) -PublishResults displayName: 🧪 dotnet test - condition: and(succeeded(), ${{ parameters.RunTests }}) - # condition: and(and(succeeded(), ${{ parameters.RunTests }}), !eq(variables['BuildConfiguration'], 'ReleaseMac')) + condition: and(and(succeeded(), ${{ parameters.RunTests }}), !eq(variables['BuildConfiguration'], 'ReleaseMac')) -# - powershell: azure-pipelines/dotnet-test-mac-cloud.ps1 -Configuration $(BuildConfiguration) -Agent $(Agent.JobName) -PublishResults -- script: dotnet build $(RepoRoot)/test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj /t:Test -c $(BuildConfiguration) /bl:"$ArtifactStagingFolder/build_logs/test.binlog" +- script: dotnet build $(RepoRoot)/test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj /t:Test -c $(BuildConfiguration) displayName: 🧪 Mac-specific tests Condition: eq(variables['BuildConfiguration'], 'ReleaseMac') +- task: PublishTestResults@2 + inputs: + testResultsFormat: XUnit + testResultsFiles: $(RepoArtifactsPath)test_logs\*.xml + displayName: 'Test: Publish Results' + condition: and(succeededOrFailed(), eq(variables['BuildConfiguration'], 'ReleaseMac')) + continueOnError: true + - powershell: azure-pipelines/variables/_pipelines.ps1 failOnStderr: true displayName: ⚙ Update pipeline variables based on build outputs From b99bc9afd5c09440f5736ee84459c736be2cc2ad Mon Sep 17 00:00:00 2001 From: Siyu Mao Date: Fri, 27 Jan 2023 11:27:59 -0800 Subject: [PATCH 56/92] Clean more code in dotnet.yml. --- azure-pipelines/dotnet.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines/dotnet.yml b/azure-pipelines/dotnet.yml index fa9176ec..84bc06a9 100644 --- a/azure-pipelines/dotnet.yml +++ b/azure-pipelines/dotnet.yml @@ -10,7 +10,7 @@ steps: displayName: 🧪 dotnet test condition: and(and(succeeded(), ${{ parameters.RunTests }}), !eq(variables['BuildConfiguration'], 'ReleaseMac')) -- script: dotnet build $(RepoRoot)/test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj /t:Test -c $(BuildConfiguration) +- script: dotnet build $(RepoRoot)/test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj /t:Test displayName: 🧪 Mac-specific tests Condition: eq(variables['BuildConfiguration'], 'ReleaseMac') From aec7cf05a280d7af7b4ca7c911931ac932a4d95a Mon Sep 17 00:00:00 2001 From: Siyu Mao Date: Fri, 27 Jan 2023 13:53:17 -0800 Subject: [PATCH 57/92] Add more changes --- azure-pipelines/dotnet.yml | 16 ++++++++-------- .../Xunit.StaFact.Tests.Mac.csproj | 1 + 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/azure-pipelines/dotnet.yml b/azure-pipelines/dotnet.yml index 84bc06a9..cd8d2f75 100644 --- a/azure-pipelines/dotnet.yml +++ b/azure-pipelines/dotnet.yml @@ -10,17 +10,17 @@ steps: displayName: 🧪 dotnet test condition: and(and(succeeded(), ${{ parameters.RunTests }}), !eq(variables['BuildConfiguration'], 'ReleaseMac')) -- script: dotnet build $(RepoRoot)/test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj /t:Test +- script: dotnet build $(RepoRootPath)/test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj /t:Test displayName: 🧪 Mac-specific tests Condition: eq(variables['BuildConfiguration'], 'ReleaseMac') -- task: PublishTestResults@2 - inputs: - testResultsFormat: XUnit - testResultsFiles: $(RepoArtifactsPath)test_logs\*.xml - displayName: 'Test: Publish Results' - condition: and(succeededOrFailed(), eq(variables['BuildConfiguration'], 'ReleaseMac')) - continueOnError: true +# - task: PublishTestResults@2 +# inputs: +# testResultsFormat: XUnit +# testResultsFiles: $(RepoArtifactsPath)test_logs\*.xml +# displayName: 'Test: Publish Results' +# condition: and(succeededOrFailed(), eq(variables['BuildConfiguration'], 'ReleaseMac')) +# continueOnError: true - powershell: azure-pipelines/variables/_pipelines.ps1 failOnStderr: true diff --git a/test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj b/test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj index a263e289..65fe03c3 100644 --- a/test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj +++ b/test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj @@ -30,6 +30,7 @@ + $(RepoRootPath) $(RepoRootPath)\bin\Xunit.StaFact.Tests.Mac\$(Configuration)\$(TargetFramework)\osx-x64 $(PartialTargetPath)\Xunit.StaFact.Tests.Mac.dll $(BUILD_ARTIFACTSTAGINGDIRECTORY) From 24259348ba757cb11ffb7a3128fcf8c79cb89efd Mon Sep 17 00:00:00 2001 From: Siyu Mao Date: Fri, 27 Jan 2023 13:55:02 -0800 Subject: [PATCH 58/92] test .yml version 1 --- azure-pipelines/dotnet.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines/dotnet.yml b/azure-pipelines/dotnet.yml index cd8d2f75..03e467a9 100644 --- a/azure-pipelines/dotnet.yml +++ b/azure-pipelines/dotnet.yml @@ -10,7 +10,7 @@ steps: displayName: 🧪 dotnet test condition: and(and(succeeded(), ${{ parameters.RunTests }}), !eq(variables['BuildConfiguration'], 'ReleaseMac')) -- script: dotnet build $(RepoRootPath)/test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj /t:Test +- script: dotnet build ./test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj /t:Test displayName: 🧪 Mac-specific tests Condition: eq(variables['BuildConfiguration'], 'ReleaseMac') From 3c99e994fb0686d73a5e8433dc80f8a6b94f1fa4 Mon Sep 17 00:00:00 2001 From: Siyu Mao Date: Fri, 27 Jan 2023 13:57:47 -0800 Subject: [PATCH 59/92] test .yml Version 2 --- azure-pipelines/dotnet.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/azure-pipelines/dotnet.yml b/azure-pipelines/dotnet.yml index 03e467a9..d1d2884a 100644 --- a/azure-pipelines/dotnet.yml +++ b/azure-pipelines/dotnet.yml @@ -10,9 +10,9 @@ steps: displayName: 🧪 dotnet test condition: and(and(succeeded(), ${{ parameters.RunTests }}), !eq(variables['BuildConfiguration'], 'ReleaseMac')) -- script: dotnet build ./test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj /t:Test - displayName: 🧪 Mac-specific tests - Condition: eq(variables['BuildConfiguration'], 'ReleaseMac') +# - script: dotnet build ./test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj /t:Test +# displayName: 🧪 Mac-specific tests +# Condition: eq(variables['BuildConfiguration'], 'ReleaseMac') # - task: PublishTestResults@2 # inputs: From 95c3b1f2d1ad2deb1604357e775db4d7c90c072d Mon Sep 17 00:00:00 2001 From: Siyu Mao Date: Fri, 27 Jan 2023 13:59:00 -0800 Subject: [PATCH 60/92] Test .yml Version 3 --- azure-pipelines/dotnet.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/azure-pipelines/dotnet.yml b/azure-pipelines/dotnet.yml index d1d2884a..21d42c40 100644 --- a/azure-pipelines/dotnet.yml +++ b/azure-pipelines/dotnet.yml @@ -8,7 +8,8 @@ steps: - powershell: azure-pipelines/dotnet-test-cloud.ps1 -Configuration $(BuildConfiguration) -Agent $(Agent.JobName) -PublishResults displayName: 🧪 dotnet test - condition: and(and(succeeded(), ${{ parameters.RunTests }}), !eq(variables['BuildConfiguration'], 'ReleaseMac')) + condition: and(succeeded(), ${{ parameters.RunTests }}) +# condition: and(and(succeeded(), ${{ parameters.RunTests }}), !eq(variables['BuildConfiguration'], 'ReleaseMac')) # - script: dotnet build ./test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj /t:Test # displayName: 🧪 Mac-specific tests From a44b4c665a942dd33d6df9fdbb5d1daf4f84d954 Mon Sep 17 00:00:00 2001 From: Siyu Mao Date: Fri, 27 Jan 2023 14:03:50 -0800 Subject: [PATCH 61/92] Test .yml Version 4 --- azure-pipelines/dotnet.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/azure-pipelines/dotnet.yml b/azure-pipelines/dotnet.yml index 21d42c40..debd251c 100644 --- a/azure-pipelines/dotnet.yml +++ b/azure-pipelines/dotnet.yml @@ -8,8 +8,7 @@ steps: - powershell: azure-pipelines/dotnet-test-cloud.ps1 -Configuration $(BuildConfiguration) -Agent $(Agent.JobName) -PublishResults displayName: 🧪 dotnet test - condition: and(succeeded(), ${{ parameters.RunTests }}) -# condition: and(and(succeeded(), ${{ parameters.RunTests }}), !eq(variables['BuildConfiguration'], 'ReleaseMac')) + condition: and(and(succeeded(), ${{ parameters.RunTests }}), ne(variables['BuildConfiguration'], 'ReleaseMac')) # - script: dotnet build ./test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj /t:Test # displayName: 🧪 Mac-specific tests From b832272ddd2f5942fba19b12d7343a55efa4c865 Mon Sep 17 00:00:00 2001 From: Siyu Mao Date: Fri, 27 Jan 2023 14:12:11 -0800 Subject: [PATCH 62/92] Test .yml Version 5 --- azure-pipelines/dotnet.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/azure-pipelines/dotnet.yml b/azure-pipelines/dotnet.yml index debd251c..7f324a43 100644 --- a/azure-pipelines/dotnet.yml +++ b/azure-pipelines/dotnet.yml @@ -10,9 +10,9 @@ steps: displayName: 🧪 dotnet test condition: and(and(succeeded(), ${{ parameters.RunTests }}), ne(variables['BuildConfiguration'], 'ReleaseMac')) -# - script: dotnet build ./test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj /t:Test -# displayName: 🧪 Mac-specific tests -# Condition: eq(variables['BuildConfiguration'], 'ReleaseMac') + - script: dotnet build ./test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj /t:Test + displayName: 🧪 Mac-specific tests + Condition: eq(variables['BuildConfiguration'], 'ReleaseMac') # - task: PublishTestResults@2 # inputs: From e6db7d57cb7c4ab6606e9a085bd565c867ecf539 Mon Sep 17 00:00:00 2001 From: Siyu Mao Date: Fri, 27 Jan 2023 14:16:58 -0800 Subject: [PATCH 63/92] Test .yml Version 6 --- azure-pipelines/dotnet.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines/dotnet.yml b/azure-pipelines/dotnet.yml index 7f324a43..08286c83 100644 --- a/azure-pipelines/dotnet.yml +++ b/azure-pipelines/dotnet.yml @@ -10,7 +10,7 @@ steps: displayName: 🧪 dotnet test condition: and(and(succeeded(), ${{ parameters.RunTests }}), ne(variables['BuildConfiguration'], 'ReleaseMac')) - - script: dotnet build ./test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj /t:Test + - script: dotnet build $(RepoRootPath)/test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj /t:Test displayName: 🧪 Mac-specific tests Condition: eq(variables['BuildConfiguration'], 'ReleaseMac') From 37e2b59af4161de406fc7570d0a654bf0877a6af Mon Sep 17 00:00:00 2001 From: Siyu Mao Date: Fri, 27 Jan 2023 14:21:11 -0800 Subject: [PATCH 64/92] Test .yml Version 7 --- azure-pipelines/dotnet.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines/dotnet.yml b/azure-pipelines/dotnet.yml index 08286c83..2921e2d6 100644 --- a/azure-pipelines/dotnet.yml +++ b/azure-pipelines/dotnet.yml @@ -10,7 +10,7 @@ steps: displayName: 🧪 dotnet test condition: and(and(succeeded(), ${{ parameters.RunTests }}), ne(variables['BuildConfiguration'], 'ReleaseMac')) - - script: dotnet build $(RepoRootPath)/test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj /t:Test + - script: dotnet build $(RepoRoot)/test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj /t:Test displayName: 🧪 Mac-specific tests Condition: eq(variables['BuildConfiguration'], 'ReleaseMac') From ef65384a5f4c2d2088720de88bda1330330cda40 Mon Sep 17 00:00:00 2001 From: Siyu Mao Date: Fri, 27 Jan 2023 14:35:49 -0800 Subject: [PATCH 65/92] Test .yml Version 8 --- azure-pipelines/dotnet.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines/dotnet.yml b/azure-pipelines/dotnet.yml index 2921e2d6..8220d97d 100644 --- a/azure-pipelines/dotnet.yml +++ b/azure-pipelines/dotnet.yml @@ -10,7 +10,7 @@ steps: displayName: 🧪 dotnet test condition: and(and(succeeded(), ${{ parameters.RunTests }}), ne(variables['BuildConfiguration'], 'ReleaseMac')) - - script: dotnet build $(RepoRoot)/test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj /t:Test + - script: dotnet build $(MSBuildThisFileDirectory)/test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj /t:Test displayName: 🧪 Mac-specific tests Condition: eq(variables['BuildConfiguration'], 'ReleaseMac') From 72516acb8b3a4859cddbc3be9e50046e6d58fb7d Mon Sep 17 00:00:00 2001 From: Siyu Mao Date: Sat, 28 Jan 2023 08:47:20 -0800 Subject: [PATCH 66/92] Test .ml Version 9 --- azure-pipelines/dotnet.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/azure-pipelines/dotnet.yml b/azure-pipelines/dotnet.yml index 8220d97d..e55e471b 100644 --- a/azure-pipelines/dotnet.yml +++ b/azure-pipelines/dotnet.yml @@ -11,8 +11,8 @@ steps: condition: and(and(succeeded(), ${{ parameters.RunTests }}), ne(variables['BuildConfiguration'], 'ReleaseMac')) - script: dotnet build $(MSBuildThisFileDirectory)/test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj /t:Test - displayName: 🧪 Mac-specific tests - Condition: eq(variables['BuildConfiguration'], 'ReleaseMac') + displayName: 🧪 Mac-specific tests + condition: eq(variables['BuildConfiguration'], 'ReleaseMac') # - task: PublishTestResults@2 # inputs: From d9d14bce0cf54057f728524cbc8ba525b928f6fd Mon Sep 17 00:00:00 2001 From: Siyu Mao Date: Sat, 28 Jan 2023 08:56:30 -0800 Subject: [PATCH 67/92] Test .yml Version 10 --- azure-pipelines/dotnet.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines/dotnet.yml b/azure-pipelines/dotnet.yml index e55e471b..d97d493e 100644 --- a/azure-pipelines/dotnet.yml +++ b/azure-pipelines/dotnet.yml @@ -10,7 +10,7 @@ steps: displayName: 🧪 dotnet test condition: and(and(succeeded(), ${{ parameters.RunTests }}), ne(variables['BuildConfiguration'], 'ReleaseMac')) - - script: dotnet build $(MSBuildThisFileDirectory)/test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj /t:Test +- script: dotnet build $(MSBuildThisFileDirectory)/test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj /t:Test displayName: 🧪 Mac-specific tests condition: eq(variables['BuildConfiguration'], 'ReleaseMac') From 098c9f12924258272daed873225e01c2c3975203 Mon Sep 17 00:00:00 2001 From: Siyu Mao Date: Sat, 28 Jan 2023 09:05:33 -0800 Subject: [PATCH 68/92] Test .yml Version 11 --- azure-pipelines/dotnet.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines/dotnet.yml b/azure-pipelines/dotnet.yml index d97d493e..51cc1d1d 100644 --- a/azure-pipelines/dotnet.yml +++ b/azure-pipelines/dotnet.yml @@ -10,7 +10,7 @@ steps: displayName: 🧪 dotnet test condition: and(and(succeeded(), ${{ parameters.RunTests }}), ne(variables['BuildConfiguration'], 'ReleaseMac')) -- script: dotnet build $(MSBuildThisFileDirectory)/test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj /t:Test +- script: dotnet build $(RepoRootPath)/test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj /t:Test displayName: 🧪 Mac-specific tests condition: eq(variables['BuildConfiguration'], 'ReleaseMac') From 3efebf895fc4502799395b383ac60cfc3026cde0 Mon Sep 17 00:00:00 2001 From: Siyu Mao Date: Sat, 28 Jan 2023 09:10:24 -0800 Subject: [PATCH 69/92] Test .yml Version 12 --- azure-pipelines/dotnet.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines/dotnet.yml b/azure-pipelines/dotnet.yml index 51cc1d1d..552c3d20 100644 --- a/azure-pipelines/dotnet.yml +++ b/azure-pipelines/dotnet.yml @@ -10,7 +10,7 @@ steps: displayName: 🧪 dotnet test condition: and(and(succeeded(), ${{ parameters.RunTests }}), ne(variables['BuildConfiguration'], 'ReleaseMac')) -- script: dotnet build $(RepoRootPath)/test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj /t:Test +- script: dotnet build $(RepoRoot)/test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj /t:Test displayName: 🧪 Mac-specific tests condition: eq(variables['BuildConfiguration'], 'ReleaseMac') From 89a130dd06c383eb7a3af0b0b8fb9d9832a1226b Mon Sep 17 00:00:00 2001 From: Siyu Mao Date: Sat, 28 Jan 2023 09:18:05 -0800 Subject: [PATCH 70/92] Test .yml Version 13 --- azure-pipelines/dotnet.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines/dotnet.yml b/azure-pipelines/dotnet.yml index 552c3d20..57889092 100644 --- a/azure-pipelines/dotnet.yml +++ b/azure-pipelines/dotnet.yml @@ -10,7 +10,7 @@ steps: displayName: 🧪 dotnet test condition: and(and(succeeded(), ${{ parameters.RunTests }}), ne(variables['BuildConfiguration'], 'ReleaseMac')) -- script: dotnet build $(RepoRoot)/test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj /t:Test +- script: dotnet build ./test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj /t:Test displayName: 🧪 Mac-specific tests condition: eq(variables['BuildConfiguration'], 'ReleaseMac') From d028403466c62610f151a00cb2903c092e458b61 Mon Sep 17 00:00:00 2001 From: Siyu Mao Date: Sat, 28 Jan 2023 09:39:07 -0800 Subject: [PATCH 71/92] Test .yml Version 14 --- test/Xunit.StaFact.Tests.Mac/AppDelegate.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/Xunit.StaFact.Tests.Mac/AppDelegate.cs b/test/Xunit.StaFact.Tests.Mac/AppDelegate.cs index 07f1ecdd..82841d4d 100644 --- a/test/Xunit.StaFact.Tests.Mac/AppDelegate.cs +++ b/test/Xunit.StaFact.Tests.Mac/AppDelegate.cs @@ -1,7 +1,6 @@ // Copyright (c) Andrew Arnott. All rights reserved. // Licensed under the Ms-PL license. See LICENSE file in the project root for full license information. - using System.Runtime.InteropServices; namespace Xunit.StaFact.Tests.Mac; @@ -9,7 +8,7 @@ namespace Xunit.StaFact.Tests.Mac; [Register("AppDelegate")] public class AppDelegate : NSApplicationDelegate { - readonly List unitTestDriverArguments = new List(); + readonly private List unitTestDriverArguments = new List(); public AppDelegate() { @@ -19,6 +18,7 @@ public AppDelegate() unitTestDriverArguments.Add(args[i]); } } + public override void DidFinishLaunching(NSNotification notification) { // Disable AppDomain support since we need all tests to run From b1a399d650c355094f707c2ec7df0adec2d64d13 Mon Sep 17 00:00:00 2001 From: Siyu Mao Date: Sat, 28 Jan 2023 09:55:53 -0800 Subject: [PATCH 72/92] Test .yml Version 15 --- test/Xunit.StaFact.Tests.Mac/AppDelegate.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Xunit.StaFact.Tests.Mac/AppDelegate.cs b/test/Xunit.StaFact.Tests.Mac/AppDelegate.cs index 82841d4d..a556b566 100644 --- a/test/Xunit.StaFact.Tests.Mac/AppDelegate.cs +++ b/test/Xunit.StaFact.Tests.Mac/AppDelegate.cs @@ -8,7 +8,7 @@ namespace Xunit.StaFact.Tests.Mac; [Register("AppDelegate")] public class AppDelegate : NSApplicationDelegate { - readonly private List unitTestDriverArguments = new List(); + private readonly List unitTestDriverArguments = new List(); public AppDelegate() { From 7cf2afb9a9d9aadd6300ecfd76ec230bbdb4949d Mon Sep 17 00:00:00 2001 From: Siyu Mao Date: Mon, 30 Jan 2023 07:42:25 -0800 Subject: [PATCH 73/92] Test .yml Version 16 --- test/Xunit.StaFact.Tests.Mac/AppDelegate.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/test/Xunit.StaFact.Tests.Mac/AppDelegate.cs b/test/Xunit.StaFact.Tests.Mac/AppDelegate.cs index a556b566..8ab08124 100644 --- a/test/Xunit.StaFact.Tests.Mac/AppDelegate.cs +++ b/test/Xunit.StaFact.Tests.Mac/AppDelegate.cs @@ -15,7 +15,7 @@ public AppDelegate() var args = NSProcessInfo.ProcessInfo.Arguments; for (int i = 1; i < args.Length; i++) { - unitTestDriverArguments.Add(args[i]); + this.unitTestDriverArguments.Add(args[i]); } } @@ -24,15 +24,15 @@ public override void DidFinishLaunching(NSNotification notification) // Disable AppDomain support since we need all tests to run // in the main app domain to be able to run on or dispatch to // the main thread. - unitTestDriverArguments.Add("-appdomains"); - unitTestDriverArguments.Add("denied"); + this.unitTestDriverArguments.Add("-appdomains"); + this.unitTestDriverArguments.Add("denied"); // We also cannot run tests in parallel since our tests depend // on ordered execution on the main thread. - unitTestDriverArguments.Add("-parallel"); - unitTestDriverArguments.Add("none"); + this.unitTestDriverArguments.Add("-parallel"); + this.unitTestDriverArguments.Add("none"); - var args = unitTestDriverArguments.ToArray(); + var args = this.unitTestDriverArguments.ToArray(); ThreadPool.QueueUserWorkItem(o => { From 20e347637c9de5e00342e4b6b5bb744bc6e41d7e Mon Sep 17 00:00:00 2001 From: Siyu Mao Date: Mon, 30 Jan 2023 07:53:39 -0800 Subject: [PATCH 74/92] Test .yml Version 17 --- azure-pipelines/dotnet.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/azure-pipelines/dotnet.yml b/azure-pipelines/dotnet.yml index 57889092..83894eed 100644 --- a/azure-pipelines/dotnet.yml +++ b/azure-pipelines/dotnet.yml @@ -14,13 +14,13 @@ steps: displayName: 🧪 Mac-specific tests condition: eq(variables['BuildConfiguration'], 'ReleaseMac') -# - task: PublishTestResults@2 -# inputs: -# testResultsFormat: XUnit -# testResultsFiles: $(RepoArtifactsPath)test_logs\*.xml -# displayName: 'Test: Publish Results' -# condition: and(succeededOrFailed(), eq(variables['BuildConfiguration'], 'ReleaseMac')) -# continueOnError: true +- task: PublishTestResults@2 + inputs: + testResultsFormat: XUnit + testResultsFiles: $(RepoArtifactsPath)test_logs\*.xml + displayName: 'Test: Publish Results' + condition: and(succeededOrFailed(), eq(variables['BuildConfiguration'], 'ReleaseMac')) + continueOnError: true - powershell: azure-pipelines/variables/_pipelines.ps1 failOnStderr: true From 7f8b78913da1dea540b51689e9bd9c33121df0bc Mon Sep 17 00:00:00 2001 From: Siyu Mao Date: Mon, 30 Jan 2023 08:03:16 -0800 Subject: [PATCH 75/92] Test .yml Version 18 --- azure-pipelines/dotnet.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines/dotnet.yml b/azure-pipelines/dotnet.yml index 83894eed..da198d22 100644 --- a/azure-pipelines/dotnet.yml +++ b/azure-pipelines/dotnet.yml @@ -17,7 +17,7 @@ steps: - task: PublishTestResults@2 inputs: testResultsFormat: XUnit - testResultsFiles: $(RepoArtifactsPath)test_logs\*.xml + testResultsFiles: ./test_logs/*.xml displayName: 'Test: Publish Results' condition: and(succeededOrFailed(), eq(variables['BuildConfiguration'], 'ReleaseMac')) continueOnError: true From 7ae1504f301476c759bb89d72b6de52f65dcf6d8 Mon Sep 17 00:00:00 2001 From: Siyu Mao Date: Mon, 30 Jan 2023 08:18:33 -0800 Subject: [PATCH 76/92] Test .yml Version 19 --- azure-pipelines/dotnet.yml | 2 +- test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/azure-pipelines/dotnet.yml b/azure-pipelines/dotnet.yml index da198d22..64b0722a 100644 --- a/azure-pipelines/dotnet.yml +++ b/azure-pipelines/dotnet.yml @@ -17,7 +17,7 @@ steps: - task: PublishTestResults@2 inputs: testResultsFormat: XUnit - testResultsFiles: ./test_logs/*.xml + testResultsFiles: $(RepoArtifactsPath)test_logs/*.xml displayName: 'Test: Publish Results' condition: and(succeededOrFailed(), eq(variables['BuildConfiguration'], 'ReleaseMac')) continueOnError: true diff --git a/test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj b/test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj index 65fe03c3..6c890ff9 100644 --- a/test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj +++ b/test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj @@ -45,6 +45,10 @@ + + + + From 52180e41a2c1a34ef6b6352e12cb035b5693e5fc Mon Sep 17 00:00:00 2001 From: Siyu Mao Date: Mon, 30 Jan 2023 08:32:09 -0800 Subject: [PATCH 77/92] Test .yml Version 21 --- azure-pipelines/dotnet.yml | 2 +- test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/azure-pipelines/dotnet.yml b/azure-pipelines/dotnet.yml index 64b0722a..da198d22 100644 --- a/azure-pipelines/dotnet.yml +++ b/azure-pipelines/dotnet.yml @@ -17,7 +17,7 @@ steps: - task: PublishTestResults@2 inputs: testResultsFormat: XUnit - testResultsFiles: $(RepoArtifactsPath)test_logs/*.xml + testResultsFiles: ./test_logs/*.xml displayName: 'Test: Publish Results' condition: and(succeededOrFailed(), eq(variables['BuildConfiguration'], 'ReleaseMac')) continueOnError: true diff --git a/test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj b/test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj index 6c890ff9..9d773ead 100644 --- a/test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj +++ b/test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj @@ -42,11 +42,11 @@ <_AppExePath>$(PartialTargetPath)\Xunit.StaFact.Tests.Mac.app\Contents\MacOS\Xunit.StaFact.Tests.Mac - + - + From 9dbf6beaf6b3c2cca709ec93b180e5a6ff87ec7a Mon Sep 17 00:00:00 2001 From: Siyu Mao Date: Mon, 30 Jan 2023 08:35:43 -0800 Subject: [PATCH 78/92] Test .yml Version 22 --- test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj b/test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj index 9d773ead..b8f5de8c 100644 --- a/test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj +++ b/test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj @@ -42,7 +42,7 @@ <_AppExePath>$(PartialTargetPath)\Xunit.StaFact.Tests.Mac.app\Contents\MacOS\Xunit.StaFact.Tests.Mac - + From 1b9a72dab75977a30f96bd8a6c7fb152b7045843 Mon Sep 17 00:00:00 2001 From: Siyu Mao Date: Mon, 30 Jan 2023 08:51:55 -0800 Subject: [PATCH 79/92] Test .yml Version 23 --- azure-pipelines/dotnet.yml | 2 +- test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/azure-pipelines/dotnet.yml b/azure-pipelines/dotnet.yml index da198d22..4687573b 100644 --- a/azure-pipelines/dotnet.yml +++ b/azure-pipelines/dotnet.yml @@ -17,7 +17,7 @@ steps: - task: PublishTestResults@2 inputs: testResultsFormat: XUnit - testResultsFiles: ./test_logs/*.xml + testResultsFiles: ./test_logs/Xunit.StaFact.Tests.Mac.xml displayName: 'Test: Publish Results' condition: and(succeededOrFailed(), eq(variables['BuildConfiguration'], 'ReleaseMac')) continueOnError: true diff --git a/test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj b/test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj index b8f5de8c..54ff6490 100644 --- a/test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj +++ b/test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj @@ -46,7 +46,8 @@ - + + From aaf5ead9ceffb7fcf9d0d264c7cf3ffd36f9f682 Mon Sep 17 00:00:00 2001 From: Siyu Mao Date: Mon, 30 Jan 2023 09:17:44 -0800 Subject: [PATCH 80/92] Test .yml Version 24 --- .../Xunit.StaFact.Tests.Mac.csproj | 9 --------- 1 file changed, 9 deletions(-) diff --git a/test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj b/test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj index 54ff6490..ae9ae500 100644 --- a/test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj +++ b/test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj @@ -30,12 +30,8 @@ - $(RepoRootPath) $(RepoRootPath)\bin\Xunit.StaFact.Tests.Mac\$(Configuration)\$(TargetFramework)\osx-x64 $(PartialTargetPath)\Xunit.StaFact.Tests.Mac.dll - $(BUILD_ARTIFACTSTAGINGDIRECTORY) - $([MSBuild]::EnsureTrailingSlash('$(AzureDevOpsArtifactsStagingDirectory)')) - $(RepoRootPath) @@ -45,11 +41,6 @@ - - - - - From c6e76e70511a52c49270c08b353eb5a1fb17384d Mon Sep 17 00:00:00 2001 From: Siyu Mao Date: Mon, 30 Jan 2023 09:42:32 -0800 Subject: [PATCH 81/92] Code clean up --- azure-pipelines/dotnet.yml | 2 +- .../Xunit.StaFact.Tests.Mac.csproj | 10 ---------- 2 files changed, 1 insertion(+), 11 deletions(-) diff --git a/azure-pipelines/dotnet.yml b/azure-pipelines/dotnet.yml index 4687573b..1e3098da 100644 --- a/azure-pipelines/dotnet.yml +++ b/azure-pipelines/dotnet.yml @@ -18,7 +18,7 @@ steps: inputs: testResultsFormat: XUnit testResultsFiles: ./test_logs/Xunit.StaFact.Tests.Mac.xml - displayName: 'Test: Publish Results' + displayName: 'Publish Mac-specific tests Results' condition: and(succeededOrFailed(), eq(variables['BuildConfiguration'], 'ReleaseMac')) continueOnError: true diff --git a/test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj b/test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj index ae9ae500..f19518f2 100644 --- a/test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj +++ b/test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj @@ -7,9 +7,6 @@ 10.15 true true - false - true - true @@ -21,13 +18,6 @@ - - - $(PartialTargetPath) - true - - $(RepoRootPath)\bin\Xunit.StaFact.Tests.Mac\$(Configuration)\$(TargetFramework)\osx-x64 From d69935f19bba01450e13e6d8482a37010de21aef Mon Sep 17 00:00:00 2001 From: Siyu Mao Date: Mon, 30 Jan 2023 11:05:45 -0800 Subject: [PATCH 82/92] More code testing --- test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj b/test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj index f19518f2..cfca34fd 100644 --- a/test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj +++ b/test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj @@ -5,6 +5,7 @@ enable true 10.15 + true true @@ -20,7 +21,9 @@ - $(RepoRootPath)\bin\Xunit.StaFact.Tests.Mac\$(Configuration)\$(TargetFramework)\osx-x64 + $([System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture) + $(HostArchitecture.ToLower()) + $(RepoRootPath)\bin\Xunit.StaFact.Tests.Mac\$(Configuration)\$(TargetFramework)\osx-$(HostArchitecture) $(PartialTargetPath)\Xunit.StaFact.Tests.Mac.dll From 1321b3c287c969e95b1da9d8a59caf85b1e406a5 Mon Sep 17 00:00:00 2001 From: Siyu Mao Date: Mon, 30 Jan 2023 11:19:39 -0800 Subject: [PATCH 83/92] More clean up --- test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj | 1 - 1 file changed, 1 deletion(-) diff --git a/test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj b/test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj index cfca34fd..1c147c48 100644 --- a/test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj +++ b/test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj @@ -5,7 +5,6 @@ enable true 10.15 - true true From b62abc377791d412522632095db3f87e8564b200 Mon Sep 17 00:00:00 2001 From: Siyu Mao Date: Wed, 1 Feb 2023 08:30:43 -0800 Subject: [PATCH 84/92] Test pipeline V1 --- azure-pipelines/dotnet-test-cloud.ps1 | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/azure-pipelines/dotnet-test-cloud.ps1 b/azure-pipelines/dotnet-test-cloud.ps1 index 9715c79e..6fe59c20 100644 --- a/azure-pipelines/dotnet-test-cloud.ps1 +++ b/azure-pipelines/dotnet-test-cloud.ps1 @@ -45,12 +45,9 @@ if ($x86) { } $frameworks = @() -if ($IsLinux) { - $frameworks += '-f','net6.0' -} -if ($IsMacOS) { - $frameworks += '-f','net6.0-macos' -} + if ($IsMacOS -or $IsLinux) { + $frameworks += '-f','net6.0' + } & $dotnet test $RepoRoot ` --no-build ` From 892ca8bc228bcaa685abf762ec7caa4ffda91326 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Mon, 6 Feb 2023 08:14:14 -0700 Subject: [PATCH 85/92] Simplify the mac test project --- .../Xunit.StaFact.Tests.Mac.csproj | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj b/test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj index 1c147c48..510d4d79 100644 --- a/test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj +++ b/test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj @@ -2,11 +2,12 @@ net6.0-macos Exe - enable - true 10.15 - true true + $([System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture) + $(HostArchitecture.ToLower()) + $(RepoRootPath)\bin\Xunit.StaFact.Tests.Mac\$(Configuration)\$(TargetFramework)\osx-$(HostArchitecture) + $(PartialTargetPath)\Xunit.StaFact.Tests.Mac.dll @@ -19,13 +20,6 @@ - - $([System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture) - $(HostArchitecture.ToLower()) - $(RepoRootPath)\bin\Xunit.StaFact.Tests.Mac\$(Configuration)\$(TargetFramework)\osx-$(HostArchitecture) - $(PartialTargetPath)\Xunit.StaFact.Tests.Mac.dll - - <_AppExePath>$(PartialTargetPath)\Xunit.StaFact.Tests.Mac.app\Contents\MacOS\Xunit.StaFact.Tests.Mac From bc5256d4aab3826dd3f7f313ab5bd177ae74770a Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Mon, 6 Feb 2023 08:14:23 -0700 Subject: [PATCH 86/92] Revert some sln file changes --- Xunit.StaFact.sln | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Xunit.StaFact.sln b/Xunit.StaFact.sln index 4b8495f1..c8fbed0c 100644 --- a/Xunit.StaFact.sln +++ b/Xunit.StaFact.sln @@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 17 VisualStudioVersion = 17.0.31314.41 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Xunit.StaFact", "src\Xunit.StaFact\Xunit.StaFact.csproj", "{8C500C20-0CD6-4257-A9ED-C571DA6E68D6}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Xunit.StaFact", "src\Xunit.StaFact\Xunit.StaFact.csproj", "{8C500C20-0CD6-4257-A9ED-C571DA6E68D6}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{3DC2EEF3-BA28-4C7A-B4F4-FCA18FBABE99}" ProjectSection(SolutionItems) = preProject @@ -21,7 +21,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Xunit.StaFact.Tests", "test\Xunit.StaFact.Tests\Xunit.StaFact.Tests.csproj", "{9F99EC1E-7FF7-419D-84F7-3CE96D653C2E}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Xunit.StaFact.Tests.Mac", "test\Xunit.StaFact.Tests.Mac\Xunit.StaFact.Tests.Mac.csproj", "{077DFB77-0E63-4399-BD0B-4F9D9AC80495}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Xunit.StaFact.Tests.Mac", "test\Xunit.StaFact.Tests.Mac\Xunit.StaFact.Tests.Mac.csproj", "{077DFB77-0E63-4399-BD0B-4F9D9AC80495}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{B9635B8C-19E8-4D04-ACA4-A391D558D80A}" ProjectSection(SolutionItems) = preProject @@ -40,31 +40,31 @@ EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU DebugMac|Any CPU = DebugMac|Any CPU + Release|Any CPU = Release|Any CPU ReleaseMac|Any CPU = ReleaseMac|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {8C500C20-0CD6-4257-A9ED-C571DA6E68D6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {8C500C20-0CD6-4257-A9ED-C571DA6E68D6}.Debug|Any CPU.Build.0 = Debug|Any CPU - {8C500C20-0CD6-4257-A9ED-C571DA6E68D6}.Release|Any CPU.ActiveCfg = Release|Any CPU - {8C500C20-0CD6-4257-A9ED-C571DA6E68D6}.Release|Any CPU.Build.0 = Release|Any CPU {8C500C20-0CD6-4257-A9ED-C571DA6E68D6}.DebugMac|Any CPU.ActiveCfg = Debug|Any CPU {8C500C20-0CD6-4257-A9ED-C571DA6E68D6}.DebugMac|Any CPU.Build.0 = Debug|Any CPU + {8C500C20-0CD6-4257-A9ED-C571DA6E68D6}.Release|Any CPU.ActiveCfg = Release|Any CPU + {8C500C20-0CD6-4257-A9ED-C571DA6E68D6}.Release|Any CPU.Build.0 = Release|Any CPU {8C500C20-0CD6-4257-A9ED-C571DA6E68D6}.ReleaseMac|Any CPU.ActiveCfg = Release|Any CPU {8C500C20-0CD6-4257-A9ED-C571DA6E68D6}.ReleaseMac|Any CPU.Build.0 = Release|Any CPU {9F99EC1E-7FF7-419D-84F7-3CE96D653C2E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {9F99EC1E-7FF7-419D-84F7-3CE96D653C2E}.Debug|Any CPU.Build.0 = Debug|Any CPU - {9F99EC1E-7FF7-419D-84F7-3CE96D653C2E}.Release|Any CPU.ActiveCfg = Release|Any CPU - {9F99EC1E-7FF7-419D-84F7-3CE96D653C2E}.Release|Any CPU.Build.0 = Release|Any CPU {9F99EC1E-7FF7-419D-84F7-3CE96D653C2E}.DebugMac|Any CPU.ActiveCfg = Debug|Any CPU {9F99EC1E-7FF7-419D-84F7-3CE96D653C2E}.DebugMac|Any CPU.Build.0 = Debug|Any CPU + {9F99EC1E-7FF7-419D-84F7-3CE96D653C2E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {9F99EC1E-7FF7-419D-84F7-3CE96D653C2E}.Release|Any CPU.Build.0 = Release|Any CPU {9F99EC1E-7FF7-419D-84F7-3CE96D653C2E}.ReleaseMac|Any CPU.ActiveCfg = Release|Any CPU {9F99EC1E-7FF7-419D-84F7-3CE96D653C2E}.ReleaseMac|Any CPU.Build.0 = Release|Any CPU {077DFB77-0E63-4399-BD0B-4F9D9AC80495}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {077DFB77-0E63-4399-BD0B-4F9D9AC80495}.Release|Any CPU.ActiveCfg = Release|Any CPU {077DFB77-0E63-4399-BD0B-4F9D9AC80495}.DebugMac|Any CPU.ActiveCfg = Debug|Any CPU {077DFB77-0E63-4399-BD0B-4F9D9AC80495}.DebugMac|Any CPU.Build.0 = Debug|Any CPU + {077DFB77-0E63-4399-BD0B-4F9D9AC80495}.Release|Any CPU.ActiveCfg = Release|Any CPU {077DFB77-0E63-4399-BD0B-4F9D9AC80495}.ReleaseMac|Any CPU.ActiveCfg = Release|Any CPU {077DFB77-0E63-4399-BD0B-4F9D9AC80495}.ReleaseMac|Any CPU.Build.0 = Release|Any CPU EndGlobalSection From 8f61172120d9bd3cc34241c4253335485105e6c3 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Mon, 6 Feb 2023 08:28:24 -0700 Subject: [PATCH 87/92] revert spacing change --- azure-pipelines/dotnet-test-cloud.ps1 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/azure-pipelines/dotnet-test-cloud.ps1 b/azure-pipelines/dotnet-test-cloud.ps1 index 6fe59c20..b5a8a54e 100644 --- a/azure-pipelines/dotnet-test-cloud.ps1 +++ b/azure-pipelines/dotnet-test-cloud.ps1 @@ -45,9 +45,9 @@ if ($x86) { } $frameworks = @() - if ($IsMacOS -or $IsLinux) { - $frameworks += '-f','net6.0' - } +if ($IsMacOS -or $IsLinux) { + $frameworks += '-f','net6.0' +} & $dotnet test $RepoRoot ` --no-build ` From 4400fed613686dbe3515ce92930c2c6c26f1384a Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Mon, 6 Feb 2023 08:46:15 -0700 Subject: [PATCH 88/92] Cleanup pipeline --- azure-pipelines/build.yml | 1 + azure-pipelines/dotnet.yml | 31 +++++++++++++++++-------------- 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/azure-pipelines/build.yml b/azure-pipelines/build.yml index e7cc6988..e2da06ce 100644 --- a/azure-pipelines/build.yml +++ b/azure-pipelines/build.yml @@ -50,6 +50,7 @@ jobs: - template: dotnet.yml parameters: RunTests: ${{ parameters.RunTests }} + RunMacTests: true - job: WrapUp dependsOn: diff --git a/azure-pipelines/dotnet.yml b/azure-pipelines/dotnet.yml index 1e3098da..67c7e8d1 100644 --- a/azure-pipelines/dotnet.yml +++ b/azure-pipelines/dotnet.yml @@ -1,5 +1,8 @@ parameters: - RunTests: +- name: RunTests +- name: RunMacTests + type: boolean + default: false steps: @@ -8,19 +11,19 @@ steps: - powershell: azure-pipelines/dotnet-test-cloud.ps1 -Configuration $(BuildConfiguration) -Agent $(Agent.JobName) -PublishResults displayName: 🧪 dotnet test - condition: and(and(succeeded(), ${{ parameters.RunTests }}), ne(variables['BuildConfiguration'], 'ReleaseMac')) - -- script: dotnet build ./test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj /t:Test - displayName: 🧪 Mac-specific tests - condition: eq(variables['BuildConfiguration'], 'ReleaseMac') - -- task: PublishTestResults@2 - inputs: - testResultsFormat: XUnit - testResultsFiles: ./test_logs/Xunit.StaFact.Tests.Mac.xml - displayName: 'Publish Mac-specific tests Results' - condition: and(succeededOrFailed(), eq(variables['BuildConfiguration'], 'ReleaseMac')) - continueOnError: true + condition: and(succeeded(), ${{ parameters.RunTests }}) + +- ${{ if parameters.RunMacTests }}: + - script: dotnet build ./test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj /t:Test + displayName: 🧪 Mac-specific tests + + - task: PublishTestResults@2 + inputs: + testResultsFormat: XUnit + testResultsFiles: ./test_logs/Xunit.StaFact.Tests.Mac.xml + displayName: 📢 Publish Mac-specific tests results + condition: succeededOrFailed() + continueOnError: true - powershell: azure-pipelines/variables/_pipelines.ps1 failOnStderr: true From 795fe77f5619d53150dc859f4735888b8167233f Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Mon, 6 Feb 2023 09:11:12 -0700 Subject: [PATCH 89/92] fix pipeline --- azure-pipelines/build.yml | 2 -- azure-pipelines/dotnet.yml | 3 ++- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/azure-pipelines/build.yml b/azure-pipelines/build.yml index e2da06ce..0c86ec34 100644 --- a/azure-pipelines/build.yml +++ b/azure-pipelines/build.yml @@ -38,8 +38,6 @@ jobs: - job: macOS condition: ${{ parameters.includeMacOS }} - variables: - BuildConfiguration: ReleaseMac pool: vmImage: macOS-12 steps: diff --git a/azure-pipelines/dotnet.yml b/azure-pipelines/dotnet.yml index 67c7e8d1..ce4ff284 100644 --- a/azure-pipelines/dotnet.yml +++ b/azure-pipelines/dotnet.yml @@ -14,13 +14,14 @@ steps: condition: and(succeeded(), ${{ parameters.RunTests }}) - ${{ if parameters.RunMacTests }}: - - script: dotnet build ./test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj /t:Test + - script: dotnet build --no-restore -c $(BuildConfiguration) ./test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj /t:Test displayName: 🧪 Mac-specific tests - task: PublishTestResults@2 inputs: testResultsFormat: XUnit testResultsFiles: ./test_logs/Xunit.StaFact.Tests.Mac.xml + testRunTitle: Xunit.StaFact.Tests.Mac (net6.0-macos, MacOS) displayName: 📢 Publish Mac-specific tests results condition: succeededOrFailed() continueOnError: true From f9e66fcf083dc62ea67ec8d3e44a58d34db93957 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Mon, 6 Feb 2023 09:18:29 -0700 Subject: [PATCH 90/92] Avoid double-build on mac --- azure-pipelines/dotnet.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines/dotnet.yml b/azure-pipelines/dotnet.yml index ce4ff284..9e283b6d 100644 --- a/azure-pipelines/dotnet.yml +++ b/azure-pipelines/dotnet.yml @@ -14,7 +14,7 @@ steps: condition: and(succeeded(), ${{ parameters.RunTests }}) - ${{ if parameters.RunMacTests }}: - - script: dotnet build --no-restore -c $(BuildConfiguration) ./test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj /t:Test + - script: dotnet build --no-restore -c $(BuildConfiguration) ./test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj -t:Test -p:BuildProjectReferences=false displayName: 🧪 Mac-specific tests - task: PublishTestResults@2 From 6a47cddc62f787e604c7ec7f581f8199354b7b64 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Mon, 6 Feb 2023 10:30:34 -0700 Subject: [PATCH 91/92] Use checked in workloads.json file --- init.ps1 | 12 +----------- workloads.json | 3 +++ 2 files changed, 4 insertions(+), 11 deletions(-) create mode 100644 workloads.json diff --git a/init.ps1 b/init.ps1 index 01a03e21..2bb7fb94 100755 --- a/init.ps1 +++ b/init.ps1 @@ -67,17 +67,7 @@ if (!$NoPrerequisites) { } # Install specific macOS workload version in order to support usage on older .NET and macOS - $rollbackFile = Join-Path ([System.IO.Path]::GetTempPath()) ([System.Guid]::NewGuid()) - @{ - "microsoft.net.sdk.macos" = "12.3.2372/7.0.100" - } | ConvertTo-Json | Set-Content -Path $rollbackFile - - try { - dotnet workload install macos --from-rollback-file $rollbackFile - } - finally { - Remove-Item $rollbackFile - } + dotnet workload install macos --from-rollback-file $PSScriptRoot/workloads.json } # Workaround nuget credential provider bug that causes very unreliable package restores on Azure Pipelines diff --git a/workloads.json b/workloads.json new file mode 100644 index 00000000..1a354fb5 --- /dev/null +++ b/workloads.json @@ -0,0 +1,3 @@ +{ + "microsoft.net.sdk.macos": "12.3.2372/7.0.100" +} From c04316acc156409b636972fe6dd27c123e8f52ff Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Mon, 6 Feb 2023 11:08:24 -0700 Subject: [PATCH 92/92] Add notes to CONTRIBUTING about requirement to run --- CONTRIBUTING.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 0893b308..e9a82c73 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -33,6 +33,9 @@ The easiest way to restore packages may be to run `init.ps1` which automatically to the feeds that packages for this repo come from, if any. `dotnet restore` or `nuget restore` also work but may require extra steps to authenticate to any applicable feeds. +MacOS specific code that was added in #68 requires that `init.ps1` be run in the repo within a terminal *and devenv.exe must be spawned from that same window* in order for Visual Studio for Windows to be able to find the required macos workload. +Note that `init.ps1 -InstallLocality machine` in broken due to dotnet workloads problems such as https://github.com/dotnet/sdk/issues/30230. + ## Building Building, testing, and packing this repository can be done by using the standard dotnet CLI commands (e.g. `dotnet build`, `dotnet test`, `dotnet pack`, etc.).