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