Skip to content

kaocha.repl/run auto-loads :test-paths, but not :source-paths #459

@teodorlu

Description

@teodorlu

Hi!

From my testing, kaocha.repl/run dynamically adds :test-paths to the classpath, but does not load paths from :source-paths.

This leaves me in a bit of a pickle in how I've configured my project. If I'm using Kaocha wrong, please let me know!

Versions

lambdaisland/kaocha {:mvn/version "1.91.1392"}

… on JVM Clojure, Clojure 1.12.0.

Setup

;; deps.edn
{:deps {}
 :aliases
 {:bb {:paths ["bb/src" "bb/test"]
       :extra-deps {babashka/fs {:mvn/version "0.5.25"}}}
  :dev {:extra-deps {lambdaisland/kaocha {:mvn/version "1.91.1392"}}}}}
;; tests.edn
#kaocha/v1
{:tests
 [{:id :unit
   :source-paths ["src"]
   :test-paths ["test"]}
  {:id :bb
   :source-paths ["bb/src"]
   :test-paths ["bb/test"]}]}
$ tree
.
├── bb
│   ├── src
│   │   └── script.clj
│   └── test
│       └── script_test.clj
├── deps.edn
├── README.md
├── src
│   └── repro.clj
├── test
│   └── repro_test.clj
└── tests.edn

6 directories, 7 files

Expected behavior: can run JVM tests from a JVM REPL

From a :dev REPL, I expect to be able to run the tests for a single namespace where the tests are on the classpath,

  (require 'kaocha.repl)
  (kaocha.repl/run 'repro-test)

Observed behavior: kaocha.repl/run crashes because namespace on :source-paths folder has not been loaded

In https://github.com/teodorlu/kaocha-autoload-test-src-paths-repro,

$ clj -A:dev
Clojure 1.12.0
user=> (require 'kaocha.repl)
nil
user=> (kaocha.repl/run 'repro-test)
[E]
Randomized with --seed 767566900

ERROR in bb (ns.clj:9)
Failed loading tests:
Exception: clojure.lang.Compiler$CompilerException: Syntax error macroexpanding at (script_test.clj:1:1).
#:clojure.error{:phase :execution, :line 1, :column 1, :source "script_test.clj"}
 at clojure.lang.Compiler.load (Compiler.java:8177)
    ...
(Rest of stacktrace elided)
Caused by: java.io.FileNotFoundException: Could not locate script__init.class, script.clj or script.cljc on classpath.
 at clojure.lang.RT.load (RT.java:482)
    ...
    script_test$eval4681$loading__6812__auto____4682.invoke (script_test.clj:1)
    script_test$eval4681.invokeStatic (script_test.clj:1)
    script_test$eval4681.invoke (script_test.clj:1)
    ...
(Rest of stacktrace elided)
1 tests, 1 assertions, 1 errors, 0 failures.
#:kaocha.result{:count 1, :pass 0, :error 1, :fail 0, :pending 0}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions