Fork me on GitHub
#shadow-cljs
<
2020-03-13
>
andrea.crotti16:03:39

I noticed a couple of strange things, first that when I do shadow-cljs compile test && node out/node-tests.js already with the first step the test actually run

andrea.crotti16:03:01

even if according to the doc they should only run when you execute them with node

thheller16:03:18

do you have :autorun configured?

andrea.crotti16:03:40

the other thing is that in CI even if there are test failures it's always reported as success, which I suspect means it's not returning something different from 0?

andrea.crotti16:03:44

ah yes I do have autorun

andrea.crotti16:03:34

maybe I need two different profiles then? autorun is useful I guess while doing local dev

thheller16:03:11

CI systems are known for killing the shadow-cljs JVM when it starts consuming too much memory, so you may need to restrict it to less memory. see https://shadow-cljs.github.io/docs/UsersGuide.html#jvm-opts

andrea.crotti16:03:28

ah no I don't think that's the rason

andrea.crotti16:03:37

it is definitively finishing normally

thheller16:03:39

shadow-cljs compile test --config-merge "{:autorun false}"

andrea.crotti16:03:36

let's see if that maybe fixes the return code problem as well

andrea.crotti16:03:17

uhm no

~/p/p/footy (fix-test-run|…) $
shadow-cljs compile test --config-merge "{:autorun false}" && node out/node-tests.js
shadow-cljs - config: /Users/acrotti/projects/personal/footy/shadow-cljs.edn  cli version: 2.8.83  node: v13.10.1
shadow-cljs - connected to server
NPM dependency "react" has installed version "^16.12.0"
"16.8.6" was required by jar:file:/Users/acrotti/.m2/repository/re-frame/re-frame/0.10.9/re-frame-0.10.9.jar!/deps.cljs
NPM dependency "react-dom" has installed version "^16.12.0"
"16.8.6" was required by jar:file:/Users/acrotti/.m2/repository/re-frame/re-frame/0.10.9/re-frame-0.10.9.jar!/deps.cljs
[:test] Compiling ...
[:test] Build completed. (175 files, 1 compiled, 0 warnings, 0.56s)

c
Testing footy.handlers-test
Games = [:footy.handlers/games]
^R
e
FAIL in (specs-test) (cljs-runtime/day8/re_frame/test.cljc:99:18)
expected: (db/valid-db? (clojure.core/deref games) (clojure.core/deref players-list))
  actual: (not (db/valid-db? [:footy.handlers/games] [:footy.handlers/players-list]))
failed with args  [:footy.handlers/failed {:uri /games.edn, :last-method GET, :last-error , :last-error-code 0, :debug-message No Error, :status 0, :status-text Request failed., :failure :failed}]
~/p/p/footy (fix-test-run|…) $ echo $status
0

andrea.crotti16:03:30

so it always returns 0

andrea.crotti16:03:45

I guess it's because it's not a real test runner it's just node?

thheller16:03:50

dunno the default test runner should definitely be setting the exit code https://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/test/node.cljs#L12

thheller16:03:09

if you use a different test setup you may need to hook that up manually

andrea.crotti16:03:05

mm wait but

~/p/p/footy (fix-test-run|…) $ which node
/usr/local/bin//node

andrea.crotti16:03:15

so should I be running the node from shadow-cljs?

thheller16:03:48

node out/node-tests.js

thheller16:03:59

thats what should be returning 1 when tests fail

thheller16:03:49

but I don't know how much you are modifying the defaults, so if you override :runner-ns for example it might not unless you hook it up correctly yourself

andrea.crotti16:03:39

it's quite a trivial config

andrea.crotti16:03:40

:test {:target    :node-test
         :output-to "out/node-tests.js"
         :ns-regexp "-test$"
         :autorun   true}

thheller17:03:32

but I see some re-frame testing ns ... dunno how that works. maybe it doesn't use the default testing stuff and never triggers that error

thheller17:03:41

no clue without actually seeing the code

andrea.crotti17:03:33

ah ok let me try if disabling the rf test and making another test fail works

andrea.crotti17:03:39

ah yes that was it!

andrea.crotti17:03:00

the rf test is just something like

(deftest specs-test
  (testing "Game map is valid"
    (rf-test/run-test-async

andrea.crotti17:03:51

it was the async

andrea.crotti17:03:54

run-test-sync works fine

andrea.crotti17:03:07

makes sense I guess, I use it in another project though and I never noticed these issues

andrea.crotti17:03:13

a different runner there though

andrea.crotti17:03:49

thanks a lot @U05224H0W I was not suspecting that at all

thheller16:03:12

just run things without && in 2 separate steps ... makes it easier to figure out which part is actually failing

frozar16:03:40

Hi folks, I generate a package locally "toto-0.1.1.jar" and I would like to use it in a demo project. How can I configure "shadow-cljs.edn" to say to use my local package "toto-0.1.1.jar" instead of looking at any remote repositories?

thheller16:03:44

run lein install to install it in your local repo. shadow-cljs will use that without looking at any remotes, just add the dependency by its regular name

frozar16:03:14

Thank you, I'll try that 🙂

Derek16:03:36

consider naming your local version toto-0.1.1-SNAPSHOT or something to make it clear

thheller16:03:49

no don't use snapshot versions

thheller16:03:56

that might make it check remotes

Derek16:03:31

oh really?

thheller16:03:11

yeah. can't remember the exact rules but snapshots will check remotes for the "latest" snapshot

Derek16:03:31

ah, because SNAPSHOT is a volatile label

frozar16:03:14

It works, thank you. Maybe I should use sanpshot anyway because it's also to send multiple time the same snapshot tag on a remote repository, so it's also a facility.