Add AOT smoke test to CI#5251
Conversation
Adds --smoke-test flag to NativeAot example that creates all views, verifies no AOT crashes, and exits. CI now runs the published AOT binary after dotnet publish to catch runtime AOT regressions. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
The real exceptions in AOT only manifest themselves at runtime with the release configuration, using the NuGet package from the local_packages folder. |
Can you make a specific recommendation on what should change here? |
Adds Examples/NativeAot/SmokeTest — a standalone project that references Terminal.Gui via PackageReference (not ProjectReference) and AOT-publishes + runs it. This catches AOT runtime errors that only manifest when consuming the NuGet package, where trimming decisions differ from a direct project reference. CI flow: Pack → AOT publish (ProjectRef) → run → AOT publish (NuGet) → run Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
I remember when I created the NativeAot project, there was a Debug configuration that used a reference to the Terminal.Gui project for immediate debugging purposes, and a Release configuration that used the latest NuGet package in the local_packages folder, which caught all compilation errors that weren't detectable through the Debug configuration. It seems this has been changed now, which doesn't give any certainty as to whether AOT is actually working correctly or not. |
|
Currently, I don't see anything related to trimmers in the NativeAOT project. |
SmokeTest was inside Examples/NativeAot/ so its Program.cs got auto-included in NativeAot.csproj (SDK default glob), causing 'more than one entry point' error. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
@BDisp see the updated PR description. This test should now test end-to-end and catch almost all aot issues. |
SmokeTest.csproj uses PackageReference Version='*' to pick up the freshly-packed local nupkg. Central Package Management (NU1008) blocks inline Version attributes, so opt this CI-only project out. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…oke test Instead of just creating views and exiting, smoke tests now use RunAsync with a 5-second CancellationToken timeout to exercise the full app lifecycle: Init → Run → layout → draw → event loop → stop. DisableRealDriverIO=1 env var enables headless execution in CI. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
I see. It looks like it might work. Be aware that sometimes it compiled fine in the Release configuration, successfully publishing the executable, but when run it still threw exceptions that weren't caught at compile time. I don't know if CI will also address these cases. |
Part of why the test intentionally uses a bunch of View sub-classes and enables CM. |
In CI, dotnet pack produces a prerelease version (e.g. 2.1.0-PullRequest5251.135). NuGet's Version='*' only matches stable releases, so it was resolving an old stable package from nuget.org that didn't have RunAsync. Version='*-*' matches prerelease versions too. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The NuGet-based SmokeTest added complexity (CPM opt-out, prerelease version resolution, packageSourceMapping) without catching different bugs. The ILC runs the same analysis regardless of reference type. The ProjectReference-based NativeAot --smoke-test already: - Produces a real AOT native binary via dotnet publish - Runs it with DisableRealDriverIO for headless CI - Exercises full app lifecycle via RunAsync with timeout Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Ideally, you should test with the most recently generated NuGet package because it may even contain some fixes that will be needed in the most recent release. At least try running the published file manually, because the published file is different from the file created in the Release configuration. |
|
I ran this through my local Copilot agent where I was testing the previous AOT fixes. Here is some feedback.
|
|
FWIW: Check out https://github.com/gui-cs/clet#native-binaries-install I do believe this is the first instance of a full TG app published as native AOT that really, truly, works! |
Summary
Adds an AOT runtime regression test to CI that actually publishes and runs the NativeAot example binary.
Changes
**\Examples/NativeAot/Program.cs**: Added --smoke-test\ flag that:
**.github/workflows/build-validation.yml**: Added \AOT Smoke Test\ step that runs the published AOT binary with --smoke-test\ after the existing \dotnet publish\ step.
Why
The existing CI only does \dotnet publish\ which catches compile-time AOT issues (trimming warnings, IL linker errors). But some AOT bugs only manifest at runtime — e.g., reflection-dependent Dictionary constructors, missing type metadata, serialization failures. This smoke test catches those.
Testing