Skip to content

Commit b08cee1

Browse files
committed
🚸 Improve error message for cyclic flows
1 parent 0b5b9d5 commit b08cee1

File tree

4 files changed

+29
-4
lines changed

4 files changed

+29
-4
lines changed

.github/workflows/unit_tests.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ jobs:
8686
cxx_flags: ""
8787
- version: 13
8888
compiler: gcc
89-
install: sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test && sudo apt update && sudo apt-get install -y gcc-13 g++-13
89+
install: sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test && sudo apt update && sudo apt install -y gcc-13 g++-13
9090
cc: "gcc-13"
9191
cxx: "g++-13"
9292
- version: 12
@@ -232,7 +232,7 @@ jobs:
232232
- compiler: gcc
233233
cc: "gcc-13"
234234
cxx: "g++-13"
235-
install: sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test && sudo apt update && sudo apt-get install -y gcc-13 g++-13
235+
install: sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test && sudo apt update && sudo apt install -y gcc-13 g++-13
236236
toolchain_root: "/usr"
237237

238238
steps:
@@ -288,7 +288,7 @@ jobs:
288288
- name: Install build tools
289289
run: |
290290
sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
291-
sudo apt update && sudo apt-get install -y gcc-${{env.DEFAULT_GCC_VERSION}} g++-${{env.DEFAULT_GCC_VERSION}} ninja-build valgrind
291+
sudo apt update && sudo apt install -y gcc-${{env.DEFAULT_GCC_VERSION}} g++-${{env.DEFAULT_GCC_VERSION}} ninja-build valgrind
292292
293293
- name: Restore CPM cache
294294
env:

include/flow/graph_builder.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,8 @@ struct graph_builder {
147147
constexpr static auto built() {
148148
constexpr auto v = Initialized::value;
149149
constexpr auto built = build(v);
150-
static_assert(built.has_value());
150+
static_assert(built.has_value(),
151+
"Topological sort failed: cycle in flow");
151152
return *built;
152153
}
153154

test/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ add_unit_test(
119119
catalog2_lib
120120
catalog_strings)
121121

122+
add_compile_fail_test(flow/fail/cyclic_flow.cpp LIBRARIES warnings cib)
122123
add_compile_fail_test(msg/fail/callback_bad_field_name.cpp LIBRARIES warnings
123124
cib)
124125
add_compile_fail_test(msg/fail/field_location.cpp LIBRARIES warnings cib)

test/flow/fail/cyclic_flow.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#include <cib/cib.hpp>
2+
#include <flow/flow.hpp>
3+
4+
// EXPECT: Topological sort failed: cycle in flow
5+
6+
namespace {
7+
using namespace flow::literals;
8+
9+
constexpr auto a = flow::milestone<"a">();
10+
constexpr auto b = flow::milestone<"b">();
11+
12+
struct TestFlowAlpha : public flow::service<> {};
13+
14+
struct CyclicFlowConfig {
15+
constexpr static auto config = cib::config(
16+
cib::exports<TestFlowAlpha>, cib::extend<TestFlowAlpha>(a >> b >> a));
17+
};
18+
} // namespace
19+
20+
auto main() -> int {
21+
cib::nexus<CyclicFlowConfig> nexus{};
22+
nexus.service<TestFlowAlpha>();
23+
}

0 commit comments

Comments
 (0)