Skip to content

Direct Agent Execution #1624

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

Merged
merged 4 commits into from
Apr 19, 2025
Merged

Direct Agent Execution #1624

merged 4 commits into from
Apr 19, 2025

Conversation

CharliePoole
Copy link
Member

@CharliePoole CharliePoole commented Feb 9, 2025

Fixes #1623

Copy link
Member

@manfred-brands manfred-brands left a comment

Choose a reason for hiding this comment

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

I don't think this new code is part of the testing as I don't see it in build.cake or package-tests.cake but I'm not clear on how the tester is tested.


private void WriteErrorsFailuresAndWarnings(XmlNode resultNode)
{
string resultState = resultNode.GetAttribute("result") ?? "";
Copy link
Member

Choose a reason for hiding this comment

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

"result" node could be passed in like in summary.

Comment on lines 230 to 231
if (resultNode.SelectSingleNode("reason/message")?.InnerText == "One or more child tests had warnings" ||
resultNode.SelectSingleNode("failure/message")?.InnerText == "One or more child tests had errors")
Copy link
Member

Choose a reason for hiding this comment

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

Most likely pre-existing, but this is a hard dependency on a string in another repository.

#endif
var xmlResult = runner.Run(null, TestFilter.Empty).Xml;

WriteRunSettingsReport(xmlResult);
Copy link
Member

Choose a reason for hiding this comment

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

Would like to see a separate report class.
Is it the idea that the nunit-console calls this class as otherwise we have two report classes.

#if NETFRAMEWORK
string agentExe = agentAssembly;
#else
string agentExe = Path.ChangeExtension(agentAssembly, ".exe");
Copy link
Member

Choose a reason for hiding this comment

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

Is nunit-console to be supported on non-windows? The NUnitConsole_Linux.sln has not been maintained.

On Linux there is no .exe extension.

Copy link
Member Author

Choose a reason for hiding this comment

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

It should continue to be supported. Some linux distros support exe but not all. Let's add an issue for this.

#else
const string STANDARD_CONFIG_FILE = "nunit.engine.core.tests.dll.config";
#endif
const string STANDARD_CONFIG_FILE = "nunit.agent.core.tests.exe.config";
Copy link
Member

Choose a reason for hiding this comment

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

Compiling this branch, I see the previous behaviour:

$ find . -name 'nunit.agent.core.tests*.config'
./net462/nunit.agent.core.tests.exe.config
./net8.0/nunit.agent.core.tests.dll.config

@CharliePoole
Copy link
Member Author

The DirectTestAgent isn't part of the engine but of the tests. It just provides an exe to allow exercising the direct execution facility in nunit.agent.core. There's only one unit test that uses it right now but once the agents are in separate projects, all their tests will be run through it. We have never tested the agents in isolation before but this makes a start.

@CharliePoole CharliePoole changed the title New Feature: Direct Agent Execution WIP: Direct Agent Execution Apr 13, 2025
@CharliePoole
Copy link
Member Author

This has been dormant for a while, so I'm making it WIP while I rebase and decide how to move it forward.

@CharliePoole CharliePoole changed the title WIP: Direct Agent Execution Direct Agent Execution Apr 18, 2025
@CharliePoole
Copy link
Member Author

CharliePoole commented Apr 18, 2025

@manfred-brands

This is again ready for review. I took most of your suggestions and brought the PR up to date with the latest commits. Since that included the new analyzers, I fixed the analyzer problems. I also added a few package tests to actually make use of the feature.

For the moment, I have kept the code duplication for console output. I think some of this code will change once the agents are extensions in their own right. At that point, I'd like to allow it to evolve independently. We'll then have a better idea of exactly what parts can be common and eliminate the duplication.

UPDATE: Actually not 100% up to date with version4 but still able to be merged.

Copy link
Member

@manfred-brands manfred-brands left a comment

Choose a reason for hiding this comment

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

A few small items which I have fixed in a review commit.
The main issue I have is what I said before, why is the reporting different between direct agent execution and the ConsoleRunner.
Both call runner.Run and print the results.
Why can the AgentDirectRunner not create an ResultReporter for the report?

Copy link
Member

@manfred-brands manfred-brands left a comment

Choose a reason for hiding this comment

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

Approved with the caveat of your message that the reporting will be re-visited.

@CharliePoole CharliePoole merged commit abd2b30 into version4 Apr 19, 2025
4 checks passed
@CharliePoole
Copy link
Member Author

Thanks for your review. I think it was important to get this odd bit of code in place before I start splitting out all the agents into separate projects. I also agree that something ought to be done about the output before that happens.

The duplication in this PR is duplication I just created by design. I copied some code from the console, solely as a way to get us started. I want people to see this feature and give us feedback with ideas about where it could be used and how it should look in the future.

Once that happens, we might remove the duplication in several ways...

  • Dropping the output entirely and relying on the console runner via some option.
  • Refactoring so that the report class is somewhere in common and used by both
  • Factoring out common pieces while keeping the rest specific to the individual application

If I had decided not to have the duplication in the first place, I would be picking one of those things in advance.

If this sounds crazy to you, that's OK too. It's something I've done in a lot of places and I've had a lot of strange reactions at first, but it seems to pay off more than not. ;-)

@CharliePoole CharliePoole deleted the issue-1623 branch April 19, 2025 03:30
@CharliePoole
Copy link
Member Author

Looks like that alpha.34 label was never removed. I'm a bit tired, so I'll mess directly with the labels on version4 branch in the morning when I'm fresh.

@CharliePoole
Copy link
Member Author

I got a few hours sleep and fixed the tags and did a push --tags -f on version4. Reran the build and it all looks good now. The problem was that the alpha.34 and alpha.35 tags were on detached commits.

Latest on myget is now 4.0.0-alpha.35 and I think we're now good for future runs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants