8000 Add tests for async registry pretty printer by jvolmer · Pull Request #21720 · arangodb/arangodb · GitHub
[go: up one dir, main page]

Skip to content

Add tests for async registry pretty printer #21720

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

Merged
merged 11 commits into from
May 26, 2025
Prev Previous commit
Next Next commit
Test running thread variable
  • Loading branch information
jvolmer committed May 19, 2025
commit c6a4f1579d1950a5143b1ac9acc509111b193fcb
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,18 @@ using namespace arangodb::async_registry;
auto breakpoint() { raise(SIGINT); }

auto format(PromiseSnapshot const& snapshot) -> std::string {
return fmt::format("\"{}\" (\"{}\":{}), thread {}, {}",
snapshot.source_location.function_name,
snapshot.source_location.file_name,
snapshot.source_location.line, snapshot.thread.kernel_id,
arangodb::inspection::json(snapshot.state));
if (snapshot.thread == std::nullopt) {
return fmt::format(
"\"{}\" (\"{}\":{}), {}", snapshot.source_location.function_name,
snapshot.source_location.file_name, snapshot.source_location.line,
arangodb::inspection::json(snapshot.state));
} else {
return fmt::format(
"\"{}\" (\"{}\":{}), {} on thread {}",
snapshot.source_location.function_name,
snapshot.source_location.file_name, snapshot.source_location.line,
arangodb::inspection::json(snapshot.state), snapshot.thread->kernel_id);
}
}

/**
Expand Down Expand Up @@ -79,6 +86,18 @@ int main() {

breakpoint();

// works also with a currently non-running promise
parent->data.running_thread.store(std::nullopt);
expected = fmt::format(
"async registry = {{\n"
"[thread {}] = \n"
" ┌ {}\n"
"─ thread {}}}",
current_thread.kernel_id, format(parent->data.snapshot()),
current_thread.kernel_id);

breakpoint();
< 48A3 br>
// add a promise that depends on parent promise
auto* child = thread_registry->add([&]() {
return Promise{{parent->data.id()}, std::source_location::current()};
Expand Down
0