rosado / cloak

simple automation tool inspired by rake, written in Clojure

cloak / tests / basic.clj
100644 45 lines (30 sloc) 1.033 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
(ns rosado.cloak.test.basic
  (:use clojure.contrib.test-is)
  (:require [rosado.cloak :as cloak]))
 
 
;; testing command line parsing
 
(defn opt-f []
  (cloak/parse-arg ["-f"]))
 
(defn opt-t-h []
  (cloak/parse-arg ["-t" "-h"]))
 
(defn opt-h-t []
  (cloak/parse-arg ["-h" "-t"]))
 
(defn opt-h-word []
  (cloak/parse-arg ["-h" "some-word"]))
 
(deftest cmdline-opts
  (is (thrown? Exception (opt-f)))
  (is (thrown? Exception (opt-t-h)))
  (is (thrown? Exception (opt-h-t)))
  (is (thrown? Exception (opt-h-word))))
 
(deftest simple-task
  (is (= nil (cloak/parse-arg ["a"])))
  (is (thrown? Exception (cloak/parse-arg ["nonexisiting-task"]))))
 
(deftest circular-dep-task
  (is (thrown? Exception (cloak/parse-arg ["-f" "CIRCULAR" "a"])))
  (is (thrown? Exception (cloak/parse-arg ["-f" "CIRCULAR" "b"]))))
 
(cloak/parse-arg ["-f" "ONCE" "a"])
 
(deftest run-only-once
  (is (= 1 @cloak.tests.once/*counter-a*)))
 
(cloak/parse-arg ["-f" "ONCE" "b" "b"])
 
(deftest run-only-once
  (is (= 1 @cloak.tests.once/*counter-b*)))
 
(run-tests)