forked from technomancy/leiningen
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.clj
More file actions
76 lines (61 loc) · 2.46 KB
/
Copy pathtest.clj
File metadata and controls
76 lines (61 loc) · 2.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
(ns leiningen.test.test
(:refer-clojure :exclude [test])
(:use [clojure.test]
[leiningen.test]
[leiningen.test.helper :only [tmp-dir sample-no-aot-project abort-msg]])
(:require [clojure.java.io :as io]))
(use-fixtures :each
(fn [f]
(f)
(.delete (java.io.File. tmp-dir "lein-test-ran"))))
(defn runs []
(let [ran-file (io/file tmp-dir "lein-test-ran")]
(and (.exists ran-file)
(-> ran-file
(slurp)
(.split "\n")
(->> (map read-string)
(frequencies))))))
(defn ran? [] (-> (runs) keys set))
(deftest test-project-selectors
(is (= [:default :integration :int2 :no-custom]
(keys (:test-selectors sample-no-aot-project))))
(is (every? ifn? (map eval (vals (:test-selectors sample-no-aot-project))))))
(deftest test-default-selector
(test sample-no-aot-project ":default")
(is (= (ran?) #{:regular :int2 :not-custom :fixture})))
(deftest fixture-runs-appropriate-number-of-times
;; Issue #1269
(test sample-no-aot-project)
;; Because three tests ran
(is (= 3 ((runs) :fixture))))
(deftest test-no-args-defaults-to-default-selector
(test sample-no-aot-project)
(is (= (ran?) #{:regular :int2 :not-custom :fixture})))
(deftest test-basic-selector
(test sample-no-aot-project ":integration")
(is (= (ran?) #{:integration :integration-ns :fixture})))
(deftest test-complex-selector
(test sample-no-aot-project ":no-custom")
(is (= (ran?) #{:integration :integration-ns :regular :int2 :fixture})))
(deftest test-two-selectors
(test sample-no-aot-project ":integration" ":int2")
(is (= (ran?) #{:integration :integration-ns :int2 :fixture})))
(deftest test-override-namespace-selector
(test sample-no-aot-project ":int2")
(is (= (ran?) #{:integration-ns :int2 :fixture})))
(deftest test-only-selector
(test sample-no-aot-project ":only" "selectors/regular")
(is (= (ran?) #{:regular :fixture})))
(deftest test-namespace-argument
(test sample-no-aot-project "selectors")
(is (= (ran?) #{:regular :not-custom :int2 :fixture})))
(deftest test-invalid-namespace-argument
(is (.contains
(abort-msg
test sample-no-aot-project "boom")
"java.io.FileNotFoundException: Could not locate")))
(deftest test-file-argument
(let [file (io/file (first (:test-paths sample-no-aot-project)) "selectors.clj")]
(test sample-no-aot-project (.getPath file)))
(is (= (ran?) #{:regular :not-custom :int2 :fixture})))