bazel-skylib icon indicating copy to clipboard operation
bazel-skylib copied to clipboard

analysistest should provide convenience functions for comparing action command-lines

Open sfreilich opened this issue 4 years ago • 0 comments

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.run and ctx.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.argv contains 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 (for run_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).

sfreilich avatar Nov 17 '21 20:11 sfreilich