kputnam / piggly

PL/pgSQL stored procedure code coverage tool
Other
69 stars 14 forks source link

Add ability to exclude function(s) from a trace or report #17

Closed lcoldiron closed 13 years ago

lcoldiron commented 13 years ago

I'm thinking it might be nice to have an additional command line parameter for trace / untrace / report that would allow you specify a pattern to not include a function or functions in. For instance, if I want to trace the entire database that is great but if I want to execute a whole schema or function there isn't a way at the moment. The command line param might take a list of files as well as the pattern. Thoughts???

kputnam commented 13 years ago

This can be accomplished with the current command line options, though it's tricky. I will propose an improvement in the next comment.

For instance to trace everything but procs whose name begins with "bad" or "old". This says "don't move past the first character ^ and fail if (bad|old) matches".

$ piggly trace --pattern '/^(?!bad|old)/'

Then to trace everything except procs whose name ends with "bad" or "old".

$ piggly trace --pattern '/(?!bad|old)...$/'

This shows how it starts to get complicated, and rejecting names that match somewhere between the start and end, like "an_old_proc" is much worse.

kputnam commented 13 years ago

I think the commands should have options like --select and --ignore, and apply them in the order they were passed. That is, --ignore A --select B will ignore procedure names matching A unless it matches B. When passed --select B --ignore A procedure names matching B are selected unless it matches A.

Multiple options are additive so --select A --select B means "select anything matching A or B". Then --ignore X --ignore Y means "ignore anything that maches X or Y".

I don't like making it more complicated, but I think it remains simple for simple cases, and it makes complicated things possible.

kputnam commented 13 years ago

Note currently the matches aren't performed against the schema name, just the procedure name. This will also be addressed.

lcoldiron commented 13 years ago

Seems like a reasonable compromise to me.

kputnam commented 13 years ago

Note I also added --dry-run to each command to print which procedures matched your filters. Filters can be exact string matches like --select 'public.foo' or regular expressions like --select '/public\./'.