Skip to content

Commit 7e5c8f8

Browse files
committed
Remove Midje. Use Clojure unit testing framework.
1 parent 65eed3c commit 7e5c8f8

File tree

5 files changed

+45
-52
lines changed

5 files changed

+45
-52
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ addons:
44
packages:
55
- graphviz
66
language: clojure
7-
script: lein with-profile dev midje && lein uberjar
7+
script: lein do clean, test, uberjar
88
jdk:
99
- oraclejdk7
1010
- oraclejdk8

project.clj

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,6 @@
1010

1111
:profiles {
1212

13-
:dev {:dependencies [[midje "1.8.2" :exclusions [org.clojure/clojure joda-time]]
14-
[joda-time "2.9.1"]]
15-
:plugins [[lein-midje "3.2"]]}
16-
1713
:prod {:plugins [[lein-release "1.0.6" :exclusions [org.clojure/clojure]]]
1814
:global-vars {*warn-on-reflection* true}
1915
:scm {:name "git"
@@ -25,4 +21,5 @@
2521
:checksum :warn
2622
:pedantic? :abort
2723
:eval-in-leiningen true
28-
:local-repo-classpath true)
24+
:local-repo-classpath true
25+
:warn-on-reflection false)

src/lein_plantuml/core.clj

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@
1212
[clojure.string :as string]))
1313

1414

15-
; Internal API: Constants
15+
; External API: Constants
1616

17-
(def ^:private DEF_SOURCES "src/plantuml/*.puml")
18-
(def ^:private DEF_FILE_FORMAT :png)
17+
(def ^:public DEF_SOURCES "src/plantuml/*.puml")
18+
(def ^:public DEF_FILE_FORMAT :png)
1919

20-
(def ^:private FILE_FORMAT
20+
(def ^:public FILE_FORMAT
2121
{:eps FileFormat/EPS
2222
:eps:txt FileFormat/EPS_TEXT
2323
:png FileFormat/PNG
@@ -48,16 +48,16 @@
4848
(string/replace p "\\" "/"))))
4949

5050

51-
; Internal API: Configurations
51+
; External API: Configurations
5252

53-
(defn- file-format [k]
53+
(defn file-format [k]
5454
(let [fmt (when-not (nil? k)
5555
(keyword (string/lower-case (name k))))
5656
f (get FILE_FORMAT fmt)]
5757
(if (nil? f) (log "Bad file format: " k))
5858
f))
5959

60-
(defn- read-configs [project & args]
60+
(defn read-configs [project & args]
6161
(let [includes (or (when-not (nil? project) (:plantuml project)) [])
6262
sources (concat includes (vec args))]
6363
(remove empty? sources)))
@@ -74,7 +74,10 @@
7474
charset nil]
7575
(SourceFileReader. defines in out config charset fmt)))
7676

