fsharp icon indicating copy to clipboard operation
fsharp copied to clipboard

Contributor QoL - .fsproj hacks to build ComponentTests for a single-file test run fast?

Open T-Gro opened this issue 2 months ago • 2 comments

When working on a feature, I typically run a small selection of tests very frequently. AI tools , be it via IDE or standalone agents, also typically run tests in a single file via "dotnet test --filter" to iterate quickly.

I noticed that if the build speed bothers me, I just comment out all but 1 "<Compile>" item in the .fsproj in ComponentTests.

I am writing it here as an issue just to see if:

  • Others do that too
  • There is perhaps a clever way to detect that "--filter" with a single file/module/type has been passed to botnet test, and we could conditionally choose items to compile.
  • We could somehow teach agents to do it

This is highly specific to this repo only, it assumes that all Compile items in the test project are independent (except perhaps xunit setup) and can be freely removed.

T-Gro avatar Oct 17 '25 09:10 T-Gro

One trick of limited use but helpful when crafting and debugging the test case is to have the compiled code in a separate file:

    [<Theory; FileInlineData("infinite.fs")>]
    let ``Infinite types in type relations cache`` compilation =
        compilation
        |> getCompilation
        |> typecheck

Changes will not trigger a rebuild at all.

majocha avatar Oct 17 '25 10:10 majocha

I typically had more changes in FCS than in the tests, so the total wait time for ComponentTests builds was negligible compared to FCS builds.

Martin521 avatar Oct 17 '25 11:10 Martin521