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

Remove unnecessary "return 100"s from tests #89550

Merged
merged 9 commits into from
Aug 22, 2023
Merged

Conversation

markples
Copy link
Contributor

@markples markples commented Jul 27, 2023

Add XUnitWrapperGenerator check for test methods that always return 100 and change them to void.

@ghost
Copy link

ghost commented Jul 27, 2023

Tagging subscribers to this area: @dotnet/area-system-reflection-metadata
See info in area-owners.md if you want to be subscribed.

Issue Details

Note: contains #89521

Add XUnitWrapperGenerator check for test methods that always return 100 and change them to void.

Author: markples
Assignees: markples
Labels:

area-System.Reflection.Metadata

Milestone: -

@markples markples added area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI and removed area-System.Reflection.Metadata labels Jul 27, 2023
@ghost
Copy link

ghost commented Jul 27, 2023

Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch
See info in area-owners.md if you want to be subscribed.

Issue Details

Note: contains #89521

Add XUnitWrapperGenerator check for test methods that always return 100 and change them to void.

Author: markples
Assignees: markples
Labels:

area-CodeGen-coreclr

Milestone: -

@markples
Copy link
Contributor Author

This should be ready @trylek @jkoritzinsky @TIHan cc @dotnet/jit-contrib.

The actual change is small. Tests are almost entirely changing to void and very occasionally something related to that. I've scanned the entire diff though of course I'm the author.

@markples markples marked this pull request as ready for review July 28, 2023 19:38
Comment on lines +153 to +164
foreach (SyntaxReference node in method.DeclaringSyntaxReferences.Where(n => n != null))
{
foreach (ReturnStatementSyntax rs in node.GetSyntax(context.CancellationToken).DescendantNodes().OfType<ReturnStatementSyntax>())
{
if (rs.Expression == null) continue;
found = true;
if (rs.Expression is LiteralExpressionSyntax les && les.Token.Value is int i && i == 100) continue;
return;
}
}

if (!found) return;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For a future PR, I think it's worthwhile moving these checks into a separate analyzer instead of doing them as part of the source generator. If we do them in an analyzer, we can get better performance at build time and we could use better tools (like the IOperation APIs) to validate these sorts of scenarios.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this idea but mainly did it this way because I'm unfamiliar with all of this and couldn't easily figure out how to set anything up (primarily copying and pasting in this file). So I'll either need a template for doing so or more time to turn the docs/bing chat into something real.

Copy link
Member

@trylek trylek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, thank you!

@markples
Copy link
Contributor Author

/azp run runtime-coreclr outerloop

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@markples
Copy link
Contributor Author

markples commented Aug 8, 2023

new analyzer means a race condition with newly added tests (audit commits and/or rerun old test jobs)

@markples markples assigned trylek and unassigned markples Aug 8, 2023
@trylek
Copy link
Member

trylek commented Aug 22, 2023

I have rebased this against the current main, the change is passing locally for me, I plan to merge it in once I find the lab results reasonable.

@trylek
Copy link
Member

trylek commented Aug 22, 2023

/azp run runtime-coreclr outerloop

@trylek
Copy link
Member

trylek commented Aug 22, 2023

/azp run runtime-extra-platforms

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

1 similar comment
@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@trylek
Copy link
Member

trylek commented Aug 22, 2023

Just like in the previous case runtime and outerloop are clean and runtime-extra-platforms, while not clean, doesn't look any worse than in any other runs, merging in.

@trylek trylek merged commit 5d00fc5 into dotnet:main Aug 22, 2023
@ghost ghost locked as resolved and limited conversation to collaborators Sep 21, 2023
@markples markples deleted the ret100 branch September 28, 2023 23:34
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants