Converts last tests to test namespaces and write libraries.csv

This commit is contained in:
Gabriel Horner 2021-12-27 17:27:57 -05:00
parent 0294923fbc
commit 23699de359
7 changed files with 126 additions and 46 deletions

58
doc/libraries.csv Normal file
View file

@ -0,0 +1,58 @@
maven-name,git-url
aero/aero,http://github.com/juxt/aero
amperity/vault-clj,https://github.com/amperity/vault-clj
babashka/babashka.curl,https://github.com/babashka/babashka.curl
better-cond/better-cond,https://github.com/Engelberg/better-cond
borkdude/deps,https://github.com/borkdude/deps.clj
camel-snake-kebab/camel-snake-kebab,https://github.com/clj-commons/camel-snake-kebab
circleci/bond,https://github.com/circleci/bond
clj-commons/clj-yaml,https://github.com/clj-commons/clj-yaml
clj-commons/multigrep,https://github.com/clj-commons/multigrep
clojure-csv/clojure-csv,https://github.com/davidsantiago/clojure-csv
com.github.seancorfield/honeysql,https://github.com/seancorfield/honeysql
com.grammarly/omniconf,https://github.com/grammarly/omniconf
com.stuartsierra/component,https://github.com/stuartsierra/component
com.stuartsierra/dependency,https://github.com/stuartsierra/dependency
comb/comb,https://github.com/weavejester/comb
cprop/cprop,https://github.com/tolitius/cprop
crispin/crispin,https://github.com/dunaj-project/crispin
doric/doric,https://github.com/joegallo/doric
environ/environ,https://github.com/weavejester/environ
exoscale/coax,https://github.com/exoscale/coax
failjure/failjure,https://github.com/adambard/failjure
gaka/gaka,https://github.com/cdaddr/gaka
hato/hato,https://github.com/gnarroway/hato
henryw374/cljc.java-time,https://github.com/henryw374/cljc.java-time
hiccup/hiccup,http://github.com/weavejester/hiccup
honeysql/honeysql,https://github.com/seancorfield/honeysql
http-kit/http-kit,https://github.com/http-kit/http-kit
io.helins/binf,https://github.com/helins/binf.cljc
io.replikativ/hasch,https://github.com/replikativ/hasch
java-http-clj/java-http-clj,http://www.github.com/schmee/java-http-clj
lambdaisland/regal,https://github.com/lambdaisland/regal
listora/again,https://github.com/liwp/again
markdown-clj/markdown-clj,https://github.com/yogthos/markdown-clj
medley/medley,https://github.com/weavejester/medley
minimallist/minimallist,https://github.com/green-coder/minimallist
mvxcvi/arrangement,https://github.com/greglook/clj-arrangement
orchestra/orchestra,https://github.com/jeaye/orchestra
org.babashka/spec.alpha,https://github.com/babashka/spec.alpha
org.clj-commons/clj-http-lite,https://github.com/clj-commons/clj-http-lite
org.clj-commons/digest,https://github.com/clj-commons/clj-digest
org.clojars.askonomm/ruuter,https://github.com/askonomm/ruuter
org.clojure/core.match,https://github.com/clojure/core.match
org.clojure/data.csv,https://github.com/clojure/data.csv
org.clojure/data.generators,https://github.com/clojure/data.generators
org.clojure/data.json,https://github.com/clojure/data.json
org.clojure/data.zip,https://github.com/clojure/data.zip
org.clojure/math.combinatorics,https://github.com/clojure/math.combinatorics
org.clojure/test.check,https://github.com/clojure/test.check
org.clojure/tools.gitlibs,https://github.com/clojure/tools.gitlibs
org.clojure/tools.namespace,https://github.com/babashka/tools.namespace
reifyhealth/specmonstah,https://github.com/reifyhealth/specmonstah
rewrite-clj/rewrite-clj,https://github.com/clj-commons/rewrite-clj
rm-hull/jasentaa,https://github.com/rm-hull/jasentaa
selmer/selmer,https://github.com/yogthos/Selmer
slingshot/slingshot,https://github.com/scgilardi/slingshot
table/table,https://github.com/cldwalker/table
version-clj/version-clj,https://github.com/xsc/version-clj
1 maven-name git-url
2 aero/aero http://github.com/juxt/aero
3 amperity/vault-clj https://github.com/amperity/vault-clj
4 babashka/babashka.curl https://github.com/babashka/babashka.curl
5 better-cond/better-cond https://github.com/Engelberg/better-cond
6 borkdude/deps https://github.com/borkdude/deps.clj
7 camel-snake-kebab/camel-snake-kebab https://github.com/clj-commons/camel-snake-kebab
8 circleci/bond https://github.com/circleci/bond
9 clj-commons/clj-yaml https://github.com/clj-commons/clj-yaml
10 clj-commons/multigrep https://github.com/clj-commons/multigrep
11 clojure-csv/clojure-csv https://github.com/davidsantiago/clojure-csv
12 com.github.seancorfield/honeysql https://github.com/seancorfield/honeysql
13 com.grammarly/omniconf https://github.com/grammarly/omniconf
14 com.stuartsierra/component https://github.com/stuartsierra/component
15 com.stuartsierra/dependency https://github.com/stuartsierra/dependency
16 comb/comb https://github.com/weavejester/comb
17 cprop/cprop https://github.com/tolitius/cprop
18 crispin/crispin https://github.com/dunaj-project/crispin
19 doric/doric https://github.com/joegallo/doric
20 environ/environ https://github.com/weavejester/environ
21 exoscale/coax https://github.com/exoscale/coax
22 failjure/failjure https://github.com/adambard/failjure
23 gaka/gaka https://github.com/cdaddr/gaka
24 hato/hato https://github.com/gnarroway/hato
25 henryw374/cljc.java-time https://github.com/henryw374/cljc.java-time
26 hiccup/hiccup http://github.com/weavejester/hiccup
27 honeysql/honeysql https://github.com/seancorfield/honeysql
28 http-kit/http-kit https://github.com/http-kit/http-kit
29 io.helins/binf https://github.com/helins/binf.cljc
30 io.replikativ/hasch https://github.com/replikativ/hasch
31 java-http-clj/java-http-clj http://www.github.com/schmee/java-http-clj
32 lambdaisland/regal https://github.com/lambdaisland/regal
33 listora/again https://github.com/liwp/again
34 markdown-clj/markdown-clj https://github.com/yogthos/markdown-clj
35 medley/medley https://github.com/weavejester/medley
36 minimallist/minimallist https://github.com/green-coder/minimallist
37 mvxcvi/arrangement https://github.com/greglook/clj-arrangement
38 orchestra/orchestra https://github.com/jeaye/orchestra
39 org.babashka/spec.alpha https://github.com/babashka/spec.alpha
40 org.clj-commons/clj-http-lite https://github.com/clj-commons/clj-http-lite
41 org.clj-commons/digest https://github.com/clj-commons/clj-digest
42 org.clojars.askonomm/ruuter https://github.com/askonomm/ruuter
43 org.clojure/core.match https://github.com/clojure/core.match
44 org.clojure/data.csv https://github.com/clojure/data.csv
45 org.clojure/data.generators https://github.com/clojure/data.generators
46 org.clojure/data.json https://github.com/clojure/data.json
47 org.clojure/data.zip https://github.com/clojure/data.zip
48 org.clojure/math.combinatorics https://github.com/clojure/math.combinatorics
49 org.clojure/test.check https://github.com/clojure/test.check
50 org.clojure/tools.gitlibs https://github.com/clojure/tools.gitlibs
51 org.clojure/tools.namespace https://github.com/babashka/tools.namespace
52 reifyhealth/specmonstah https://github.com/reifyhealth/specmonstah
53 rewrite-clj/rewrite-clj https://github.com/clj-commons/rewrite-clj
54 rm-hull/jasentaa https://github.com/rm-hull/jasentaa
55 selmer/selmer https://github.com/yogthos/Selmer
56 slingshot/slingshot https://github.com/scgilardi/slingshot
57 table/table https://github.com/cldwalker/table
58 version-clj/version-clj https://github.com/xsc/version-clj

