Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Explicit argc/argv passing #572

Merged
merged 6 commits into from
Jul 7, 2024
Merged

Conversation

R2RT
Copy link
Contributor

@R2RT R2RT commented Jun 21, 2023

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.

This allows user to explicitly specify args
for the run.

```c++
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.
@@ -2115,6 +2131,7 @@ class runner {

[[nodiscard]] auto run(run_cfg rc = {}) -> bool {
run_ = true;
reporter_.on(events::run_begin{.argc = rc.argc, .argv = rc.argv});
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if constexpr (requires { reporter_.on(events::run_begin{}); })

@Curve
Copy link
Contributor

Curve commented Jul 7, 2024

This is badly needed. When not using the changes introduced here, all built test binaries crash on alpine linux

@kris-jusiak kris-jusiak merged commit fb06064 into boost-ext:master Jul 7, 2024
4 of 8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants