Skip to content

Commit faf8921

Browse files
committed
test: Refactor "When using quiet specs in the batch reporter" to test color
Refactor the test so each spec becomes a suite of two specs doint the same test with and without color enabled. This exposes the bug described in #251
1 parent 77f3954 commit faf8921

File tree

1 file changed

+112
-44
lines changed

1 file changed

+112
-44
lines changed

tests/test-buttercup.el

Lines changed: 112 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -2233,51 +2233,119 @@ before it's processed by other functions."
22332233
(kill-buffer print-buffer)
22342234
(setq print-buffer nil))
22352235

2236-
(it "should print nothing if all specs are quiet"
2237-
(with-local-buttercup :color nil :quiet '(pending) :reporter #'buttercup-reporter-batch
2238-
(describe "top"
2239-
(it "spec 1")
2240-
(describe "second"
2241-
(it "spec 2")
2242-
(it "spec 3")))
2243-
(describe "empty")
2244-
(buttercup-run))
2245-
(expect (buttercup-output) :to-equal
2246-
"Running 0 out of 3 specs.\n\nRan 0 out of 3 specs, 0 failed, in 13.00s.\n"))
2247-
2248-
(it "should print the containing suites for non-quiet specs"
2249-
(with-local-buttercup :color nil :quiet '(pending) :reporter #'buttercup-reporter-batch
2250-
(describe "top"
2251-
(it "spec 1" (ignore))
2252-
(describe "second"
2253-
(it "spec 2")
2254-
(it "spec 3" (ignore))
2255-
(describe "third"
2256-
(it "spec 4"))))
2257-
(describe "empty")
2258-
(buttercup-run))
2259-
(expect (buttercup-output) :to-equal
2260-
(concat "Running 2 out of 4 specs.\n\n"
2261-
"top\n"
2262-
" spec 1 (1.00s)\n"
2263-
" second\n"
2264-
" spec 3 (1.00s)\n\n"
2265-
"Ran 2 out of 4 specs, 0 failed, in 19.00s.\n")))
2236+
(describe "it should print nothing if all specs are quiet"
2237+
:var (test-suites)
2238+
(before-each
2239+
(with-local-buttercup
2240+
(describe "top"
2241+
(it "spec 1")
2242+
(describe "second"
2243+
(it "spec 2")
2244+
(it "spec 3")))
2245+
(describe "empty")
2246+
(setq test-suites buttercup-suites)))
2247+
(after-each
2248+
(setq test-suites nil))
22662249

2267-
(it "should quiet all of the given spec statuses"
2268-
;; suppress stacktraces printed at buttercup-done
2269-
(spy-on 'buttercup-reporter-batch--print-failed-spec-report)
2270-
(with-local-buttercup
2271-
:color nil :quiet '(pending passed failed) :reporter #'buttercup-reporter-batch
2272-
(describe "passed"
2273-
(it "passed" (ignore)))
2274-
(describe "failed"
2275-
(it "failed" (buttercup-fail "because")))
2276-
(describe "pending"
2277-
(it "pending"))
2278-
(buttercup-run t))
2279-
(expect (buttercup-output) :to-equal
2280-
"Running 2 out of 3 specs.\n\nRan 2 out of 3 specs, 1 failed, in 13.00s.\n"))
2250+
(it "and color is disabled"
2251+
(with-local-buttercup
2252+
:color nil
2253+
:quiet '(pending)
2254+
:reporter #'buttercup-reporter-batch
2255+
:suites test-suites
2256+
(buttercup-run))
2257+
(expect (buttercup-output) :to-equal
2258+
"Running 0 out of 3 specs.\n\nRan 0 out of 3 specs, 0 failed, in 13.00s.\n"))
2259+
2260+
(it "and color is enabled"
2261+
(with-local-buttercup
2262+
:color t
2263+
:quiet '(pending)
2264+
:reporter #'buttercup-reporter-batch
2265+
:suites test-suites
2266+
(buttercup-run))
2267+
(expect (buttercup-output) :to-equal
2268+
"Running 0 out of 3 specs.\n\nRan 0 out of 3 specs, 0 failed, in 13.00s.\n")))
2269+
2270+
(describe "should print the containing suites for non-quiet specs"
2271+
:var (test-suites)
2272+
(before-each
2273+
(with-local-buttercup
2274+
(describe "top"
2275+
(it "spec 1" (ignore))
2276+
(describe "second"
2277+
(it "spec 2")
2278+
(it "spec 3" (ignore))
2279+
(describe "third"
2280+
(it "spec 4"))))
2281+
(describe "empty")
2282+
(setq test-suites buttercup-suites)))
2283+
(after-each
2284+
(setq test-suites nil))
2285+
2286+
(it "and color is disabled"
2287+
(with-local-buttercup
2288+
:color nil
2289+
:quiet '(pending)
2290+
:reporter #'buttercup-reporter-batch
2291+
:suites test-suites
2292+
(buttercup-run))
2293+
(expect (buttercup-output) :to-equal
2294+
(concat "Running 2 out of 4 specs.\n\n"
2295+
"top\n"
2296+
" spec 1 (1.00s)\n"
2297+
" second\n"
2298+
" spec 3 (1.00s)\n\n"
2299+
"Ran 2 out of 4 specs, 0 failed, in 19.00s.\n")))
2300+
(it "and color is enabled"
2301+
(with-local-buttercup
2302+
:color t
2303+
:quiet '(pending)
2304+
:reporter #'buttercup-reporter-batch
2305+
:suites test-suites
2306+
(buttercup-run))
2307+
(expect (buttercup-output) :to-equal
2308+
(concat "Running 2 out of 4 specs.\n\n"
2309+
"top\n"
2310+
" spec 1 (1.00s)\n"
2311+
" second\n"
2312+
" spec 3 (1.00s)\n\n"
2313+
"Ran 2 out of 4 specs, 0 failed, in 19.00s.\n"))))
2314+
2315+
(describe "should quiet all of the given spec statuses"
2316+
:var (test-suites)
2317+
(before-each
2318+
(with-local-buttercup
2319+
(describe "passed"
2320+
(it "passed" (ignore)))
2321+
(describe "failed"
2322+
(it "failed" (buttercup-fail "because")))
2323+
(describe "pending"
2324+
(it "pending"))
2325+
(setq test-suites buttercup-suites)))
2326+
(after-each (setq test-suites nil))
2327+
(it "and color is disabled"
2328+
;; suppress stacktraces printed at buttercup-done
2329+
(spy-on 'buttercup-reporter-batch--print-failed-spec-report)
2330+
(with-local-buttercup
2331+
:color nil
2332+
:quiet '(pending passed failed)
2333+
:reporter #'buttercup-reporter-batch
2334+
:suites test-suites
2335+
(buttercup-run t))
2336+
(expect (buttercup-output) :to-equal
2337+
"Running 2 out of 3 specs.\n\nRan 2 out of 3 specs, 1 failed, in 13.00s.\n"))
2338+
(it "and color is enabled"
2339+
;; suppress stacktraces printed at buttercup-done
2340+
(spy-on 'buttercup-reporter-batch--print-failed-spec-report)
2341+
(with-local-buttercup
2342+
:color t
2343+
:quiet '(pending passed failed)
2344+
:reporter #'buttercup-reporter-batch
2345+
:suites test-suites
2346+
(buttercup-run t))
2347+
(expect (buttercup-output) :to-equal
2348+
"Running 2 out of 3 specs.\n\nRan 2 out of 3 specs, 1 failed, in 13.00s.\n")))
22812349

22822350
(it "should handle `skipped' virtual status in quiet list"
22832351
;; suppress stacktraces printed at buttercup-done

0 commit comments

Comments
 (0)