Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

REPL+CLI support #44

Closed
wants to merge 43 commits into from
Closed

REPL+CLI support #44

wants to merge 43 commits into from

Conversation

frenchy64
Copy link
Contributor

@frenchy64 frenchy64 commented Feb 2, 2022

Close #21
Close #31

This exposes most of bat-test via the REPL or Clojure CLI.

There is an extra feature called :test-matcher-directories which only runs tests in particular directories. This is especially useful for huge projects that are split into many source directories, so you can easily boot up a watching tester for a subproject.

It's implemented as a sugar for :test-matcher.

The Actions build can be seen passing here.

@Deraen
Copy link
Member

Deraen commented Feb 4, 2022

Oh, I didn't remember bat-test didn't have a main ns at all for Clojure CLI yet.

Is :exec-fn prefered over ns -main function now?

I'll want to ensure the lein version works as close as possible as this, so it would make sense to implement test-matcher-directories in the impl ns so it can be shared by both frontends.

@frenchy64
Copy link
Contributor Author

Is :exec-fn prefered over ns -main function now?

It's hard to tell exactly, but Cognitect's test-runner seems to be encouraging exec. https://github.com/cognitect-labs/test-runner

I'll want to ensure the lein version works as close as possible as this, so it would make sense to implement test-matcher-directories in the impl ns so it can be shared by both frontends.

Will do.

@frenchy64
Copy link
Contributor Author

Looking into providing a kv interface via Lein, eg., lein bat-test :watch true for full feature parity.

@frenchy64 frenchy64 marked this pull request as draft February 7, 2022 00:16
@frenchy64
Copy link
Contributor Author

My implementation of Leiningen test selectors is wrong, I need to go back to the drawing board.

@frenchy64
Copy link
Contributor Author

frenchy64 commented Feb 7, 2022

I added a separator for lein bat-test so you can provide selectors/namespaces in both styles.

lein bat-test foo.ns : :parallel? true
;; same as
lein bat-test : :selectors '[foo.ns]' :parallel? true

I really like this interface, saves a lot of typing. I'll try and port it to Clojure CLI with -M.

@Deraen
Copy link
Member

Deraen commented Mar 2, 2022

Hi, what is the status now?

I see some problems with the Lein implementation, as the Lein namespace is using cli namespace directly, which requires c.t.namespace, which probably isn't available on Lein boot classpath.

I can probably fix those problems if the cli interface and the selectors work with Lein otherwise.

@frenchy64
Copy link
Contributor Author

frenchy64 commented Mar 2, 2022

@Deraen I was thinking of one extra feature, but was having trouble implementing it. I think this PR is good enough to start with though, if you could fix the dependency issues for me that would be great. Then it's good to merge.

Here's the idea for an extra feature:

lein bat-test ./my-dir watching tests in my-dir. Distinguished from lein bat-test my-dir because it starts with ..

You could then alternatively do cd my-dir && lein bat-test ..

@Deraen
Copy link
Member

Deraen commented May 2, 2022

@frenchy64 I tried fixing the cli namespace uses from the Lein plugin code but wasn't successful.

Another problem is that the bat-test artifact is currently supposed to be used as a Lein or Boot plugin so that it won't have any dependencies and instead depends on the tool to add the dependencies vs. clj.

What would you think about just taking the CLI part and releasing that as a new project? I believe using the main namespace with Lein is becoming a popular way to support multiple tools (e.g., Kaocha and Figwheel-main).

@frenchy64
Copy link
Contributor Author

Thanks for trying, I have no problem with making a new project!

@frenchy64 frenchy64 closed this May 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Clojure CLI tool support Provide functions to run tests from REPL
2 participants