Description:
Small tweaks to tests.
Commit status:
[Not Reviewed]
References:
Comments:
0 Commit comments 0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
Add another comment

r30:00e4925d221b -

@@ -2,6 +2,7
2 2 (ns project-checkup.core
3 3 (:gen-class)
4 4 (:require [clojure.java.shell :as shell]
5 [clojure.set :as set]
5 6 [clojure.string :as string]))
6 7
7 8 (defn get-extension [path]
@@ -18,16 +19,13
18 19 (string/split (:out (shell/sh "chg" "st" "-u" "-n")) #"\n"))
19 20 (if (contains? vcs-systems ".git")
20 21 (string/split (:out (shell/sh "git" "ls-files" "--others"
21 "--exclude-standard")) #"\n"))]))
22 "--exclude-standard")) #"\n"))]))
22 23 (defn gather-project-info
23 24 "Creates a dictionary of project information."
24 25 []
25 26 (let [all-files (map str (file-seq (clojure.java.io/file ".")))
26 27 files (map #(clojure.string/replace % #"./(.*)" "$1") all-files )
27 ; file-set (set files)
28 ;note that using some here means that if both are present, hg is
29 ;ignored:
30 vcs-systems (set (vector (some #{".git" ".hg"} files))) ]
28 vcs-systems (set/intersection #{".git" ".hg"} (set files))]
31 29 {:files files
32 30 :extensions (frequencies (map get-extension files ))
33 31 :path (System/getProperty "user.dir")
@@ -109,7 +107,7
109 107 :function check-readme-placeholders
110 108 :description "No placeholders in README"
111 109 :level :error
112 :follow-up "Address placeholders or convert them to tasks."}
110 :follow-up "Address placeholders or convert them to tasks."}
113 111 { :name "Project has a license"
114 112 :function check-license
115 113 :description "Project has a LICENSE file."
@@ -143,7 +141,7
143 141 (let [project-info (gather-project-info)]
144 142 (doseq [check checks]
145 143 (println (:output (perform-check check project-info )))))
146 (catch Exception ex
144 (catch Exception ex ; Not expecting there to be a lot of exceptions, hence the catch-all.
147 145 (.printStackTrace ex)
148 146 (str "caught exception: " (.getMessage ex)))
149 147 (finally (shutdown-agents))))
@@ -2,38 +2,36
2 2 (:require [clojure.test :refer :all]
3 3 [project-checkup.core :refer :all]))
4 4
5
6
7 5 (deftest test-check-vcs
8 6 (testing "Ensure the check works."
9 7 (is
10 8 (check-vcs {:files [".git"]}) )
11 9 (is
12 10 (check-vcs {:files [".hg"]}) )
11 (is
12 (check-vcs {:files [".hg" ".git"]}) ))
13 (testing "Ensure no false positives."
13 14 (is
14 15 (not (check-vcs {:files []})) )
15 16 (is ;various almost-correct entries
16 17 (not (check-vcs {:files ["hg" "git" "."]})) )))
17 18
18
19 19 (deftest test-check-readme
20 20 (testing "Ensure READMEs are found correctly."
21 21 (is
22 22 (check-readme {:files ["README.md"]})))
23 (testing "Ensure no false positives"
24 (is
25 (not (check-readme {:files ["readme.exe"]})))
23 (testing "Ensure no false positives"
24 (is
25 (not (check-readme {:files ["readme.exe"]})))
26 26 (is
27 27 (not (check-readme {:files []})))))
28 28
29 29 (deftest test-check-untracked
30 30 (testing "Ensure empty returns true"
31 (is (check-untracked {:untracked-files []}))
32 )
31 (is (check-untracked {:untracked-files []})))
33 32 (testing "Ensure non-empty returns false"
34 33 (is (not (check-untracked {:untracked-files [".hg"]})))))
35 34
36
37 35 (deftest test-check-license
38 36 (testing "Ensure license is counted"
39 37 (is (check-license {:files ["LICENSE.mkd"]}))
You need to be logged in to leave comments. Login now