lambdaisland / lambdaisland/kaocha

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

Open
#459 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Clojure
Stars
860
Forks
81
PR merge metrics
No merged PRs in 30d

Description

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}

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at kaocha.repl/run and reproduce the failure with the provided deps.edn, tests.edn, and project tree. Compare how :test-paths and :source-paths are handled, then verify that running (kaocha.repl/run 'repro-test) can load script.clj from bb/src without the observed FileNotFoundException.

Written by the indexing model from the issue text.

Assessment

Tech stack
clojure
Domain
testing, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.