View file

@ -13,10 +13,12 @@
[clojure.edn :as edn]))
(deps/add-deps '{:deps {org.clojure/tools.gitlibs {:mvn/version "2.4.172"}
borkdude/rewrite-edn {:mvn/version "0.1.0"}}})
borkdude/rewrite-edn {:mvn/version "0.1.0"}
org.clojure/data.csv {:mvn/version "1.0.0"}}})
(require '[clojure.tools.gitlibs :as gl])
(require '[borkdude.rewrite-edn :as r])
(require '[clojure.data.csv :as csv])
;; CLI Utils
;; =========
@ -153,6 +155,16 @@
:lib-coordinate (-> deps-map vals first)
:git-url (:git-url options)})))
(defn- write-lib-to-csv
"Updates libraries.csv with latest bb-tested-libs.edn"
[]
(let [libs (-> "test-resources/lib_tests/bb-tested-libs.edn" slurp edn/read-string)
rows (sort-by first
(map (fn [[name {:keys [git-url]}]]
[name git-url]) libs))]
(with-open [w (io/writer "doc/libraries.csv")]
(csv/write-csv w (into [["maven-name" "git-url"]] rows)))))
(defn- add-libtest*
[args options]
(let [[artifact-or-deps-string] args
@ -164,6 +176,7 @@
dirs (when-not (:manually-added options) (copy-tests git-url lib-name options))
namespaces (add-lib-to-tested-libs lib-name git-url dirs options)]
(println "Added lib" lib-name "which tests the following namespaces:" namespaces)
(write-lib-to-csv)
(when (:test options)
(apply shell "script/lib_tests/run_all_libtests" namespaces))))

