lambdaisland / lambdaisland/kaocha

Prevent loading of namespaces that are skipped

Open
#145 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Via @borkdude on Clojurians Slack

When using kaocha, is there an equivalent to -n from the cognitect test runner or :only from leiningen, from the command line?
nm, got it: https://cljdoc.org/d/lambdaisland/kaocha/1.0.632/doc/6-focusing-and-skipping#on-a-namespace
I'm trying to port this:

clojure -A:test -n babashka.pods.jvm-test
;;=>
clojure -A:test:kaocha --focus babashka.pods.jvm-testclojure -A:sci:test -n babashka.pods.sci-test
;;=>
clojure -A:sci:test:kaocha --focus babashka.pods.sci-test

This one:

clojure -A:test:kaocha --focus babashka.pods.jvm-test

doesn't work, since the sci library is (deliberately!) not available on the classpath. The code should run without the library, which is part of my test.
With the Cognitest test runner or leiningen that works, but with kaocha it doesn't:

$ clojure -A:test:kaocha --focus babashka.pods.jvm-test
WARNING: :focus [:babashka.pods.jvm-test] did not match any tests.
[E]
Randomized with --seed 2027872620ERROR in unit (babashka/pods/sci.clj:1)
Exception: clojure.lang.Compiler$CompilerException: Syntax error compiling at (babashka/pods/sci.clj:1:1).
#:clojure.error{:phase :compile-syntax-check, :line 1, :column 1, :source "babashka/pods/sci.clj"}

So my proposal would be that focus should not load files other than it needs.

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 by tracing Kaocha's command-line --focus handling and the test namespace discovery/loading path; the issue provides the babashka.pods.jvm-test command as a reproduction. Run that focused command with the optional sci namespace unavailable, and consider the work done when skipped namespaces are not loaded and the focused test runs successfully.

Written by the indexing model from the issue text.

Assessment

Tech stack
clojure
Domain
cli, testing
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.