77-
(defn- process-file [in out fmt]
77+
78+
; External API: Renderer
79+
80+
(defn process-file [in out fmt]
7881
(try
7982
(let [reader (create-reader in out fmt)
8083
images (.getGeneratedImages reader)]
@@ -85,7 +88,7 @@
8588
(log "Can not render file " in " with file format " fmt)
8689
false)))
8790

88-
(defn- process-config [config]
91+
(defn process-config [config]
8992
(let [inputs (fs/glob (clean-path (nth config 0 DEF_SOURCES)))
9093
fmt (file-format (nth config 1 DEF_FILE_FORMAT))
9194
output (nth config 2 nil)]

src/lein_plantuml/plugin.clj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
(ns ^{:author "Vladislav Bauer"}
22
lein-plantuml.plugin
3-
(:require [leiningen.compile :as lcomp]
3+
(:require [leiningen.compile]
44
[lein-plantuml.core :as core]
55
[robert.hooke :as hooke]))
66

test/lein_plantuml/t_core.clj

Lines changed: 29 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,75 +1,68 @@
11
(ns ^{:author "Vladislav Bauer"}
22
lein-plantuml.t-core
33
(:import (net.sourceforge.plantuml FileFormat))
4-
(:use [midje.sweet :only [fact]]
5-
[midje.util :only [testable-privates]]
6-
[clojure.java.io :only [as-file]])
7-
(:require [lein-plantuml.core :as core]
8-
[me.raynes.fs :as fs]))
4+
(:use [clojure.java.io :only [as-file]]
5+
[clojure.test :only [deftest is]])
6+
(:require [me.raynes.fs :as fs]
7+
[lein-plantuml.core :as core]))
98

109

1110
; Configurations
1211

1312
(def ^:private DEF_OUTPUT "test-out")
1413

15-
(testable-privates
16-
lein-plantuml.core
17-
file-format
18-
read-configs
19-
process-file
20-
FILE_FORMAT)
21-
2214

2315
; Helper functions
2416

2517
(defn- clear-output[]
2618
(fs/delete-dir DEF_OUTPUT))
2719

2820
(defn- check-formats [& names]
29-
(let [formats (distinct (map file-format names))
21+
(let [formats (distinct (map core/file-format names))
3022
eq (= 1 (count formats))]
3123
(if eq
3224
(first formats)
3325
(throw (Exception. "Incorrect file-format function")))))
3426

3527
(defn- check-process
3628
([u] (let [file (str "example/doc/" u)
37-
formats (vals (var-get FILE_FORMAT))]
29+
formats (vals core/FILE_FORMAT)]
3830
(every? #(check-process file %) formats)))
3931
([u f] (try
4032
(do
4133
(clear-output)
42-
(process-file u DEF_OUTPUT f))
34+
(core/process-file u DEF_OUTPUT f))
4335
(finally (clear-output)))))
4436

4537

4638
; Tests
4739

48-
(fact "Check available file formats"
49-
(check-formats nil :none) => nil
50-
(check-formats :eps :EPS "eps" "EPS") => FileFormat/EPS
51-
(check-formats :eps:txt "eps:txt") => FileFormat/EPS_TEXT
52-
(check-formats :png "png") => FileFormat/PNG
53-
(check-formats :txt "txt") => FileFormat/ATXT
54-
(check-formats :utxt "utxt") => FileFormat/UTXT
55-
(check-formats :svg "SVG") => FileFormat/SVG
40+
(deftest check-available-file-formats
41+
(is (= (check-formats nil :none) nil))
42+
(is (= (check-formats :eps :EPS "eps" "EPS") FileFormat/EPS))
43+
(is (= (check-formats :eps:txt "eps:txt") FileFormat/EPS_TEXT))
44+
(is (= (check-formats :png "png") FileFormat/PNG))
45+
(is (= (check-formats :txt "txt") FileFormat/ATXT))
46+
(is (= (check-formats :utxt "utxt") FileFormat/UTXT))
47+
(is (= (check-formats :svg "SVG") FileFormat/SVG))
5648
; TODO: The following formats are very unstable:
5749
;(check-formats :pdf) => FileFormat/PDF
5850
;(check-formats :html) => FileFormat/HTML
5951
;(check-formats :html5) => FileFormat/HTML5
6052
)
6153

62-
(fact "Check source list"
63-
(empty? (read-configs nil)) => true
64-
(empty? (read-configs {})) => true
65-
(empty? (read-configs {:plantuml []})) => true
66-
(empty? (read-configs {:plantuml ["test.uml"]})) => false
67-
(empty? (read-configs {} "test.uml")) => false
68-
(empty? (read-configs {} ["test.uml"])) => false
69-
(empty? (read-configs {:plantuml ["test.uml"]} ["test.uml"])) => false)
54+
(deftest check-source-list
55+
(let [read-conf core/read-configs]
56+
(is (= (empty? (read-conf nil)) true))
57+
(is (= (empty? (read-conf {})) true))
58+
(is (= (empty? (read-conf {:plantuml []})) true))
59+
(is (= (empty? (read-conf {:plantuml ["test.uml"]})) false))
60+
(is (= (empty? (read-conf {} "test.uml")) false))
61+
(is (= (empty? (read-conf {} ["test.uml"])) false))
62+
(is (= (empty? (read-conf {:plantuml ["test.uml"]} ["test.uml"])) false))))
7063

71-
(fact "Check PlantUML processor"
72-
(check-process "example-01.puml") => true
73-
(check-process "example-02.puml") => true
74-
(check-process "example-03.puml") => true
75-
(check-process "example-04.puml") => true)
64+
(deftest check-plantuml-processor
65+
(is (= (check-process "example-01.puml") true))
66+
(is (= (check-process "example-02.puml") true))
67+
(is (= (check-process "example-03.puml") true))
68+
(is (= (check-process "example-04.puml") true)))

0 commit comments

Comments
 (0)