native icon indicating copy to clipboard operation
native copied to clipboard

[record_use] Dart API: Testing record use

Open dcharkes opened this issue 2 months ago • 0 comments

dart test runs in JIT mode, which means package authors can't use it to test that their link hooks and record-use annotations do the right thing.

To make the tests useful, every test should AOT compile its own entry point. However, that would not enable testing that something got tree-shaken out.

It would be better to have something similar to:

https://github.com/dart-lang/native/blob/400c7001de7a3cddca341e728163bd64029ab288/pkgs/hooks/lib/src/test.dart#L42

testLinkHook.

However, then the user would need to provide the recorded uses file manually. So we need an API that compiles an entry point and provides the recorded uses so that we can pass it in to the test.

Thanks @simolus3 for the suggestion!

dcharkes avatar Sep 25 '25 15:09 dcharkes