Fork me on GitHub
#beginners
<
2023-05-20
>
Sam14:05:17

How do I run all tests from the command line, with a non-zero exit code if something fails? I added (run-all-tests) to the end of my test file and I can run all of them with clj test_file.clj, but it exits with 0 instead of 1. This is with deps.edn and tools.build, is there a function you can add to builds.clj that will solve it all?

Sam15:05:19

Great, thanks!

James Amberger20:05:38

I’m still not at home with clj. I’ve run it in a project dir with a src and then I (ns my.namespace) and find that nothing is in scope.

Alex Miller (Clojure team)20:05:58

Lots of people here happy to help, but will need some more info than that. "nothing" == ?? what exactly do you see?

hiredman21:05:14

Running (ns ...) In the repl just creates the namespace

hiredman21:05:37

It doesn't tell clojure to load anything from disk, just says "make this namespace"

seancorfield21:05:03

> clj
user=> (require '[my.namespace :as my])
nil
user=> (my/func 1 2 3)
☝️:skin-tone-2: That would be a reasonable way to work, with a short alias to your namespace. Or perhaps this approach:
> clj
user=> (require 'my.namespace)
nil
user=> (in-ns 'my.namespace)
...
my.namespace=> (func 1 2 3)
It's important to require the namespace first -- to load it from disk into the REPL -- and then to switch the REPL into it (with in-ns). If you call in-ns without loading your code, it will be an empty namespace.

James Amberger22:05:43

Thank you all; somehow the need to require first escaped me.

2
👍 2
Kamuela22:05:32

Is there a blessed path that goes zero through basic development setup through to baby’s first deployment?

seancorfield22:05:41

Depending on where you are on your Clojure journey (and assuming you're asking about Clojure rather than ClojureScript), perhaps this will help? https://clojure-doc.org/articles/ecosystem/libraries_authoring/

seancorfield22:05:06

Are you working with Leiningen or with the Clojure CLI @U0KLE4WHZ?

Kamuela22:05:38

I suppose that’d be part of the question @U04V70XH6, the one that were the more straightforward of the two to get started with that path

seancorfield22:05:58

Well, Clojure CLI is the official, supported tooling from the core team and is rising in popularity. You'll find docs for that on http://clojure.org (you will not find Leiningen documented on the official site but it appears in a lot of books and tutorials, since it's been around much longer). https://clojure-doc.org/articles/tutorials/getting_started/ talks about why both exist and how they differ.

seancorfield22:05:45

At work, we started with Clojure back in 2010/2011 and Leiningen was the only option. We switched from that to Boot in 2015, and from Boot to the Clojure CLI in 2018.

seancorfield22:05:43

I recommend beginners learn about the Clojure CLI these days because it's what most current work is targeting for Clojure (JVM), ClojureScript, and now for ClojureCLR.

thanks3 2