native icon indicating copy to clipboard operation
native copied to clipboard

[native_assets_cli] Improve hook testing

Open dcharkes opened this issue 8 months ago • 2 comments

We currently have a testBuildHook and testCodeBuildHook (added in https://github.com/dart-lang/native/pull/1377 and refactored afterwards).

These are intended for use in the same package as the hook, and to run the hooks in isolation.

Some things to add to this way of testing:

  • Use the correct working directory.
  • Use process invocation to be able to test exit codes? (The downside would be that you can't use the debugger to step through the code as easily.)
  • A way to provide user-defines.
  • A way to provide assets passed in from other build hooks (a.k.a. metadata).
  • Similar methods for link hooks.
  • Similar methods for data assets.

Note: If lots of hooks start building on top of other hooks, then possibly testing hooks in isolation might prove to be less useful than anticipated. This remains to be seen.

dcharkes avatar Apr 25 '25 09:04 dcharkes

cc @mosuem Are you using these functions? (The initial one was added by you.)

Context: I'm trying to see

  1. what classes we typically need inside hooks,
  2. what classes we typically need inside tests for hooks, and
  3. what classes we typically need in hook-helper-packages.

This will hopefully inform how we should structure our libraries (https://github.com/dart-lang/native/issues/1805).

dcharkes avatar Apr 25 '25 10:04 dcharkes

Are you using these functions? (The initial one was added by you.)

I don't - but I probably should. Currently, I just have end-to-end tests which run the build hooks by building, and then testing them by running the compiled program. This is not good practice IMO.

mosuem avatar May 05 '25 07:05 mosuem