[native_assets_cli] Improve hook testing
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.
cc @mosuem Are you using these functions? (The initial one was added by you.)
Context: I'm trying to see
- what classes we typically need inside hooks,
- what classes we typically need inside tests for hooks, and
- 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).
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.