fix: CLI11 integration

* Run 'sparkd tests' outside of the CLI::App framework
  (delegate to 'catch', which has a solid cli).  This
  fixes a bug which prevented callers from specifying
  test tags (in the form of '[<tag>]'), as the CLI::App's
  parse method removes square brackets from cli options.

* Bind cli options to instance members of their subcommand's
  CLI::App derived class.  This seems to fix a bug which caused
  the [static instance] binding source to be destructed twice.

 * Add help text for several subcommands
This commit is contained in:
John Colvin committed 2021-01-16 00:01:15 -06:00
1 parent 45de55a552
commit ca4e477f56
61 files changed
+841 -742

No files matched your search

+25 -21
View File
@@ -322,21 +322,6 @@ static void boost_pool_allocator(::benchmark::State &state) {
}
BENCHMARK(boost_pool_allocator);
static std::vector<std::string> args;
static void execute() {
bts_assert(args.size() < 99);
int argc = args.size() + 1;
char *argv[100];
argv[0] = (char *)"spark";
for (size_t i = 0; i < args.size(); i++)
argv[i + 1] = (char *)args[i].c_str();
::benchmark::Initialize(&argc, argv);
::benchmark::RunSpecifiedBenchmarks();
}
static void boost_lockless_queue(::benchmark::State &state) {
using FreeList = boost::lockfree::queue<void *>;
FreeList queue(1000000);
@@ -798,12 +783,31 @@ void concurrent_append_collection_index(::benchmark::State &state) {
}
BENCHMARK(concurrent_append_collection_index);
void Benchmark::register_cmd(CLI::App &app) {
auto *cmd = app.add_subcommand(
"benchmark", "Run micro-benchmarks. Use --benchmark_filter=regex to run "
"only specific benchmarks.");
cmd->add_option("args", args);
cmd->callback(execute);
struct Benchmark::Args {
std::vector<std::string> args;
};
Benchmark::Benchmark()
: CLI::App(
"Run micro-benchmarks. Use --benchmark_filter=regex to run only "
"specific benchmarks.",
"benchmark"),
_args(new Benchmark::Args()) {
add_option("args", _args->args);
callback([&] {
bts_assert(_args->args.size() < 99);
int argc = _args->args.size() + 1;
char *argv[100];
argv[0] = (char *)"spark";
for (size_t i = 0; i < _args->args.size(); i++)
argv[i + 1] = (char *)_args->args[i].c_str();
::benchmark::Initialize(&argc, argv);
::benchmark::RunSpecifiedBenchmarks();
});
}
Benchmark::~Benchmark() {}
} // namespace bts::cmds