bazel-skylib
bazel-skylib copied to clipboard
analysistest should provide convenience functions for comparing action command-lines
Writing assertions on the command lines of actions of the target under test is complicated for a few reasons:
- Not all actions have argv, you want to pull out just the ones created with
ctx.actions.runandctx.actions.run_shell. - Not all actions may be generated by the code under test (for example, you might not care about the exact command-lines of actions generated by `cc_common.compile/link), so you might want to pull out just the actions with a specific mnemonic, or with mnemonics that begin with a specific prefix.
-
Action.argvcontains paths that are long. It would be nice if there was an easy way of abbreviating the bin dir path of the target under test, the relative path to the package of the target under test, and the path to the shell binary (forrun_shell) so that the expected values for assertions could abbreviate those as well (e.g. a function that takes argv and replaces those with "bin", "package", and "sh", respectively).