diff --git a/.editorconfig b/.editorconfig index 8dc73cc..bbbde86 100644 --- a/.editorconfig +++ b/.editorconfig @@ -9,9 +9,9 @@ insert_final_newline = true trim_trailing_whitespace = true charset = utf-8 indent_style = space -indent_size = 4 +indent_size = 2 # Clojure dialect settings [*.{clj,cljc,cljs}] indent_style = space -indent_size = 2 \ No newline at end of file +indent_size = 2 diff --git a/jovial-engine-clojure.test/build.gradle b/jovial-engine-clojure.test/build.gradle index b2c35a6..86d0109 100644 --- a/jovial-engine-clojure.test/build.gradle +++ b/jovial-engine-clojure.test/build.gradle @@ -4,14 +4,15 @@ plugins { } dependencies { - compile 'org.junit.platform:junit-platform-engine:1.0.0-M1' + compile 'org.junit.platform:junit-platform-engine:1.1.0' compile 'org.clojure:clojure:1.9.0' compile project(':jovial-lang-clojure') testCompile 'junit:junit:4.12' - testCompile 'org.junit.platform:junit-platform-launcher:1.0.0-M1' + testCompile 'org.junit.platform:junit-platform-launcher:1.1.0' } test { - systemProperty "classpath.roots", classpath.asPath + classpath += files('src/test/samples') + systemProperty "classpath.roots", file('src/test/samples') } diff --git a/jovial-engine-clojure.test/src/main/java/org/ajoberstar/jovial/engine/clojure_test/ClojureNamespaceDescriptor.java b/jovial-engine-clojure.test/src/main/java/org/ajoberstar/jovial/engine/clojure_test/ClojureNamespaceDescriptor.java index 2484310..ea810f8 100644 --- a/jovial-engine-clojure.test/src/main/java/org/ajoberstar/jovial/engine/clojure_test/ClojureNamespaceDescriptor.java +++ b/jovial-engine-clojure.test/src/main/java/org/ajoberstar/jovial/engine/clojure_test/ClojureNamespaceDescriptor.java @@ -18,6 +18,7 @@ import clojure.lang.Namespace; import java.util.Set; import org.ajoberstar.jovial.lang.clojure.util.SimpleClojure; +import org.junit.platform.engine.TestDescriptor.Type; import org.junit.platform.engine.TestTag; import org.junit.platform.engine.UniqueId; import org.junit.platform.engine.support.descriptor.AbstractTestDescriptor; @@ -27,10 +28,12 @@ public class ClojureNamespaceDescriptor extends AbstractTestDescriptor { private final Set tags; public ClojureNamespaceDescriptor(UniqueId id, Namespace ns) { - super(id, ns.toString()); + super( + id, + ns.toString(), + SimpleClojure.invoke("org.ajoberstar.jovial.lang.clojure", "ns-source", ns)); this.ns = ns; this.tags = SimpleClojure.invoke("org.ajoberstar.jovial.lang.clojure", "tags", ns); - setSource(SimpleClojure.invoke("org.ajoberstar.jovial.lang.clojure", "ns-source", ns)); } public Namespace getNamespace() { @@ -38,13 +41,8 @@ public Namespace getNamespace() { } @Override - public boolean isContainer() { - return true; - } - - @Override - public boolean isTest() { - return false; + public Type getType() { + return Type.CONTAINER; } @Override diff --git a/jovial-engine-clojure.test/src/main/java/org/ajoberstar/jovial/engine/clojure_test/ClojureVarDescriptor.java b/jovial-engine-clojure.test/src/main/java/org/ajoberstar/jovial/engine/clojure_test/ClojureVarDescriptor.java index f6a04c0..ad28dfe 100644 --- a/jovial-engine-clojure.test/src/main/java/org/ajoberstar/jovial/engine/clojure_test/ClojureVarDescriptor.java +++ b/jovial-engine-clojure.test/src/main/java/org/ajoberstar/jovial/engine/clojure_test/ClojureVarDescriptor.java @@ -19,19 +19,22 @@ import clojure.lang.Var; import java.util.Set; import org.ajoberstar.jovial.lang.clojure.util.SimpleClojure; +import org.junit.platform.engine.TestDescriptor.Type; import org.junit.platform.engine.TestTag; import org.junit.platform.engine.UniqueId; import org.junit.platform.engine.support.descriptor.AbstractTestDescriptor; -public class ClojureVarDescriptor extends AbstractTestDescriptor { +public final class ClojureVarDescriptor extends AbstractTestDescriptor { private final Var var; private final Set tags; public ClojureVarDescriptor(UniqueId id, Var var) { - super(id, var.sym.getName()); + super( + id, + var.sym.getName(), + SimpleClojure.invoke("org.ajoberstar.jovial.lang.clojure", "var-source", var)); this.var = var; this.tags = SimpleClojure.invoke("org.ajoberstar.jovial.lang.clojure", "tags", var); - setSource(SimpleClojure.invoke("org.ajoberstar.jovial.lang.clojure", "var-source", var)); } public Var getVar() { @@ -43,13 +46,8 @@ public Namespace getNamespace() { } @Override - public boolean isContainer() { - return false; - } - - @Override - public boolean isTest() { - return true; + public Type getType() { + return Type.TEST; } @Override diff --git a/jovial-engine-clojure.test/src/test/java/org/ajoberstar/jovial/engine/clojure_test/ClojureTestEngineTest.java b/jovial-engine-clojure.test/src/test/java/org/ajoberstar/jovial/engine/clojure_test/ClojureTestEngineTest.java index dada764..ba5b359 100644 --- a/jovial-engine-clojure.test/src/test/java/org/ajoberstar/jovial/engine/clojure_test/ClojureTestEngineTest.java +++ b/jovial-engine-clojure.test/src/test/java/org/ajoberstar/jovial/engine/clojure_test/ClojureTestEngineTest.java @@ -23,6 +23,8 @@ import static org.junit.platform.engine.discovery.DiscoverySelectors.selectUniqueId; import java.io.File; +import java.nio.file.Path; +import java.nio.file.Paths; import java.util.Arrays; import java.util.HashMap; import java.util.List; @@ -40,9 +42,9 @@ public class ClojureTestEngineTest { @Test public void selectingByClasspathDir() { - Set roots = + Set roots = Arrays.stream(System.getProperty("classpath.roots").split(File.pathSeparator)) - .map(File::new) + .map(Paths::get) .collect(Collectors.toSet()); EngineDiscoveryRequest request = @@ -63,7 +65,7 @@ public void selectingByClasspathDir() { TestDescriptor descriptor = new ClojureTestEngine().discover(request, root); List actualIds = descriptor - .getAllDescendants() + .getDescendants() .stream() .map(TestDescriptor::getUniqueId) .collect(Collectors.toList()); @@ -90,7 +92,7 @@ public void selectingByNamespace() { TestDescriptor descriptor = new ClojureTestEngine().discover(request, root); List actualIds = descriptor - .getAllDescendants() + .getDescendants() .stream() .map(TestDescriptor::getUniqueId) .collect(Collectors.toList()); @@ -115,7 +117,7 @@ public void selectingByVar() { TestDescriptor descriptor = new ClojureTestEngine().discover(request, root); List actualIds = descriptor - .getAllDescendants() + .getDescendants() .stream() .map(TestDescriptor::getUniqueId) .collect(Collectors.toList()); @@ -144,7 +146,7 @@ public void selectingTestByUniqueId() { TestDescriptor descriptor = new ClojureTestEngine().discover(request, root); List actualIds = descriptor - .getAllDescendants() + .getDescendants() .stream() .map(TestDescriptor::getUniqueId) .collect(Collectors.toList()); @@ -173,7 +175,7 @@ public void selectingContainerByUniqueId() { TestDescriptor descriptor = new ClojureTestEngine().discover(request, root); List actualIds = descriptor - .getAllDescendants() + .getDescendants() .stream() .map(TestDescriptor::getUniqueId) .collect(Collectors.toList()); @@ -183,9 +185,9 @@ public void selectingContainerByUniqueId() { @Test public void filteringByNamespace() { - Set roots = + Set roots = Arrays.stream(System.getProperty("classpath.roots").split(File.pathSeparator)) - .map(File::new) + .map(Paths::get) .collect(Collectors.toSet()); EngineDiscoveryRequest request = @@ -206,7 +208,7 @@ public void filteringByNamespace() { TestDescriptor descriptor = new ClojureTestEngine().discover(request, root); List actualIds = descriptor - .getAllDescendants() + .getDescendants() .stream() .map(TestDescriptor::getUniqueId) .collect(Collectors.toList()); @@ -216,9 +218,9 @@ public void filteringByNamespace() { @Test public void getsTagsFromMetadata() { - Set roots = + Set roots = Arrays.stream(System.getProperty("classpath.roots").split(File.pathSeparator)) - .map(File::new) + .map(Paths::get) .collect(Collectors.toSet()); EngineDiscoveryRequest request = @@ -245,7 +247,7 @@ public void getsTagsFromMetadata() { TestDescriptor descriptor = new ClojureTestEngine().discover(request, root); Map> actualTags = descriptor - .getAllDescendants() + .getDescendants() .stream() .collect(Collectors.toMap(TestDescriptor::getUniqueId, TestDescriptor::getTags)); diff --git a/jovial-engine-clojure.test/src/test/resources/sample/core_test.clj b/jovial-engine-clojure.test/src/test/samples/sample/core_test.clj similarity index 100% rename from jovial-engine-clojure.test/src/test/resources/sample/core_test.clj rename to jovial-engine-clojure.test/src/test/samples/sample/core_test.clj diff --git a/jovial-engine-clojure.test/src/test/resources/sample/other_test.clj b/jovial-engine-clojure.test/src/test/samples/sample/other_test.clj similarity index 100% rename from jovial-engine-clojure.test/src/test/resources/sample/other_test.clj rename to jovial-engine-clojure.test/src/test/samples/sample/other_test.clj diff --git a/jovial-lang-clojure/build.gradle b/jovial-lang-clojure/build.gradle index dfd7927..cf30a1a 100644 --- a/jovial-lang-clojure/build.gradle +++ b/jovial-lang-clojure/build.gradle @@ -4,7 +4,7 @@ plugins { } dependencies { - compile 'org.junit.platform:junit-platform-engine:1.0.0-M1' + compile 'org.junit.platform:junit-platform-engine:1.1.0' compile 'org.clojure:clojure:1.9.0' compile 'org.clojure:tools.namespace:0.2.11' diff --git a/jovial-lang-clojure/src/main/clojure/org/ajoberstar/jovial/lang/clojure.clj b/jovial-lang-clojure/src/main/clojure/org/ajoberstar/jovial/lang/clojure.clj index 8d97eed..ab3bb14 100644 --- a/jovial-lang-clojure/src/main/clojure/org/ajoberstar/jovial/lang/clojure.clj +++ b/jovial-lang-clojure/src/main/clojure/org/ajoberstar/jovial/lang/clojure.clj @@ -47,11 +47,11 @@ (defn var-source [var] (let [{:keys [ns name file line column]} (meta var) - file-pos (if (and line column) (FilePosition. line column)) - file (if file (FileSource. (io/file *root-dir* file) file-pos)) + file-pos (if (and line column) (FilePosition/from line column)) + file (if file (FileSource/from (io/file *root-dir* file) file-pos)) var (->ClojureVarSource (str ns) (str name))] (if file - (CompositeTestSource. [var file]) + (CompositeTestSource/from [var file]) var))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; diff --git a/jovial-lang-clojure/src/main/clojure/org/ajoberstar/jovial/lang/clojure/impl/discovery.clj b/jovial-lang-clojure/src/main/clojure/org/ajoberstar/jovial/lang/clojure/impl/discovery.clj index 174b363..785acbc 100644 --- a/jovial-lang-clojure/src/main/clojure/org/ajoberstar/jovial/lang/clojure/impl/discovery.clj +++ b/jovial-lang-clojure/src/main/clojure/org/ajoberstar/jovial/lang/clojure/impl/discovery.clj @@ -5,10 +5,11 @@ [clojure.string :as str]) (:import (clojure.lang Var Namespace) (java.io File) - (java.nio.file Path) + (java.nio.file Path Paths) + (java.net URI) (org.ajoberstar.jovial.lang.clojure VarSelector NamespaceSelector NamespaceFilter) (org.junit.platform.engine UniqueId EngineDiscoveryRequest Filter DiscoverySelector) - (org.junit.platform.engine.discovery UniqueIdSelector ClasspathSelector ClassSelector))) + (org.junit.platform.engine.discovery UniqueIdSelector ClasspathRootSelector ClassSelector))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Selecting candidates for discovery @@ -37,6 +38,8 @@ (->> [dir] find-namespaces (map sym->ns) (mapcat -select))))) Path (-select [dir] (-select (.toFile dir))) + URI + (-select [uri] (-select (Paths/get uri))) Class (-select [clazz] (let [clazz-name (.getCanonicalName clazz) @@ -56,12 +59,11 @@ (-select [selector] (-select (.getNamespace selector))) UniqueIdSelector (-select [selector] (-select (.getUniqueId selector))) - ClasspathSelector + ClasspathRootSelector (-select [selector] (-select (.getClasspathRoot selector))) ClassSelector (-select [selector] (-select (.getJavaClass selector)))) - (defn select [^EngineDiscoveryRequest request] (mapcat -select (.getSelectorsByType request DiscoverySelector))) @@ -69,7 +71,7 @@ ;; Filtering candidates for discovery ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defn- ns-filter [request candidates] - (let [filters (.getDiscoveryFiltersByType request NamespaceFilter) + (let [filters (.getFiltersByType request NamespaceFilter) unified (Filter/composeFilters filters) included? (fn [cand] (->> cand :namespace (.apply unified) .included))] (clojure.core/filter included? candidates)))