Skip to content

Commit

Permalink
Remove case-switch per checker-group
Browse files Browse the repository at this point in the history
Part of #38
  • Loading branch information
ligurio committed May 2, 2022
1 parent d23bf96 commit 1487adf
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions src/elle_cli/cli.clj
Original file line number Diff line number Diff line change
Expand Up @@ -165,17 +165,18 @@

(defn check-history
"Check a specified history according to model specified by model name"
[model-name history options checker-group]
[model-name history options]

(let [checker-fn (get models model-name)]
(case checker-group
"knossos" (competition/analysis (checker-fn) history)
"elle" (checker-fn options history)
"jepsen" (case model-name
"jepsen-bank" (jepsen-model/check-safe (checker-fn {:negative-balances? true}) nil history)
"jepsen-set-full" (jepsen-model/check-safe (checker-fn) nil history)
"jepsen-counter" (jepsen-model/check-safe (checker-fn) nil history)
))))
(case model-name
"knossos-register" (competition/analysis (checker-fn) history)
"knossos-cas-register" (competition/analysis (checker-fn) history)
"knossos-mutex" (competition/analysis (checker-fn) history)
"elle-list-append" (checker-fn options history)
"elle-rw-register" (checker-fn options history)
"jepsen-bank" (jepsen-model/check-safe (checker-fn {:negative-balances? true}) nil history)
"jepsen-counter" (jepsen-model/check-safe (checker-fn) nil history)
"jepsen-set-full" (jepsen-model/check-safe (checker-fn) nil history))))

(defn read-fn-by-extension
"Take a path to file and returns a function for reading that file."
Expand Down Expand Up @@ -206,7 +207,7 @@
(let [read-history (or read-history (read-fn-by-extension filepath))
checker-group (first (str/split model-name #"-"))
history (read-history filepath checker-group)
analysis (check-history model-name history options checker-group)]
analysis (check-history model-name history options)]

(if (true? (:verbose options))
(json/pprint analysis)
Expand Down

0 comments on commit 1487adf

Please sign in to comment.