-
Notifications
You must be signed in to change notification settings - Fork 33
Add cocoa fact attribute and related unit tests #68
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 83 commits
b026c64
d7718fa
9516e6d
8fbeb9a
e996a5c
897247b
53bf326
fca1e86
0d636e2
68e2e49
04de106
0bdc567
2ca5096
b621858
0695648
77e6854
a7cc92c
5727671
3cf676c
b13aa1d
153f2ec
cf8b3a6
565faf6
13063f2
c2531a3
3d32350
d03833a
3871190
715bbfc
4eb7a71
bdb092f
f4f07b8
f081705
d5f36c7
8110c72
8a3a3b6
8e75d0c
30036b3
696daac
bb80ec5
09fe7b4
1de23a6
643e8bf
7c62d1b
676ed17
9f0cb71
90dae75
05460db
36b599c
6dcf89f
30d506a
41570f8
2a198ad
67c4d92
621aeb1
b99bc9a
aec7cf0
2425934
3c99e99
95c3b1f
a44b4c6
b832272
e6db7d5
37e2b59
ef65384
72516ac
d9d14bc
098c9f1
3efebf8
89a130d
d028403
b1a399d
7cf2afb
20e3476
7f8b789
7ae1504
52180e4
9dbf6be
1b9a72d
aaf5ead
c6e76e7
d69935f
1321b3c
b62abc3
892ca8b
bc5256d
8f61172
4400fed
795fe77
f9e66fc
6a47cdd
c04316a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -349,3 +349,6 @@ MigrationBackup/ | |
|
|
||
| # dotnet tool local install directory | ||
| .store/ | ||
|
|
||
| # File built by MacOS | ||
| .DS_Store | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -65,6 +65,19 @@ if (!$NoPrerequisites) { | |
| if ($env:OS -eq 'Windows_NT') { | ||
| $EnvVars['PROCDUMP_PATH'] = & "$PSScriptRoot\azure-pipelines\Get-ProcDump.ps1" | ||
| } | ||
|
|
||
| # 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" | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you explain to me more about this requirement? Does this mean that
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The macOS workload is necessary in order to target The .NET SDK makes it difficult to specify a preferred version of a given workload. You have to use a rollback file to achieve this. Without specifying the version, the SDK will pull the latest for the SDK version specified in
Yes.
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks. That's helpful, and I've upvoted that issue.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Notice it's picking 13.1.1024, which is a different version. It's newer, and I don't see it in nuget. If you have multiple SDK versions installed, and you're running
On Mac, when installing workloads to the machine-wide .NET SDK installation (
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I do have the 7.0.200 installed, as of this morning when a VS update installed it. But all my dotnet workload install attempts were within the directory containing global.json, so evidently my repo's 7.0.101 constraint wasn't effective at retaining behavior from that SDK in this regard. Windows doesn't need The failures I'm seeing turn out to come from a collection of bugs in the SDK around this area. The do not show up when DOTNET_ROOT is set, which is why it works in non-elevated scenarios. |
||
| } | 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 | ||
|
|
@@ -77,7 +90,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." | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| // 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.Sdk; | ||
|
|
||
| namespace Xunit; | ||
|
|
||
| /// <summary> | ||
| /// Identifies an xunit test that starts on with a <see cref="System.Threading.SynchronizationContext"/> | ||
| /// running on <see cref="Foundation.NSRunLoop.Main"/>. | ||
| /// </summary> | ||
| [AttributeUsage(AttributeTargets.Method, AllowMultiple = false)] | ||
| [XunitTestCaseDiscoverer("Xunit.Sdk.CocoaFactDiscoverer", ThisAssembly.AssemblyName)] | ||
| public class CocoaFactAttribute : FactAttribute | ||
| { | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| // 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.Sdk; | ||
|
|
||
| namespace Xunit; | ||
|
|
||
| /// <summary> | ||
| /// Identifies an xunit theory that starts on with a <see cref="System.Threading.SynchronizationContext"/> | ||
| /// running on <see cref="Foundation.NSRunLoop.Main"/>. | ||
| /// </summary> | ||
| [AttributeUsage(AttributeTargets.Method, AllowMultiple = false)] | ||
| [XunitTestCaseDiscoverer("Xunit.Sdk.CocoaTheoryDiscoverer", ThisAssembly.AssemblyName)] | ||
| public class CocoaTheoryAttribute : TheoryAttribute | ||
| { | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| // 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.CompilerServices; | ||
|
|
||
| namespace Xunit.Sdk; | ||
|
|
||
| /// <summary> | ||
| /// The discovery class for <see cref="CocoaFactDiscoverer"/>. | ||
| /// </summary> | ||
| public class CocoaFactDiscoverer : FactDiscoverer | ||
| { | ||
| private readonly IMessageSink diagnosticMessageSink; | ||
|
|
||
| /// <summary> | ||
| /// Initializes a new instance of the <see cref="CocoaFactDiscoverer"/> class. | ||
| /// </summary> | ||
| /// <param name="diagnosticMessageSink">The diagnostic message sink.</param> | ||
| 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 new UITestCase(UITestCase.SyncContextType.Cocoa, this.diagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), testMethod); | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the changes to this file can be undone now, right?