diff --git a/deps.edn b/deps.edn index 1fe4a55..09b914b 100644 --- a/deps.edn +++ b/deps.edn @@ -31,4 +31,8 @@ :build {:deps {io.github.seancorfield/build-clj {:git/tag "v0.6.3" :git/sha "9b8e09b"}} - :ns-default build}}} + :ns-default build} + + :gen-test-suite {:extra-deps {org.clojure/data.csv {:mvn/version "1.0.0"}} + :extra-paths ["test" "test/resources"] + :exec-fn csv2rdf.w3c-csvw-suite-test.gen/write-tests-file}}} diff --git a/doc/developing.md b/doc/developing.md index ba5d271..300e91e 100644 --- a/doc/developing.md +++ b/doc/developing.md @@ -31,6 +31,14 @@ To run the tests: $ clojure -T:build test ``` +`csv2rdf` in addition to its own tests, also includes an extensive +test suite generated from the official W3C CSV Working Group test +suite. Tests generated by this command will be run by the above command. + +To rebuild this suite you can run the command: + +`clojure -X:gen-test-suite` + To build the command line application as an uberjar: ``` diff --git a/test/csv2rdf/examples_test.clj b/test/csv2rdf/examples_test.clj index 2ae0307..6fd106b 100644 --- a/test/csv2rdf/examples_test.clj +++ b/test/csv2rdf/examples_test.clj @@ -1,7 +1,7 @@ (ns csv2rdf.examples-test (:require [clojure.test :as t] [clojure.java.io :as io] - [csv2rdf.csvw-test.impl :as impl])) + [csv2rdf.w3c-csvw-suite-test.impl :as impl])) ;; See issue 47 ;; Resolving template property URIs with values containing spaces should work diff --git a/test/csv2rdf/csvw_test.clj b/test/csv2rdf/w3c_csvw_suite_test.clj similarity index 99% rename from test/csv2rdf/csvw_test.clj rename to test/csv2rdf/w3c_csvw_suite_test.clj index 033e48a..a1f7b9c 100644 --- a/test/csv2rdf/csvw_test.clj +++ b/test/csv2rdf/w3c_csvw_suite_test.clj @@ -1,12 +1,17 @@ -(ns csv2rdf.csvw-test - (:require [clojure.test :refer :all] +(ns csv2rdf.w3c-csvw-suite-test + "WARNING THIS FILE IS GENERATED DO NOT EDIT BY HAND. + + Generated test cases from the official W3C CSV Working Group's + test suite. + + See csv2rdf.csvw-test.gen/write-tests-file for more details" + (:require [clojure.test :refer [deftest is]] [clojure.java.io :as io] - [csv2rdf.csvw-test.impl :refer :all] + [csv2rdf.w3c-csvw-suite-test.impl :refer [is-isomorphic? test-csv->rdf]] [csv2rdf.test-common :refer [->TestHttpClient]] - [csv2rdf.csvw :as csvw] [csv2rdf.http :as http] [grafter-2.rdf4j.io :as gio]) - (:import [java.net URI URL])) + (:import [java.net URI])) (deftest ^ diff --git a/test/csv2rdf/csvw_test/gen.clj b/test/csv2rdf/w3c_csvw_suite_test/gen.clj similarity index 93% rename from test/csv2rdf/csvw_test/gen.clj rename to test/csv2rdf/w3c_csvw_suite_test/gen.clj index 747d7b1..001a127 100644 --- a/test/csv2rdf/csvw_test/gen.clj +++ b/test/csv2rdf/w3c_csvw_suite_test/gen.clj @@ -1,9 +1,11 @@ -(ns csv2rdf.csvw-test.gen +(ns csv2rdf.w3c-csvw-suite-test.gen (:require [clojure.data.csv :as csv] [clojure.java.io :as io] [clojure.string :as string] - [csv2rdf.http :as http] - [csv2rdf.csvw-test.impl :refer :all] + #_:clj-kondo/ignore [csv2rdf.http :as http] + #_:clj-kondo/ignore [csv2rdf.w3c-csvw-suite-test.impl + :refer + [is-isomorphic? test-csv->rdf]] [clojure.pprint :as pp]) (:import [java.io File] [java.net URI URL])) @@ -264,18 +266,23 @@ `(~'is (~'= 0 (~'count ~'errors)) "Received errors but none was expected")))))) (def ns-decl - '(ns csv2rdf.csvw-test - (:require [clojure.test :refer :all] + '(ns csv2rdf.w3c-csvw-suite-test + "WARNING THIS FILE IS GENERATED DO NOT EDIT BY HAND. + + Generated test cases from the official W3C CSV Working Group's + test suite. + + See csv2rdf.csvw-test.gen/write-tests-file for more details" + (:require [clojure.test :refer [deftest is]] [clojure.java.io :as io] - [csv2rdf.csvw-test.impl :refer :all] + [csv2rdf.w3c-csvw-suite-test.impl :refer [is-isomorphic? test-csv->rdf]] [csv2rdf.test-common :refer [->TestHttpClient]] - [csv2rdf.csvw :as csvw] [csv2rdf.http :as http] [grafter-2.rdf4j.io :as gio]) - (:import [java.net URI URL]))) + (:import [java.net URI]))) -(defn write-tests-file [] - (with-open [writer (io/writer (io/file "test/csv2rdf/csvw_test.clj"))] +(defn write-tests-file [{:keys [test-file] :or {test-file "test/csv2rdf/w3c_csvw_suite_test.clj"}}] + (with-open [writer (io/writer (io/file test-file))] (binding [pp/*print-right-margin* 120 pp/*print-pprint-dispatch* pp/code-dispatch] (pp/pprint ns-decl writer) diff --git a/test/csv2rdf/csvw_test/impl.clj b/test/csv2rdf/w3c_csvw_suite_test/impl.clj similarity index 92% rename from test/csv2rdf/csvw_test/impl.clj rename to test/csv2rdf/w3c_csvw_suite_test/impl.clj index d60d272..fea4f4c 100644 --- a/test/csv2rdf/csvw_test/impl.clj +++ b/test/csv2rdf/w3c_csvw_suite_test/impl.clj @@ -1,5 +1,5 @@ -(ns csv2rdf.csvw-test.impl - (:require [grafter-2.rdf4j.io :as gio] +(ns csv2rdf.w3c-csvw-suite-test.impl + (:require [grafter-2.rdf4j.io :as gio] [grafter-2.rdf4j.repository :as repo] [csv2rdf.logging :as logging] [csv2rdf.csvw :refer [csv->rdf->destination]])