Skip to content

Commit

Permalink
Merge pull request #595 from elbeno/flow-graph-cycle
Browse files Browse the repository at this point in the history
🚸 Improve error message for cyclic flows
  • Loading branch information
elbeno authored Aug 12, 2024
2 parents 0b5b9d5 + b08cee1 commit 5b8cb6e
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 4 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/unit_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ jobs:
cxx_flags: ""
- version: 13
compiler: gcc
install: sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test && sudo apt update && sudo apt-get install -y gcc-13 g++-13
install: sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test && sudo apt update && sudo apt install -y gcc-13 g++-13
cc: "gcc-13"
cxx: "g++-13"
- version: 12
Expand Down Expand Up @@ -232,7 +232,7 @@ jobs:
- compiler: gcc
cc: "gcc-13"
cxx: "g++-13"
install: sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test && sudo apt update && sudo apt-get install -y gcc-13 g++-13
install: sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test && sudo apt update && sudo apt install -y gcc-13 g++-13
toolchain_root: "/usr"

steps:
Expand Down Expand Up @@ -288,7 +288,7 @@ jobs:
- name: Install build tools
run: |
sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
sudo apt update && sudo apt-get install -y gcc-${{env.DEFAULT_GCC_VERSION}} g++-${{env.DEFAULT_GCC_VERSION}} ninja-build valgrind
sudo apt update && sudo apt install -y gcc-${{env.DEFAULT_GCC_VERSION}} g++-${{env.DEFAULT_GCC_VERSION}} ninja-build valgrind
- name: Restore CPM cache
env:
Expand Down
3 changes: 2 additions & 1 deletion include/flow/graph_builder.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,8 @@ struct graph_builder {
constexpr static auto built() {
constexpr auto v = Initialized::value;
constexpr auto built = build(v);
static_assert(built.has_value());
static_assert(built.has_value(),
"Topological sort failed: cycle in flow");
return *built;
}

Expand Down
1 change: 1 addition & 0 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ add_unit_test(
catalog2_lib
catalog_strings)

add_compile_fail_test(flow/fail/cyclic_flow.cpp LIBRARIES warnings cib)
add_compile_fail_test(msg/fail/callback_bad_field_name.cpp LIBRARIES warnings
cib)
add_compile_fail_test(msg/fail/field_location.cpp LIBRARIES warnings cib)
Expand Down
23 changes: 23 additions & 0 deletions test/flow/fail/cyclic_flow.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#include <cib/cib.hpp>
#include <flow/flow.hpp>

// EXPECT: Topological sort failed: cycle in flow

namespace {
using namespace flow::literals;

constexpr auto a = flow::milestone<"a">();
constexpr auto b = flow::milestone<"b">();

struct TestFlowAlpha : public flow::service<> {};

struct CyclicFlowConfig {
constexpr static auto config = cib::config(
cib::exports<TestFlowAlpha>, cib::extend<TestFlowAlpha>(a >> b >> a));
};
} // namespace

auto main() -> int {
cib::nexus<CyclicFlowConfig> nexus{};
nexus.service<TestFlowAlpha>();
}

0 comments on commit 5b8cb6e

Please sign in to comment.