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

A hatch test command? #1053

Open
jeanas opened this issue Nov 20, 2023 · 8 comments
Open

A hatch test command? #1053

jeanas opened this issue Nov 20, 2023 · 8 comments

Comments

@jeanas
Copy link

jeanas commented Nov 20, 2023

On the topic of standardizing workflows, I think one cool feature of, e.g., Cargo, is the cargo test command that is the same across projects (as opposed in Python to: tox, hatch run test, ...).

Maybe this is a silly idea or considered out of scope, but I wonder about Hatch providing a command hatch test. This could act like hatch run test:test given

[tool.hatch.envs.test]
dependencies = ["pytest"]
[tool.hatch.envs.test.scripts]
test = "pytest"

except that the above config would be implicit if not overridden.

@ofek
Copy link
Sponsor Collaborator

ofek commented Nov 20, 2023

Yes that is literally coming next month actually! Right now I'm finishing up the fmt command.

@jeanas
Copy link
Author

jeanas commented Nov 20, 2023

Oh, great!

@jeanas
Copy link
Author

jeanas commented Dec 10, 2023

If we're using this issue to track what similar commands could be added, hatch doc would be great too. There seems to be a lot of confusion and home-made solutions for running Sphinx (I have no experience with mkdocs).

@ofek
Copy link
Sponsor Collaborator

ofek commented Dec 10, 2023

Documentation would never happen I think because there is no monopoly. For tests pytest does have a monopoly and for formatting/linting Ruff is literally better than everything.

@jeanas
Copy link
Author

jeanas commented Dec 10, 2023

Well... I think it's fair to say there is a duopoly? (I didn't even know that English word existed :) The only two tools I've seen used are Sphinx and mkdocs. Hatch could choose one or the other based on the existence of conf.py or mkdocs.yml.

This could also live in extensions though.

@ofek
Copy link
Sponsor Collaborator

ofek commented Dec 10, 2023

Hatch could choose one or the other based on the existence of conf.py or mkdocs.yml.

So Hatch would transparently manage the environment with conditional dependencies and any arguments would get passed directly to one of the two frameworks? Generally, I'm okay with that but often you need more logic like environment variables and select optional dependency groups (features/extras). Then again if I am just trying to satisfy most cases I think this is acceptable and anything more complex can just define an environment.

This could also live in extensions though.

There is an open feature request for a plugin type that adds commands. I haven't done this yet because I'm still thinking about the best way to go about that.

@oprypin
Copy link
Contributor

oprypin commented Dec 15, 2023

I was mentioning elsewhere also - I think the test command should in fact be a separate plugin (of this new type that adds commands).

For MkDocs check out https://github.com/mkdocs/hatch-mkdocs :)

@funkyfuture
Copy link
Contributor

though pytest and Sphinx are the the exceptions, i've seen a lot of development tools come and go in my time. actually i remember pytest being one among several established test frameworks and that Sphinx was alternativlos. given also the fact that hatch's env functionality allows a solid definition and execution of developer tasks, i can only support the idea to separate that to a plugin. (actually, i find it irritating that hatch's fmt command doesn't allow to use black.)

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

No branches or pull requests

4 participants