Skip to content

Commit 4415472

Browse files
authored
Improve test failure messages (#89967)
1 parent 26103db commit 4415472

File tree

12 files changed

+52
-3
lines changed

12 files changed

+52
-3
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// Copyright (c) .NET Foundation and contributors. All rights reserved.
2+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
3+
4+
using System;
5+
6+
namespace Mono.Linker.Tests.Cases.Expectations.Assertions;
7+
8+
[AttributeUsage (AttributeTargets.Class)]
9+
public class ExpectNonZeroExitCodeAttribute : BaseExpectedLinkedBehaviorAttribute
10+
{
11+
public ExpectNonZeroExitCodeAttribute (int value)
12+
{
13+
}
14+
}

src/tools/illink/test/Mono.Linker.Tests.Cases/CommandLine/InvalidArguments.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
namespace Mono.Linker.Tests.Cases.CommandLine
55
{
6+
[ExpectNonZeroExitCode (1)]
67
[SetupLinkerArgument ("--verbose", "--invalidArgument")]
78
[LogContains ("Unrecognized command-line option")]
89
[NoLinkedOutput]

src/tools/illink/test/Mono.Linker.Tests.Cases/FeatureSettings/FeatureSubstitutionsInvalid.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
namespace Mono.Linker.Tests.Cases.FeatureSettings
55
{
6+
[ExpectNonZeroExitCode (1)]
67
[SetupLinkerSubstitutionFile ("FeatureSubstitutionsInvalid.xml")]
78
[SetupLinkerArgument ("--feature", "NoValueFeature", "true")]
89
[LogContains ("FeatureSubstitutionsInvalid.xml'. Feature 'NoValueFeature' does not specify a 'featurevalue' attribute")]

src/tools/illink/test/Mono.Linker.Tests.Cases/LinkAttributes/TypedArgumentsErrors.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
namespace Mono.Linker.Tests.Cases.LinkAttributes
66
{
7+
[ExpectNonZeroExitCode (1)]
78
[SetupLinkAttributesFile ("TypedArgumentsErrors.xml")]
89
[IgnoreLinkAttributes (false)]
910
[NoLinkedOutput]

src/tools/illink/test/Mono.Linker.Tests.Cases/Logging/CommonLogs.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
namespace Mono.Linker.Tests.Cases.Logging
55
{
6+
[ExpectNonZeroExitCode (1)]
67
[SetupCompileBefore ("LogStep.dll", new[] { "Dependencies/LogStep.cs" }, new[] { "illink.dll", "Mono.Cecil.dll" })]
78
[SetupLinkerArgument ("--custom-step", "Log.LogStep,LogStep.dll")]
89
[SetupLinkerArgument ("--verbose")]

src/tools/illink/test/Mono.Linker.Tests.Cases/Warnings/CanDisableWarnAsError.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
namespace Mono.Linker.Tests.Cases.Warnings
55
{
6+
[ExpectNonZeroExitCode (1)]
67
[IgnoreTestCase ("Ignore in NativeAOT, see https://github.com/dotnet/runtime/issues/82447", IgnoredBy = Tool.NativeAot)]
78
[SkipKeptItemsValidation]
89
[SkipRemainingErrorsValidation]

src/tools/illink/test/Mono.Linker.Tests.Cases/Warnings/CanSingleWarnWithWarnAsError.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
namespace Mono.Linker.Tests.Cases.Warnings
77
{
8+
[ExpectNonZeroExitCode (1)]
89
[IgnoreTestCase ("Ignore in NativeAOT, see https://github.com/dotnet/runtime/issues/82447", IgnoredBy = Tool.NativeAot)]
910
[SkipKeptItemsValidation]
1011
[SetupCompileBefore ("library.dll", new[] { typeof (TriggerWarnings_Lib) })]

src/tools/illink/test/Mono.Linker.Tests.Cases/Warnings/CanWarnAsError.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
namespace Mono.Linker.Tests.Cases.Warnings
55
{
6+
[ExpectNonZeroExitCode (1)]
67
[IgnoreTestCase ("Ignore in NativeAOT, see https://github.com/dotnet/runtime/issues/82447", IgnoredBy = Tool.NativeAot)]
78
[SkipKeptItemsValidation]
89
[SetupLinkerSubstitutionFile ("CanWarnAsErrorSubstitutions.xml")]

src/tools/illink/test/Mono.Linker.Tests.Cases/Warnings/InvalidWarningVersion.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
namespace Mono.Linker.Tests.Cases.Warnings
55
{
6+
[ExpectNonZeroExitCode (1)]
67
[IgnoreTestCase ("Ignore in NativeAOT, see https://github.com/dotnet/runtime/issues/82447", IgnoredBy = Tool.NativeAot)]
78
[SetupLinkerArgument ("--verbose")]
89
[SetupLinkerArgument ("--warn", "invalid")]

src/tools/illink/test/Mono.Linker.Tests/TestCasesRunner/LinkedTestCaseResult.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,9 @@ public class LinkedTestCaseResult
1717
public readonly ManagedCompilationResult CompilationResult;
1818
public readonly LinkerTestLogger Logger;
1919
public readonly LinkerCustomizations Customizations;
20+
public readonly int ExitCode;
2021

21-
public LinkedTestCaseResult (TestCase testCase, NPath inputAssemblyPath, NPath outputAssemblyPath, NPath expectationsAssemblyPath, TestCaseSandbox sandbox, TestCaseMetadataProvider metadataProvider, ManagedCompilationResult compilationResult, LinkerTestLogger logger, LinkerCustomizations customizations)
22+
public LinkedTestCaseResult (TestCase testCase, NPath inputAssemblyPath, NPath outputAssemblyPath, NPath expectationsAssemblyPath, TestCaseSandbox sandbox, TestCaseMetadataProvider metadataProvider, ManagedCompilationResult compilationResult, LinkerTestLogger logger, LinkerCustomizations customizations, int exitCode)
2223
{
2324
TestCase = testCase;
2425
InputAssemblyPath = inputAssemblyPath;
@@ -29,6 +30,7 @@ public LinkedTestCaseResult (TestCase testCase, NPath inputAssemblyPath, NPath o
2930
CompilationResult = compilationResult;
3031
Logger = logger;
3132
Customizations = customizations;
33+
ExitCode = exitCode;
3234
}
3335
}
3436
}

0 commit comments

Comments
 (0)