ut icon indicating copy to clipboard operation
ut copied to clipboard

Explicit argc/argv passing

Open R2RT opened this issue 2 years ago • 0 comments

This allows user to explicitly specify args for the run.

int main(int argc, const char** argv) {
  // explicitly run registered test suites and manually pass argc/argv
  return ut::cfg<>.run({.argc = argc, .argv = argv});
}

To get it working yet another event has been added: events::run_begin, which contains argc/argv passed by the user.

TODO

  • [ ] update documentation
  • [ ] multi-file suites are crashing (args are parsed per compilation unit, but initialized only in main one)

Open questions

  1. It seems that detail::cfg is made of two sets of static variables: location+wip used while executing tests (?) and "the rest", which is/should be configurable by user (args). If we extract "the rest" to be non-static (and keep inside static config instance) we could add tests for parse function. Would it be OK?
  2. Should implicit argument capturing be default behaviour? I am no fan of it, but I guess both approaches can live next to each other.

R2RT avatar Jun 21 '23 20:06 R2RT