Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/Adapter/MSTest.Engine/Engine/TestExecutionContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@ public void ReportException(Exception exception, CancellationToken? timeoutCance
// We want to consider user timeouts as failures if they didn't use our cancellation token
OperationCanceledException canceledException
when canceledException.CancellationToken == _originalCancellationToken || canceledException.CancellationToken == CancellationToken
#pragma warning disable CS0618 // Type or member is obsolete
=> new CancelledTestNodeStateProperty(ExceptionFlattener.FlattenOrUnwrap(exception)),
#pragma warning restore CS0618 // Type or member is obsolete
OperationCanceledException canceledException when canceledException.CancellationToken == timeoutCancellationToken
=> new TimeoutTestNodeStateProperty(ExceptionFlattener.FlattenOrUnwrap(exception)),
AssertFailedException => new FailedTestNodeStateProperty(ExceptionFlattener.FlattenOrUnwrap(exception), exception.Message),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,9 @@ public async Task ConsumeAsync(IDataProducer dataProducer, IData value, Cancella
case ErrorTestNodeStateProperty error:
await WriteExceptionAsync(error.Explanation, error.Exception, cancellationToken).ConfigureAwait(false);
break;
#pragma warning disable CS0618 // Type or member is obsolete
case CancelledTestNodeStateProperty cancelled:
#pragma warning restore CS0618 // Type or member is obsolete
await WriteExceptionAsync(cancelled.Explanation, cancelled.Exception, cancellationToken).ConfigureAwait(false);
break;
case TimeoutTestNodeStateProperty timeout:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,9 @@ public async Task ConsumeAsync(IDataProducer dataProducer, IData value, Cancella

_testsCurrentExecutionState.TryAdd(nodeChangedMessage.TestNode.Uid, (nodeChangedMessage.TestNode.DisplayName, typeof(InProgressTestNodeStateProperty), _clock.UtcNow));
}
#pragma warning disable CS0618 // Type or member is obsolete
else if (state is PassedTestNodeStateProperty or ErrorTestNodeStateProperty or CancelledTestNodeStateProperty
#pragma warning restore CS0618 // Type or member is obsolete
or FailedTestNodeStateProperty or TimeoutTestNodeStateProperty or SkippedTestNodeStateProperty
&& _testsCurrentExecutionState.TryRemove(nodeChangedMessage.TestNode.Uid, out (string Name, Type Type, DateTimeOffset StartTime) record)
&& _traceLevelEnabled)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,9 @@ await HandleFailuresAsync(
cancellationToken).ConfigureAwait(false);
break;

#pragma warning disable CS0618 // Type or member is obsolete
case CancelledTestNodeStateProperty canceledState:
#pragma warning restore CS0618 // Type or member is obsolete
await HandleFailuresAsync(
testNodeStateChanged.TestNode.DisplayName,
isCanceled: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,18 @@ internal static class TestNodePropertiesCategories
typeof(FailedTestNodeStateProperty),
typeof(ErrorTestNodeStateProperty),
typeof(TimeoutTestNodeStateProperty),
#pragma warning disable CS0618 // Type or member is obsolete
typeof(CancelledTestNodeStateProperty),
#pragma warning restore CS0618 // Type or member is obsolete
];

public static Type[] WellKnownTestNodeTestRunOutcomeFailedProperties { get; } =
[
typeof(FailedTestNodeStateProperty),
typeof(ErrorTestNodeStateProperty),
typeof(TimeoutTestNodeStateProperty),
#pragma warning disable CS0618 // Type or member is obsolete
typeof(CancelledTestNodeStateProperty),
#pragma warning restore CS0618 // Type or member is obsolete
];
}
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,7 @@ public override int GetHashCode()
/// <summary>
/// Property that represents an eventual cancellation of a test node.
/// </summary>
[Obsolete("CancelledTestNodeStateProperty is obsolete. Test frameworks should throw OperationCanceledException using the cancellation token passed by Microsoft.Testing.Platform instead of using this state.")]
public sealed class CancelledTestNodeStateProperty : TestNodeStateProperty, IEquatable<CancelledTestNodeStateProperty>
{
/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,9 @@ public Task ConsumeAsync(IDataProducer dataProducer, IData value, CancellationTo
OnFailedTest(testNodeStateChanged, timeoutState, timeoutState.Exception, duration);
break;

#pragma warning disable CS0618 // Type or member is obsolete
case CancelledTestNodeStateProperty cancelledState:
#pragma warning restore CS0618 // Type or member is obsolete
OnFailedTest(testNodeStateChanged, cancelledState, cancelledState.Exception, duration);
break;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,9 @@ public Task ConsumeAsync(IDataProducer dataProducer, IData value, CancellationTo
standardError);
break;

#pragma warning disable CS0618 // Type or member is obsolete
case CancelledTestNodeStateProperty cancelledState:
#pragma warning restore CS0618 // Type or member is obsolete
_terminalTestReporter.TestCompleted(
testNodeStateChanged.TestNode.Uid.Value,
testNodeStateChanged.TestNode.DisplayName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,9 @@ public async Task ConsumeAsync(IDataProducer dataProducer, IData value, Cancella
exceptions = FlattenToExceptionMessages(reason, timeoutTestNodeStateProperty.Exception);
break;

#pragma warning disable CS0618 // Type or member is obsolete
case CancelledTestNodeStateProperty cancelledTestNodeStateProperty:
#pragma warning restore CS0618 // Type or member is obsolete
state = TestStates.Cancelled;
duration = testNodeUpdateMessage.TestNode.Properties.SingleOrDefault<TimingProperty>()?.GlobalTiming.Duration.Ticks;
reason = nodeState.Explanation;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,9 @@ public Json(Dictionary<Type, JsonSerializer>? serializers = null, Dictionary<Typ
break;
}

#pragma warning disable CS0618 // Type or member is obsolete
case CancelledTestNodeStateProperty canceledTestNodeStateProperty:
#pragma warning restore CS0618 // Type or member is obsolete
{
properties.Add(("execution-state", "canceled"));
Exception? exception = canceledTestNodeStateProperty.Exception;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,9 @@ internal void PopulateTestNodeStatistics(TestNodeUpdateMessage message)

case FailedTestNodeStateProperty:
case ErrorTestNodeStateProperty:
#pragma warning disable CS0618 // Type or member is obsolete
case CancelledTestNodeStateProperty:
#pragma warning restore CS0618 // Type or member is obsolete
case TimeoutTestNodeStateProperty:
AddOrUpdateTestNodeStateStatistics(testNodeUid, hasPassed: false);
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,9 @@ static SerializerUtilities()
break;
}

#pragma warning disable CS0618 // Type or member is obsolete
case CancelledTestNodeStateProperty canceledTestNodeStateProperty:
#pragma warning restore CS0618 // Type or member is obsolete
{
properties["execution-state"] = "canceled";
properties["error.message"] = canceledTestNodeStateProperty.Explanation ?? canceledTestNodeStateProperty.Exception?.Message;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,9 @@ internal static IEnumerable<object[]> FailedState()
{
yield return [new FailedTestNodeStateProperty()];
yield return [new ErrorTestNodeStateProperty()];
#pragma warning disable CS0618 // Type or member is obsolete
yield return [new CancelledTestNodeStateProperty()];
#pragma warning restore CS0618 // Type or member is obsolete
yield return [new TimeoutTestNodeStateProperty()];
}

Expand Down
Loading