View file

@ -25,46 +25,13 @@
(str/lower-case)
(str/includes? "win")))
;;;; cprop
;; Standard test-runner for libtests
(let [lib-tests (edn/read-string (slurp (io/resource "bb-tested-libs.edn")))]
(doseq [{tns :test-namespaces skip-windows :skip-windows} (vals lib-tests)]
(when-not (and skip-windows windows?)
(apply test-namespaces tns))))
;; TODO: port to test-namespaces
(require '[cprop.core])
(require '[cprop.source :refer [from-env]])
(println (:cprop-env (from-env)))
;;;; clojure.data.zip
;; TODO: port to test-namespaces
(require '[clojure.data.xml :as xml])
(require '[clojure.zip :as zip])
(require '[clojure.data.zip.xml :refer [attr attr= xml1->]])
(def data (str "<root>"
" <character type=\"person\" name=\"alice\" />"
" <character type=\"animal\" name=\"march hare\" />"
"</root>"))
;; TODO: convert to test
(let [xml (zip/xml-zip (xml/parse (java.io.StringReader. data)))]
;(prn :xml xml)
(prn :alice-is-a (xml1-> xml :character [(attr= :name "alice")] (attr :type)))
(prn :animal-is-called (xml1-> xml :character [(attr= :type "animal")] (attr :name))))
;;;; deps.clj
;; TODO: port to test-namespaces
(require '[babashka.curl :as curl])
(spit "deps_test.clj"
(:body (curl/get "https://raw.githubusercontent.com/borkdude/deps.clj/master/deps.clj"
(if windows? {:compressed false} {}))))
(binding [*command-line-args* ["-Sdescribe"]]
(load-file "deps_test.clj"))
(.delete (io/file "deps_test.clj"))
;; Non-standard tests - These are tests with unusual setup around test-namespaces
;;;; doric
@ -85,11 +52,6 @@
(require '[babashka.process] :reload)
(test-namespaces 'babashka.process-test))
(let [lib-tests (edn/read-string (slurp (io/resource "bb-tested-libs.edn")))]
(doseq [{tns :test-namespaces skip-windows :skip-windows} (vals lib-tests)]
(when-not (and skip-windows windows?)
(apply test-namespaces tns))))
;;;; final exit code
(let [{:keys [:test :fail :error] :as m} @status]

View file

@ -67,4 +67,7 @@
amperity/vault-clj {:git-url "https://github.com/amperity/vault-clj", :test-namespaces [vault.lease-test vault.client.http-test], :manually-added true}
orchestra/orchestra {:git-url "https://github.com/jeaye/orchestra", :test-namespaces (orchestra.make-fns orchestra.many-fns orchestra.expound-test orchestra.core-test orchestra.reload-test), :test-directories ("test/cljc" "test/clj"), :git-sha "81e5181f7b42e5e2763a2b37db17954f3be0314e"}
;; BB-TEST-PATCH: Manually removed tasks.clj
org.clj-commons/clj-http-lite {:git-url "https://github.com/clj-commons/clj-http-lite", :test-namespaces (clj-http.lite.test-runner clj-http.lite.client-test), :test-directories ("bb"), :git-sha "6b53000df55ac05c4ff8e5047a5323fc08a52e8b"}}
org.clj-commons/clj-http-lite {:git-url "https://github.com/clj-commons/clj-http-lite", :test-namespaces (clj-http.lite.test-runner clj-http.lite.client-test), :test-directories ("bb"), :git-sha "6b53000df55ac05c4ff8e5047a5323fc08a52e8b"}
cprop/cprop {:git-url "https://github.com/tolitius/cprop", :test-namespaces [cprop.smoke-test], :manually-added true}
org.clojure/data.zip {:git-url "https://github.com/clojure/data.zip", :test-namespaces [clojure.data.zip-test], :manually-added true}
borkdude/deps {:git-url "https://github.com/borkdude/deps.clj", :test-namespaces [borkdude.deps.smoke-test], :manually-added true}}

View file

@ -0,0 +1,20 @@
(ns borkdude.deps.smoke-test
(:require [clojure.test :as t :refer [deftest is]]
[clojure.java.io :as io]
[clojure.string :as str]
[babashka.curl :as curl]))
(def windows? (-> (System/getProperty "os.name")
(str/lower-case)
(str/includes? "win")))
(deftest basic-test
(spit "deps_test.clj"
(:body (curl/get "https://raw.githubusercontent.com/borkdude/deps.clj/master/deps.clj"
(if windows? {:compressed false} {}))))
(binding [*command-line-args* ["-Sdescribe"]]
(load-file "deps_test.clj"))
(.delete (io/file "deps_test.clj")))

View file

@ -0,0 +1,17 @@
(ns clojure.data.zip-test
(:require [clojure.test :as t :refer [deftest is]]
[clojure.data.xml :as xml]
[clojure.zip :as zip]
[clojure.data.zip.xml :refer [attr attr= xml1->]]))
(def data (str "<root>"
" <character type=\"person\" name=\"alice\" />"
" <character type=\"animal\" name=\"march hare\" />"
"</root>"))
(deftest xml1-test
(let [xml (zip/xml-zip (xml/parse (java.io.StringReader. data)))]
(is (= "person"
(xml1-> xml :character [(attr= :name "alice")] (attr :type))))
(is (= "march hare"
(xml1-> xml :character [(attr= :type "animal")] (attr :name))))))

View file

@ -0,0 +1,7 @@
(ns cprop.smoke-test
(:require [clojure.test :as t :refer [deftest is]]
[cprop.core]
[cprop.source :refer [from-env]]))
(deftest from-env-test
(println (:cprop-env (from-env))))