Fork me on GitHub
#shadow-cljs
<
2022-08-04
>
steveb8n02:08:18

Q: I’m running node tests using the instructions here: https://shadow-cljs.github.io/docs/UsersGuide.html#target-node-test when run via the node process they return a non-zero exit code as expected on my laptop. When I run in CI (bitbucket) i.e. docker, the same command returns zero even when the tests report failures. Has anyone seen this before?

steveb8n21:08:53

Here’s the CLI command….

npx shadow-cljs -A:cljs:git-deps:test compile test-ci && node cljs-out/test-ci/node-tests.js

steveb8n21:08:22

and the config

{:target           :node-test
                                :compiler-options {:optimizations :whitespace}
                                :output-to        "cljs-out/test-ci/node-tests.js"
                                ;:ns-regexp        "^\b([a-z\\-]+)\b(?<!render|ignoreme)-test"
                                ; cannot use autorun if return code is needed. see shadow docs link above
                                :autorun          true}

steveb8n21:08:55

I’ve tried this without autorun as well but same problem

steveb8n21:08:18

@thheller if there’s nothing obvious then I’ll try a local docker repro next. I’d guess its a docker env problem. CI is often painful

thheller06:08:38

again. in what context is the CLI command called?

thheller06:08:04

this is relevant since that dictates how the error code is handled

thheller06:08:51

I'm also not a docker expert or any container expert. so no idea what the rules of those even are and if they even check error codes

steveb8n22:08:25

@thheller I got to the bottom of this one. I was using node fs/mkdirSync and that was failing in CI (not on localhost). If an fs/foo call throws an exception, the return code from the tests is zero. once I fixed the fs call, the tests properly returned non-zero for actual test fails

steveb8n22:08:37

is this interesting enough for an issue?

thheller06:08:34

node -e "require('fs').mkdirSync(null)" echo $! does not have a 0 exit code?

thheller06:08:55

do you have an "uncaughtException" handler that prevents the actual exit?

steveb8n09:08:02

I’m running a chain of promises and the fs fail is in the last one. maybe that’s the key? I’m using promesa for the chain

steveb8n09:08:14

if you want a repro I can add a sample test to an issue

thheller05:08:21

depends on how you run then in CI I guess

steveb8n06:08:10

Same exact cli command. Since ci is Docker I will try local docker to try and reproduce

thheller07:08:05

well but how does your CI run it? Is it run in a bash file or so?

steveb8n09:08:02

I'll put the invocations in a thread tomorrow for you to verify. A bit late here now

john21:08:39

Funny story... I keep raving about how excited I am at work about Shadow Grove. So a colleague mailed me a Shadow Grove T-Shirt. Apparently it's a brewery near him! Gotta get you one of these, @thheller

👏 2
simple_smile 1
Drew Verlee22:08:37

I would totally buy a shadow cljs shirt.

Drew Verlee22:08:57

If you had to generate an index.html before starting your shadow app is there some configuration for that or do i just just run that logic then shadow server functions like (server/start!). I have to imagine it's the latter.