This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-11-16
Channels
- # announcements (62)
- # babashka (12)
- # babashka-sci-dev (73)
- # beginners (16)
- # biff (10)
- # calva (65)
- # cider (13)
- # clerk (8)
- # clojure (31)
- # clojure-europe (16)
- # clojure-nl (1)
- # clojure-norway (19)
- # clojure-spec (24)
- # clojure-uk (5)
- # clojuredesign-podcast (18)
- # clojurescript (18)
- # dev-tooling (2)
- # emacs (30)
- # etaoin (4)
- # gratitude (3)
- # hyperfiddle (20)
- # integrant (2)
- # jobs (4)
- # kaocha (7)
- # malli (1)
- # observability (11)
- # off-topic (11)
- # pathom (12)
- # podcasts-discuss (7)
- # portal (12)
- # quil (3)
- # re-frame (6)
- # releases (1)
- # sql (22)
- # squint (5)
- # testing (79)
- # tools-deps (3)
- # xtdb (20)
Hello! May you can help me... I'm not succeding in using #kaocha for testing... when I call bin/kaocha --version, for exemplo, it gives me a compilation error... Here's the complete error report:
{:clojure.main/message
"Syntax error (ArityException) compiling at (kaocha/version_check.clj:1:1).\nWrong number of args (3) passed to: clojure.spec.alpha/amp-impl\n",
:clojure.main/triage
{:clojure.error/phase :compile-syntax-check,
:clojure.error/line 1,
:clojure.error/column 1,
:clojure.error/source "version_check.clj",
:clojure.error/path "kaocha/version_check.clj",
:clojure.error/class clojure.lang.ArityException,
:clojure.error/cause
"Wrong number of args (3) passed to: clojure.spec.alpha/amp-impl"},
:clojure.main/trace
{:via
[{:type clojure.lang.Compiler$CompilerException,
:message
"Syntax error compiling at (kaocha/version_check.clj:1:1).",
:data
{:clojure.error/phase :compile-syntax-check,
:clojure.error/line 1,
:clojure.error/column 1,
:clojure.error/source "kaocha/version_check.clj"},
:at [clojure.lang.Compiler load "Compiler.java" 7648]}
{:type java.lang.ExceptionInInitializerError,
:at [java.lang.Class forName0 "Class.java" -2]}
{:type clojure.lang.ArityException,
:message
"Wrong number of args (3) passed to: clojure.spec.alpha/amp-impl",
:at [clojure.lang.AFn throwArity "AFn.java" 429]}],
:trace
[[clojure.lang.AFn throwArity "AFn.java" 429]
[clojure.lang.AFn invoke "AFn.java" 40]
[clojure.core.specs.alpha$fn__59 invokeStatic "alpha.clj" 107]
[clojure.core.specs.alpha$fn__59 invoke "alpha.clj" 107]
[clojure.core.specs.alpha__init load nil 107]
[clojure.core.specs.alpha__init <clinit> nil -1]
[java.lang.Class forName0 "Class.java" -2]
[java.lang.Class forName "Class.java" 348]
[clojure.lang.RT classForName "RT.java" 2211]
[clojure.lang.RT classForName "RT.java" 2220]
[clojure.lang.RT loadClassForName "RT.java" 2239]
[clojure.lang.RT load "RT.java" 449]
[clojure.lang.RT load "RT.java" 424]
[clojure.lang.Compiler ensureMacroCheck "Compiler.java" 6958]
[clojure.lang.Compiler checkSpecs "Compiler.java" 6970]
[clojure.lang.Compiler macroexpand1 "Compiler.java" 6988]
[clojure.lang.Compiler macroexpand "Compiler.java" 7075]
[clojure.lang.Compiler eval "Compiler.java" 7161]
[clojure.lang.Compiler load "Compiler.java" 7636]
[clojure.lang.RT loadResourceScript "RT.java" 381]
[clojure.lang.RT loadResourceScript "RT.java" 372]
[clojure.lang.RT load "RT.java" 459]
[clojure.lang.RT load "RT.java" 424]
[clojure.core$load$fn__6839 invoke "core.clj" 6126]
[clojure.core$load invokeStatic "core.clj" 6125]
[clojure.core$load doInvoke "core.clj" 6109]
[clojure.lang.RestFn invoke "RestFn.java" 408]
[clojure.core$load_one invokeStatic "core.clj" 5908]
[clojure.core$load_one invoke "core.clj" 5903]
[clojure.core$load_lib$fn__6780 invoke "core.clj" 5948]
[clojure.core$load_lib invokeStatic "core.clj" 5947]
[clojure.core$load_lib doInvoke "core.clj" 5928]
[clojure.lang.RestFn applyTo "RestFn.java" 142]
[clojure.core$apply invokeStatic "core.clj" 667]
[clojure.core$load_libs invokeStatic "core.clj" 5985]
[clojure.core$load_libs doInvoke "core.clj" 5969]
[clojure.lang.RestFn applyTo "RestFn.java" 137]
[clojure.core$apply invokeStatic "core.clj" 667]
[clojure.core$require invokeStatic "core.clj" 6007]
[clojure.core$require doInvoke "core.clj" 6007]
[clojure.lang.RestFn invoke "RestFn.java" 408]
[user$eval1 invokeStatic "runner.clj" 1]
[user$eval1 invoke "runner.clj" 1]
[clojure.lang.Compiler eval "Compiler.java" 7177]
[clojure.lang.Compiler load "Compiler.java" 7636]
[clojure.lang.RT loadResourceScript "RT.java" 381]
[clojure.lang.RT loadResourceScript "RT.java" 372]
[clojure.lang.RT load "RT.java" 459]
[clojure.lang.RT load "RT.java" 424]
[clojure.core$load$fn__6839 invoke "core.clj" 6126]
[clojure.core$load invokeStatic "core.clj" 6125]
[clojure.core$load doInvoke "core.clj" 6109]
[clojure.lang.RestFn invoke "RestFn.java" 408]
[clojure.core$load_one invokeStatic "core.clj" 5908]
[clojure.core$load_one invoke "core.clj" 5903]
[clojure.core$load_lib$fn__6780 invoke "core.clj" 5948]
[clojure.core$load_lib invokeStatic "core.clj" 5947]
[clojure.core$load_lib doInvoke "core.clj" 5928]
[clojure.lang.RestFn applyTo "RestFn.java" 142]
[clojure.core$apply invokeStatic "core.clj" 667]
[clojure.core$load_libs invokeStatic "core.clj" 5985]
[clojure.core$load_libs doInvoke "core.clj" 5969]
[clojure.lang.RestFn applyTo "RestFn.java" 137]
[clojure.core$apply invokeStatic "core.clj" 667]
[clojure.core$require invokeStatic "core.clj" 6007]
[clojure.main$main_opt invokeStatic "main.clj" 514]
[clojure.main$main_opt invoke "main.clj" 510]
[clojure.main$main invokeStatic "main.clj" 664]
[clojure.main$main doInvoke "main.clj" 616]
[clojure.lang.RestFn applyTo "RestFn.java" 137]
[clojure.lang.Var applyTo "Var.java" 705]
[clojure.main main "main.java" 40]],
:cause
"Wrong number of args (3) passed to: clojure.spec.alpha/amp-impl",
:phase :compile-syntax-check}}
Is your own code using Slingshot perhaps, and bringing in an older version than Kaocha needs?
Slingshot? Sorry... what that should be?
You're probably going to need to share your deps.edn
file and you may do better getting help directly in the #CCY2V0U6A channel (I don't use Kaocha so I'm speculating based on that stacktrace and what the kaocha.version-check
namespace contains).
This is how my deps.end looks like
{:deps {org.clojure/clojure {:mvn/version "1.10.1"}
;; DATABASE ACCESS
org.clojure/java.jdbc {:mvn/version "0.6.1"}
org.clojure/data.json {:mvn/version "2.1.1"}
javax.servlet/servlet-api {:mvn/version "2.5"}
org.flatland/ordered {:mvn/version "1.15.10"}
;; LOGGING
com.taoensso/timbre {:mvn/version "4.10.0"}
org.slf4j/slf4j-api {:mvn/version "1.7.14"}
com.fzakaria/slf4j-timbre {:mvn/version "0.3.13"}
org.slf4j/log4j-over-slf4j {:mvn/version "1.7.14"}
org.slf4j/jul-to-slf4j {:mvn/version "1.7.14"}
org.slf4j/jcl-over-slf4j {:mvn/version "1.7.14"}
}
:paths ["src" "classes" "resources"]
:aliases {:test
{:extra-paths ["test"]
:extra-deps {lambdaisland/kaocha {:mvn/version "1.87.1366"}
com.h2database/h2 {:mvn/version "1.3.148"}
org.postgresql/postgresql {:mvn/version "42.2.20"}
expectations/expectations {:mvn/version "2.2.0-rc3"}
org.eclipse.jetty/jetty-servlet-tester {:mvn/version "7.0.0.M2"}}
:main-opts ["-m" "kaocha.runner" #_"--watch" #_"--no-capture-output" "--fail-fast"]}
}
}
```I don't see anything wrong with that (tried it locally -- only Kaocha brings in Slingshot and it brings in the latest version). What's in your Kaocha config file?
I have none.
And you're running this with clojure -M:test
?
kind of... I've follow the install instruction on kaocha site and have created a bin/kaocha with this:
#!/usr/bin/env bash
clojure -M:test "$@"
When I run that, using your deps.edn
, I get warnings:
WARNING: Did not load a configuration file and using the defaults.
This is fine for experimenting, but for long-term use, we recommend creating a configuration file to avoid changes in behavior between releases.
To create a configuration file using the current defaults and configuration file location, create a file named tests.edn that contains '#kaocha/v1 {}'.
Do you get that? Or does it fail prior to that?sorry... I have a tests.edn indeed.
And what does clojure -version
print out?
#kaocha/v1
{:plugins [:hooks]
:kaocha.hooks/pre-load [docx.hooks/pre-load-hook]}
clojure -version Clojure CLI version 1.11.1.1347
OK, good. And docx.hooks/pre-load-hook
is in your own code?
yes, it is
(ns docx.hooks
(:require [ :as io]))
(defn pre-load-hook [test-plan]
(compile 'docx.core)
(compile 'docx.servlet)
test-plan)
^ it's this simple
And that's under your test
tree?
OK, so run this command to get an interactive REPL:
clj -Sdeps '{:aliases {:repl {:main-opts ["-r"]}}}' -M:test:repl
and then do
(require 'docx.hooks)
(docx.hooks/pre-load-hook nil)
This should validate that you can load the test dependencies and run that hook. To eliminate any of that code as a problem.(that alias/repl trick is a way to override the :main-opts
in your :test
alias so you can get a REPL with test stuff loaded)
It gives an error:
OK, so you probably have an error in one of your files, and because it's a compile error when Kaocha tries to load your code, the stacktrace is misleading.
So start a fresh REPL like you did above and try to (require 'docx.core)
and then (require 'docx.servlet)
to see if that helps narrow down where your syntax error is.
(unless all your code is up on GH or somewhere I can just go look at it and see if I can spot the problem)
It may be easier to use your editor and just try loading each file into the REPL and see what errors you get...
what i can't understand is that this very base code can compile and generate a .jar file that can be run with success...
😉 it was a comment (;) inside the (ns ... )
thank you very much for the tips
Happy to help! Glad you figured it out 🙂
Remember that your test
code does not get compiled or loaded when you make a JAR -- I assume the ns
error was in a test file somewhere?
it was both in both places
😞 i was wrong
it didn't work
it's really weird, @U04V70XH6
the first time I do a require, it dont work, but if I call require again, it works.
That's why I said you needed a fresh REPL for the test...
So if docx.core
won't load, start a new REPL and try to require each of the nses it requires in its ns. Repeat recursively until you find the culprit.
The "Syntax error .. at (.. :1:1)" suggests it's something in an ns
form somewhere in your code.
(if this was up on GitHub, I could take a look and probably find it faster)
I'm cutting piece by piece to find out...
to running test, do I need do first compile the classes?
i mean... I do need to add a 'compile' step before calling the tests?
I'm getting errors like that: clj -X:test Running tests in #{"test"} Syntax error (ClassNotFoundException) compiling at (docx/servlet_test.clj:20:20). docx.servlet
(i've dumped the kaocha and now using just the regular clojure test runner... then I'm getting those error about having not compile the classes)
Do what I suggested above: start a REPL from the command-line and just try to require
a namespace.
You need to do little tiny steps in the REPL.
Until you've figured out what is causing the syntax error, there's no point in trying to run the tests at all.
from repl it's working
there's no syntax error
37 minutes ago, you said there was still.
Fresh REPL. One require
. It failed.
yeah... but that i could figure out
and fixed
the only thing now is this code:
it's a test
and it need the class docx.servlet
but it can't find this class
Why did you switch away from Kaocha and the pre load hook?
so I'm thinking that I will need to compile that in some way
That hook was what was compiling the classes you need.
because I couldn't find out any useful messages when using it
with the clojure test runner, there's some "hook" alternative that I can use do compile the classes?
If you think you've "fixed" the problem in your code, go back and repeat this experiment and make sure you can load and run the hook: https://clojurians.slack.com/archives/C08LK2DH7/p1700169047926159?thread_ts=1700166725.087079&cid=C08LK2DH7
The problem was with the sfl4j shit... after I've removed (comment out) that error on spec alfa gone
Now I came back to Kaocha
and is almost 100% working.. there's just this error:
that has to be with some logging shit..
Finnaly! Everything working... in the end, I think it was just an 'require' that wasn't present... thank you very much, @U04V70XH6 You're the best Sean that I know of.
Logging is a giant pain. Personally, I think Timbre makes it worse. We use clojure.tools.logging
and log4j2
at work (after trying a lot of other things).
Systematic, step-by-step debugging FTW 🙂
Thanks @U04V70XH6 for helping to figure this out!