Skip to content
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

Fix NativeAot_hw_runs_with_no_warnings_when_PublishAot_is_enabled Test #46661

Merged
merged 2 commits into from
Feb 10, 2025
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
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,25 @@ public void NativeAot_hw_runs_with_no_warnings_when_PublishAot_is_enabled(string
{
testProject.AdditionalProperties["StripSymbols"] = "true";
}
var testAsset = _testAssetsManager.CreateTestProject(testProject);
var testAsset = _testAssetsManager.CreateTestProject(testProject, identifier: targetFramework);

string[] ignoredPatterns = null;

if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
{
ignoredPatterns = new string[]
{
// Both these exclusions can be removed once the min tested version is .NET 10 and the min supported
// XCode version is XCode 16.

// -ld_classic option is required to workaround bugs in XCode 15 and .NET 9 and older runtimes.
// See https://github.com/dotnet/runtime/issues/97745 for details.
"ld: warning: -ld_classic is deprecated and will be removed in a future release",
// These warnings show up when dotnet/runtime compiled using Apple clang 15+ is used
// with classic linker (either Apple clang 14 or clang 15+ with -ld_classic).
"ld: warning: __LD,__compact_unwind entries for",
};
}

var publishCommand = new PublishCommand(Log, Path.Combine(testAsset.TestRoot, testProject.Name));
publishCommand
Expand All @@ -48,7 +66,7 @@ public void NativeAot_hw_runs_with_no_warnings_when_PublishAot_is_enabled(string
.And.NotHaveStdOutContaining("IL2026")
.And.NotHaveStdErrContaining("NETSDK1179")
.And.NotHaveStdErrContaining("warning")
.And.NotHaveStdOutContaining("warning");
.And.NotHaveStdOutContaining("warning", ignoredPatterns);

var buildProperties = testProject.GetPropertyValues(testAsset.TestRoot, targetFramework);
var rid = buildProperties["NETCoreSdkPortableRuntimeIdentifier"];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,23 @@ public AndConstraint<CommandResultAssertions> HaveStdOutContaining(Func<string,
return new AndConstraint<CommandResultAssertions>(this);
}

public AndConstraint<CommandResultAssertions> NotHaveStdOutContaining(string pattern)
public AndConstraint<CommandResultAssertions> NotHaveStdOutContaining(string pattern, string[] ignoredPatterns = null)
{
Execute.Assertion.ForCondition(!_commandResult.StdOut.Contains(pattern))
string filteredStdOut = _commandResult.StdOut;
if (ignoredPatterns != null && ignoredPatterns.Length > 0)
{
foreach (var ignoredPattern in ignoredPatterns)
{
filteredStdOut = string.Join(Environment.NewLine, filteredStdOut
.Split(new[] { Environment.NewLine }, StringSplitOptions.None)
.Where(line => !line.Contains(ignoredPattern)));
}
}

// Perform the assertion on the filtered output
Execute.Assertion.ForCondition(!filteredStdOut.Contains(pattern))
.FailWith(AppendDiagnosticsTo($"The command output contained a result it should not have contained: {pattern}{Environment.NewLine}"));

return new AndConstraint<CommandResultAssertions>(this);
}

Expand Down