Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/init/system.clj
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@
(stop-system system graph selectors nil))
([system graph selectors exception]
(reduce (fn [ex [k c]]
(stop-component c (system k) ex))
(if (contains? system k)
(stop-component c (system k) ex)
ex))
exception
(graph/reverse-dependency-order graph selectors))))

Expand Down
16 changes: 16 additions & 0 deletions test/init/system_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,19 @@
(is (= ::d (-> ex ex-data :component :name)))
(is (= ::d (-> ex ex-cause ex-data :name)))
(is (= [::c ::b ::a] (mapv #(-> % ex-cause ex-data :name) (.getSuppressed ex)))))))

(deftest partial-system-test
(testing "start/stop partially started system"
(let [stopped (atom [])
stop-fn (partial swap! stopped conj)
add (fn [c [n d]]
(config/add-component c {:name n
:deps d
:start-fn (constantly n)
:stop-fn stop-fn}))
config (reduce add {} [[::a] [::b [::a]] [::c [::b]] [::d [::c ::a]]])
system (-> config graph/dependency-graph (system/start [::b]))
result (system/stop system (keys system))]
(is (= [::a ::b] (keys system)))
(is (nil? result))
(is (= [::b ::a] @stopped)))))