-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathdejour-tests.clj
69 lines (48 loc) · 2.1 KB
/
dejour-tests.clj
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
(ns clj-tests
(:use clojure.contrib.test-is)
(:use clojure.contrib.shell-out))
(defn windows? []
(re-seq #"[wW]indows" (System/getProperty "os.name")))
(defn executable [name]
(if (windows?)
(str name ".exe")
name))
(defn run [cmd]
(apply sh
(cons
(executable (first cmd))
(rest cmd))))
(defn output-matches? [cmd re msg]
(let [ output (run cmd) ]
(is
(re-seq re output)
msg)))
(defn output-doesnt-match? [cmd re msg]
(let [ output (run cmd) ]
(is
(not (re-seq re output))
msg)))
; core jar files and main classes
(output-matches? ["clj" "-debug"] #"lib.clojure-[\d.]+\.jar" "Contains clojure.jar")
(output-matches? ["clj" "-debug"] #"lib.clojure-contrib-[\d.]+\.jar" "Contains contrib")
(output-matches? ["clj" "-debug"] #"lib.jline\.jar" "Contains jline.jar")
(output-matches? ["clj" "-debug"] #"jline\.ConsoleRunner" "Contains console runner")
(output-matches? ["clj" "-debug"] #"clojure\.main$" "contains clojure main")
; repl class
(output-doesnt-match? ["clj" "-debug" "-repl-class" "foo"] #"clojure\.main$" "repl class")
(output-matches? ["clj" "-debug" "-repl-class" "foo"] #"foo$" "repl class")
; clojure args
(output-matches? ["clj" "-debug" "arg1" "arg2"] #"arg1 +arg2$" "clojure arguments")
(output-matches? ["clj" "-debug" "--" "arg1" "arg2"] #"arg1 +arg2$" "-- params")
; No jline
(output-doesnt-match? ["clj" "-debug" "-no-jline"] #"jline.jar" "no jline, no jar")
(output-doesnt-match? ["clj" "-debug" "-no-jline"] #"jline.ConsoleRunner" "no jline no class")
; -classpath and -cp
(output-matches? ["clj" "-debug" "-cp" "extra" ] #"extra" "-cp")
(output-matches? ["clj" "-debug" "-classpath" "extra" ] #"extra" "-classpath")
; Java args
(output-matches? ["clj" "-debug" "-Dfoo=bar" ] #"-Dfoo=bar.*clojure.main" "-D")
(output-matches? ["clj" "-debug" "-Xfoo=bar" ] #"-Xfoo=bar.*clojure.main" "-X")
(output-matches? ["clj" "-debug" "-server" ] #"-server.*clojure.main" "-server")
(output-matches? ["clj" "-debug" "-client" ] #"-client.*clojure.main" "-client")
(output-matches? ["clj" "-debug" "-hotspot" ] #"-hotspot.*clojure.main" "-hotspot")