You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
where print_out simply prints out the arguments so we can verify them in testing; and do_work is the entry function of the program, args is a program-specific function where you do all the CLI stuff and return a tuple to apply to the do_work function (names are just examples).
So now we can verify that we pass the right values by running a simple python script and compare the output.
Ideally, do_work should have its own integration test but that might be tricky sometimes. First, it must be separated in a header. In that case, some things would be compiled twice, which is an awful idea for things like queries.
There is one solution that might be a bit annoying. We'd have three files:
Proposal
This is one idea I had that doesn't involve some crazy complicated stuff in C++.
Basically, we have a hidden flag
--print-arguments
that doesn't show up in the help. We always have this pattern:where
print_out
simply prints out the arguments so we can verify them in testing; anddo_work
is the entry function of the program,args
is a program-specific function where you do all the CLI stuff and return a tuple to apply to thedo_work
function (names are just examples).So now we can verify that we pass the right values by running a simple python script and compare the output.
Ideally,
do_work
should have its own integration test but that might be tricky sometimes. First, it must be separated in a header. In that case, some things would be compiled twice, which is an awful idea for things likequeries
.There is one solution that might be a bit annoying. We'd have three files:
program.hpp
program.cpp
program_entry.cpp
The last one would be something like this:
This is not ideal, but actually this would allow to directly test
args
fromCatch
.Any thoughts? Other ideas?
The text was updated successfully, but these errors were encountered: