Skip to content

Commit 110e7d4

Browse files
committed
runner all-test
Needed for #34
1 parent dfb4d45 commit 110e7d4

File tree

1 file changed

+48
-5
lines changed

1 file changed

+48
-5
lines changed

src/tarantool/runner.clj

Lines changed: 48 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,17 @@
4747
;:monotonic monotonic/workload
4848
;:multimonotonic multimonotonic/workload
4949
;:pages pages/workload
50+
:none (fn [_] tests/noop-test)
5051
:register register/workload})
5152

53+
(def standard-workloads
54+
"The workload names we run for test-all by default."
55+
(remove #{:none} (keys workloads)))
56+
57+
(def workloads-expected-to-pass
58+
"A collection of workload names which we expect should actually pass."
59+
(remove #{:register :counter-dec} standard-workloads))
60+
5261
(def workload-options
5362
"For each workload, a map of workload options to all the values that option
5463
supports."
@@ -73,14 +82,27 @@
7382
[nil "--mvcc"
7483
"Enable MVCC engine"
7584
:default false]
76-
["-w" "--workload NAME" "Test workload to run"
77-
:parse-fn keyword
78-
:missing (str "--workload " (cli/one-of workloads))
79-
:validate [workloads (cli/one-of workloads)]]
8085
["-e" "--engine NAME"
8186
"What Tarantool data engine should we use?"
8287
:default "memtx"]])
8388

89+
(def test-all-opts
90+
"Command line options for testing everything."
91+
[[nil "--only-workloads-expected-to-pass" "Don't run tests which we know fail."
92+
:default false]
93+
["-w" "--workload NAME"
94+
"Test workload to run. If omitted, runs all workloads."
95+
:parse-fn keyword
96+
:default nil
97+
:validate [workloads (cli/one-of workloads)]]])
98+
99+
(def single-test-opts
100+
"Command line options for single tests."
101+
[["-w" "--workload NAME" "Test workload to run"
102+
:parse-fn keyword
103+
:missing (str "--workload " (cli/one-of workloads))
104+
:validate [workloads (cli/one-of workloads)]]])
105+
84106
(def crash-pattern
85107
"An egrep pattern we use to find crashes in the Tarantool logs."
86108
(str/join "|"
@@ -148,10 +170,31 @@
148170
:exceptions (checker/unhandled-exceptions)
149171
:workload (:checker workload)})})))
150172

173+
(defn all-test-options
174+
"Takes base cli options, a collection of workloads, and a test count,
175+
and constructs a sequence of test options."
176+
[cli workloads]
177+
(for [w workloads, i (range (:test-count cli))]
178+
(assoc cli
179+
:workload w)))
180+
181+
(defn all-tests
182+
"Takes parsed CLI options and constructs a sequence of test options, by
183+
combining all workloads."
184+
[test-fn opts]
185+
(let [workloads (if-let [w (:workload opts)] [w]
186+
(if (:only-workloads-expected-to-pass opts)
187+
workloads-expected-to-pass
188+
standard-workloads))]
189+
(->> (all-test-options opts workloads)
190+
(map test-fn))))
191+
151192
(defn -main
152193
"Handles command line arguments."
153194
[& args]
154195
(cli/run! (merge (cli/single-test-cmd {:test-fn tarantool-test
155-
:opt-spec cli-opts})
196+
:opt-spec (concat cli-opts single-test-opts)})
197+
(cli/test-all-cmd {:tests-fn (partial all-tests tarantool-test)
198+
:opt-spec (concat cli-opts test-all-opts)})
156199
(cli/serve-cmd))
157200
args))

0 commit comments

Comments
 (0)