Skip to content

Commit

Permalink
try to make tests more predictable
Browse files Browse the repository at this point in the history
  • Loading branch information
adamhathcock committed Jan 27, 2025
1 parent 0c9c95a commit d50757d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 16 deletions.
Original file line number Diff line number Diff line change
@@ -1,24 +1,13 @@
{
"Type": "AggregateException",
"InnerExceptions": [
{
"InnerException": {
"Message": "The method or operation is not implemented.",
"Data": {},
"InnerException": null,
"HelpLink": null,
"Source": "Speckle.Sdk.Serialization.Tests",
"HResult": -2147467263,
"StackTrace": " at Speckle.Sdk.Serialization.Tests.Framework.ExceptionSendCacheManager.SaveObjects(IEnumerable`1 items) in C:\\Users\\adam\\Git\\speckle-sharp-sdk\\tests\\Speckle.Sdk.Serialization.Tests\\Framework\\ExceptionSendCacheManager.cs:line 19\r\n at Speckle.Sdk.Serialisation.V2.Receive.ObjectLoader.SaveToCache(List`1 batch) in C:\\Users\\adam\\Git\\speckle-sharp-sdk\\src\\Speckle.Sdk\\Serialisation\\V2\\Receive\\ObjectLoader.cs:line 116\r\n at Open.ChannelExtensions.<INTERNALIZED STACKTRACE>Extensions.<>c__DisplayClass98_0`1.<ReadAllConcurrently>b__0(T e)\r\n at Open.ChannelExtensions.<INTERNALIZED STACKTRACE>Extensions.<>c__DisplayClass92_0`1.<ReadAllConcurrentlyAsync>b__2(T item, Int64 _)\r\n at Open.ChannelExtensions.<INTERNALIZED STACKTRACE>Extensions.ReadUntilCancelledAsync[T](<INTERNALIZED STACKTRACE>ChannelReader`1 reader, CancellationToken cancellationToken, Func`3 receiver, Boolean deferredExecution)\r\n at Open.ChannelExtensions.<INTERNALIZED STACKTRACE>Extensions.<>c__DisplayClass92_0`1.<<ReadAllConcurrentlyAsync>g__Read|1>d.MoveNext()\r\n--- End of stack trace from previous location ---\r\n at Open.ChannelExtensions.<INTERNALIZED STACKTRACE>Extensions.<>c__DisplayClass92_0`1.<<ReadAllConcurrentlyAsync>g__Read|1>d.MoveNext()"
"StackTrace": " at Speckle.Sdk.Serialization.Tests.Framework.ExceptionSendCacheManager.SaveObjects(IEnumerable`1 items) in C:\\Users\\adam\\Git\\speckle-sharp-sdk\\tests\\Speckle.Sdk.Serialization.Tests\\Framework\\ExceptionSendCacheManager.cs:line 19\r\n at Speckle.Sdk.Serialisation.V2.Receive.ObjectLoader.SaveToCache(List`1 batch) in C:\\Users\\adam\\Git\\speckle-sharp-sdk\\src\\Speckle.Sdk\\Serialisation\\V2\\Receive\\ObjectLoader.cs:line 116\r\n at Open.ChannelExtensions.<INTERNALIZED STACKTRACE>Extensions.<>c__DisplayClass98_0`1.<ReadAllConcurrently>b__0(T e)\r\n at Open.ChannelExtensions.<INTERNALIZED STACKTRACE>Extensions.<>c__DisplayClass63_0`1.<ReadAllAsync>b__0(T e, Int64 _)\r\n at Open.ChannelExtensions.<INTERNALIZED STACKTRACE>Extensions.ReadUntilCancelledAsync[T](<INTERNALIZED STACKTRACE>ChannelReader`1 reader, CancellationToken cancellationToken, Func`3 receiver, Boolean deferredExecution)\r\n at Open.ChannelExtensions.<INTERNALIZED STACKTRACE>Extensions.ReadAllAsync[T](<INTERNALIZED STACKTRACE>ChannelReader`1 reader, Func`3 receiver, Boolean deferredExecution, CancellationToken cancellationToken)"
},
{
"Message": "The method or operation is not implemented.",
"Data": {},
"InnerException": null,
"HelpLink": null,
"Source": "Speckle.Sdk.Serialization.Tests",
"HResult": -2147467263,
"StackTrace": " at Speckle.Sdk.Serialization.Tests.Framework.ExceptionSendCacheManager.SaveObjects(IEnumerable`1 items) in C:\\Users\\adam\\Git\\speckle-sharp-sdk\\tests\\Speckle.Sdk.Serialization.Tests\\Framework\\ExceptionSendCacheManager.cs:line 19\r\n at Speckle.Sdk.Serialisation.V2.Receive.ObjectLoader.SaveToCache(List`1 batch) in C:\\Users\\adam\\Git\\speckle-sharp-sdk\\src\\Speckle.Sdk\\Serialisation\\V2\\Receive\\ObjectLoader.cs:line 116\r\n at Open.ChannelExtensions.<INTERNALIZED STACKTRACE>Extensions.<>c__DisplayClass98_0`1.<ReadAllConcurrently>b__0(T e)\r\n at Open.ChannelExtensions.<INTERNALIZED STACKTRACE>Extensions.<>c__DisplayClass92_0`1.<ReadAllConcurrentlyAsync>b__2(T item, Int64 _)\r\n at Open.ChannelExtensions.<INTERNALIZED STACKTRACE>Extensions.ReadUntilCancelledAsync[T](<INTERNALIZED STACKTRACE>ChannelReader`1 reader, CancellationToken cancellationToken, Func`3 receiver, Boolean deferredExecution)\r\n at Open.ChannelExtensions.<INTERNALIZED STACKTRACE>Extensions.<>c__DisplayClass92_0`1.<<ReadAllConcurrentlyAsync>g__Read|1>d.MoveNext()\r\n--- End of stack trace from previous location ---\r\n at Open.ChannelExtensions.<INTERNALIZED STACKTRACE>Extensions.<>c__DisplayClass92_0`1.<<ReadAllConcurrentlyAsync>g__Read|1>d.MoveNext()"
}
],
"StackTrace": "at Speckle.Sdk.Dependencies.Serialization.ChannelLoader`1.CheckForExceptions()\nat Speckle.Sdk.Serialisation.V2.Receive.ObjectLoader.GetAndCache(String rootId, DeserializeProcessOptions options, CancellationToken cancellationToken)\nat Speckle.Sdk.Serialisation.V2.Receive.DeserializeProcess.Deserialize(String rootId)\n--- End of stack trace from previous location ---\nat Xunit.Assert.RecordExceptionAsync(Func`1 testCode)"
}
10 changes: 8 additions & 2 deletions tests/Speckle.Sdk.Serialization.Tests/ExceptionTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,13 @@ public async Task Test_Exceptions_Receive_Server(string fileName, string rootId,
closures.Count.Should().Be(oldCount);

var o = new ObjectLoader(new DummySqLiteReceiveManager(closures), new ExceptionServerObjectManager(), null);
using var process = new DeserializeProcess(null, o, new ObjectDeserializerFactory(), default, new(true));
using var process = new DeserializeProcess(
null,
o,
new ObjectDeserializerFactory(),
default,
new(true, MaxParallelism: 1)
);

var ex = await Assert.ThrowsAsync<NotImplementedException>(async () =>
{
Expand All @@ -95,7 +101,7 @@ public async Task Test_Exceptions_Receive_Cache(string fileName, string rootId,
o,
new ObjectDeserializerFactory(),
default,
new(MaxParallelism: 2)
new(MaxParallelism: 1)
);

Exception ex;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public override void Write(VerifyJsonWriter writer, Exception value)
if (value.StackTrace != null)
{
var ex = JsonConvert.SerializeObject(value, Formatting.Indented);
var newString = InteralizeStacktrace().Replace(ex, "<INTERNALIZED STACKTRACE>");
var newString = InteralizeStacktrace().Replace(ex, "<INTERNALIZED STACKTRACE>").Trim();
writer.WriteRawValue(newString);
return;
}
Expand Down

0 comments on commit d50757d

Please sign in to comment.