Skip to content

Commit 2758f86

Browse files
committed
Captured max output sizes in tests
1 parent ada4af1 commit 2758f86

14 files changed

+26
-85
lines changed

test/Thinktecture.Runtime.Extensions.SourceGenerator.Tests/SourceGeneratorTests/AdHocUnionSourceGeneratorTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ namespace Thinktecture.Runtime.Tests.SourceGeneratorTests;
77
public class AdHocUnionSourceGeneratorTests : SourceGeneratorTestsBase
88
{
99
public AdHocUnionSourceGeneratorTests(ITestOutputHelper output)
10-
: base(output)
10+
: base(output, 23_000)
1111
{
1212
}
1313

test/Thinktecture.Runtime.Extensions.SourceGenerator.Tests/SourceGeneratorTests/JsonSmartEnumSourceGeneratorTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ namespace Thinktecture.Runtime.Tests.SourceGeneratorTests;
77
public class JsonSmartEnumSourceGeneratorTests : SourceGeneratorTestsBase
88
{
99
public JsonSmartEnumSourceGeneratorTests(ITestOutputHelper output)
10-
: base(output)
10+
: base(output, 1_000)
1111
{
1212
}
1313

test/Thinktecture.Runtime.Extensions.SourceGenerator.Tests/SourceGeneratorTests/JsonValueObjectSourceGeneratorTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ namespace Thinktecture.Runtime.Tests.SourceGeneratorTests;
77
public class JsonValueObjectSourceGeneratorTests : SourceGeneratorTestsBase
88
{
99
public JsonValueObjectSourceGeneratorTests(ITestOutputHelper output)
10-
: base(output)
10+
: base(output, 8_000)
1111
{
1212
}
1313

test/Thinktecture.Runtime.Extensions.SourceGenerator.Tests/SourceGeneratorTests/MessagePackSmartEnumSourceGeneratorTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ namespace Thinktecture.Runtime.Tests.SourceGeneratorTests;
99
public class MessagePackSmartEnumSourceGeneratorTests : SourceGeneratorTestsBase
1010
{
1111
public MessagePackSmartEnumSourceGeneratorTests(ITestOutputHelper output)
12-
: base(output)
12+
: base(output, 1_000)
1313
{
1414
}
1515

test/Thinktecture.Runtime.Extensions.SourceGenerator.Tests/SourceGeneratorTests/MessagePackValueObjectSourceGeneratorTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ namespace Thinktecture.Runtime.Tests.SourceGeneratorTests;
99
public class MessagePackValueObjectSourceGeneratorTests : SourceGeneratorTestsBase
1010
{
1111
public MessagePackValueObjectSourceGeneratorTests(ITestOutputHelper output)
12-
: base(output)
12+
: base(output, 4_000)
1313
{
1414
}
1515

test/Thinktecture.Runtime.Extensions.SourceGenerator.Tests/SourceGeneratorTests/NewtonsoftJson/ReadJson.cs

Lines changed: 0 additions & 36 deletions
This file was deleted.

test/Thinktecture.Runtime.Extensions.SourceGenerator.Tests/SourceGeneratorTests/NewtonsoftJsonSmartEnumSourceGeneratorTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ namespace Thinktecture.Runtime.Tests.SourceGeneratorTests;
77
public class NewtonsoftJsonSmartEnumSourceGeneratorTests : SourceGeneratorTestsBase
88
{
99
public NewtonsoftJsonSmartEnumSourceGeneratorTests(ITestOutputHelper output)
10-
: base(output)
10+
: base(output, 1_000)
1111
{
1212
}
1313

test/Thinktecture.Runtime.Extensions.SourceGenerator.Tests/SourceGeneratorTests/NewtonsoftJsonValueObjectSourceGeneratorTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ namespace Thinktecture.Runtime.Tests.SourceGeneratorTests;
77
public class NewtonsoftJsonValueObjectSourceGeneratorTests : SourceGeneratorTestsBase
88
{
99
public NewtonsoftJsonValueObjectSourceGeneratorTests(ITestOutputHelper output)
10-
: base(output)
10+
: base(output, 8_000)
1111
{
1212
}
1313

test/Thinktecture.Runtime.Extensions.SourceGenerator.Tests/SourceGeneratorTests/ObjectFactorySourceGeneratorTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ namespace Thinktecture.Runtime.Tests.SourceGeneratorTests;
77
public class ObjectFactorySourceGeneratorTests : SourceGeneratorTestsBase
88
{
99
public ObjectFactorySourceGeneratorTests(ITestOutputHelper output)
10-
: base(output)
10+
: base(output, 2_000)
1111
{
1212
}
1313

test/Thinktecture.Runtime.Extensions.SourceGenerator.Tests/SourceGeneratorTests/RegularUnionSourceGeneratorTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ namespace Thinktecture.Runtime.Tests.SourceGeneratorTests;
77
public class RegularUnionSourceGeneratorTests : SourceGeneratorTestsBase
88
{
99
public RegularUnionSourceGeneratorTests(ITestOutputHelper output)
10-
: base(output)
10+
: base(output, 8_000)
1111
{
1212
}
1313

test/Thinktecture.Runtime.Extensions.SourceGenerator.Tests/SourceGeneratorTests/SmartEnumSourceGeneratorTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ namespace Thinktecture.Runtime.Tests.SourceGeneratorTests;
77
public class SmartEnumSourceGeneratorTests : SourceGeneratorTestsBase
88
{
99
public SmartEnumSourceGeneratorTests(ITestOutputHelper output)
10-
: base(output)
10+
: base(output, 40_000)
1111
{
1212
}
1313

test/Thinktecture.Runtime.Extensions.SourceGenerator.Tests/SourceGeneratorTests/SourceGeneratorTestsBase.cs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,14 @@ public abstract class SourceGeneratorTestsBase
1515
private const string _GENERATION_ERROR = "CS8785";
1616

1717
private readonly ITestOutputHelper _output;
18+
private readonly int _maxOutputSize;
1819

19-
protected SourceGeneratorTestsBase(ITestOutputHelper output)
20+
protected SourceGeneratorTestsBase(
21+
ITestOutputHelper output,
22+
int maxOutputSize)
2023
{
2124
_output = output ?? throw new ArgumentNullException(nameof(output));
25+
_maxOutputSize = maxOutputSize;
2226
}
2327

2428
protected Task VerifyAsync(
@@ -48,6 +52,9 @@ protected async Task VerifyAsync(
4852
throw new Exception($"Output file '{fileName}' not found. Available files: {String.Join(", ", outputs.Keys)}", ex);
4953
}
5054

55+
if (content.Length > _maxOutputSize)
56+
throw new Exception($"Output file '{fileName}' is too big. Actual size: {content.Length}. Max size: {_maxOutputSize}.");
57+
5158
var verify = Verifier.Verify(content);
5259
var paramText = parameterText;
5360

@@ -68,13 +75,19 @@ protected async Task VerifyAsync(
6875
string parameterText,
6976
string output)
7077
{
78+
if (output.Length > _maxOutputSize)
79+
throw new Exception($"Output file is too big. Actual size: {output.Length}. Max size: {_maxOutputSize}.");
80+
7181
await Verifier.Verify(output)
7282
.UseTextForParameters(parameterText);
7383
}
7484

7585
protected async Task VerifyAsync(
7686
string output)
7787
{
88+
if (output.Length > _maxOutputSize)
89+
throw new Exception($"Output file is too big. Actual size: {output.Length}. Max size: {_maxOutputSize}.");
90+
7891
await Verifier.Verify(output);
7992
}
8093

@@ -101,7 +114,7 @@ protected string GetGeneratedOutput<T>(
101114
return output;
102115
}
103116

104-
public static Dictionary<string, string> GetGeneratedOutputs<T>(string source, params Assembly[] furtherAssemblies)
117+
protected static Dictionary<string, string> GetGeneratedOutputs<T>(string source, params Assembly[] furtherAssemblies)
105118
where T : IIncrementalGenerator, new()
106119
{
107120
var syntaxTree = CSharpSyntaxTree.ParseText(source);

test/Thinktecture.Runtime.Extensions.SourceGenerator.Tests/SourceGeneratorTests/SystemTextJson/ReadJson.cs

Lines changed: 0 additions & 36 deletions
This file was deleted.

test/Thinktecture.Runtime.Extensions.SourceGenerator.Tests/SourceGeneratorTests/ValueObjectSourceGeneratorTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ namespace Thinktecture.Runtime.Tests.SourceGeneratorTests;
1010
public class ValueObjectSourceGeneratorTests : SourceGeneratorTestsBase
1111
{
1212
public ValueObjectSourceGeneratorTests(ITestOutputHelper output)
13-
: base(output)
13+
: base(output, 13_000)
1414
{
1515
}
1616

0 commit comments

Comments
 (0)