-
Notifications
You must be signed in to change notification settings - Fork 788
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
Use Bats assertion libraries #1534
Conversation
Do not use `assert_failure` because since doing so would lose information (the exact integer exit code).
e49ee56
to
c6851cd
Compare
Interesting. A few initial thoughts on this. We don't particularly want to add Nodejs ecosystem to our dev dependencies for the core (docs site is a reluctant exception). Adding Nodejs to the core dev experience would ideally be managed by Anyway, I am very reluctant to use Nodejs just for package distribution of some Shell scripts. What I would like to see with introducing dependencies like this is managing them with asdf via plugins and The questions I then have is around how we utilise those when we're trying to source the files in tests. And we would have to be certain these extra dependencies don't leak into the core user-executed code. |
Hm I see, so I guess this would be related to #367? We wouldn't be managing a language per se, but just some tool. If we do it this way, ignoring the maintenance burden of having to maintain an asdf plugin for these library utilities, how would we solve the issue you mention - when adding entries to the
I think this asdf plugin for these libraries exposes some |
I think using XDG directories as the default would resolve this. But as you mention, definitely a breaking change.
I am not sure how different managing these scripts would be to Bats aside from the fact it has a CLI binary to shim and these won't. |
Currently, #1351 doesn't move asdf directories - it only makes using XDG Base Dir-compliant directories the default, and still searches for old directory locations for backwards compatibility. I don't like the idea of moving directories behind a user's back. I know you said you wanted to use
👍 |
This isn't blocked by #1351. #1351 just unblocks us using managing more tools in our Submodules and Subtree are a "no" vote from me.
Ideally developers who contribute to this repo only have to add plugins and run The larger point to be made here is that these libraries don't introduce much more than syntactic sugar (from my limited understanding). While making it easier to read, people should get the gist of what a test looks like from the hundreds we have in this repo which now have little variation due to the consistent linting/style-checking you have helped setup and enforce. Because of this the cost is high for seemingly little gain. |
I see your point - these libraries don't add any major features that we can't live without, and we have more uniformity now in the tests and the code. So there is less to gain, especially since it might be harder to get the dependency installed. Therefore, I guess I'll close this issue 😅 |
Exactly. We're always open to suggestions, the conversations are useful to have. Thanks for contributing so frequently 🙇 |
Happy to help! :) |
Sorry for the late reply again here. I was going to weigh in a week ago but time got away from me.
I avoid anything npm/Node/JavaScript like the plague. I'd really hate to have to use npm just to managed out tests written in BATS/Bash. I'm all for better test code too, but these assertions don't seem to be adding much. I have to agree with @jthegedus that this isn't the right approach. Thanks for all your contributions @hyperupcall ! Sorry to reject this one. |
Summary
There are several helper libraries to make it easier to write tests and understand failures if they occur.
For example, if
[ have = want ]
is replaced withassert_equal 'have' 'want'
(a function from bats-assert), then the following will be printed.This also solves the issue of rogue printing statements that I continue to find during tests.
Dependency Management
Before this is merged, I wanted to inquire about the preferred approach to using this dependency (I am assuming the consensus is that the tradeoff of the dependency is worth the DX benefit it yields)
To get started quickly, I just used my
@hyperupcall/bats-all
library. Using it is faster than sourcing each individual testing library and I'm trying to get it listed on the bats site. It is also an option to install each package separately (bats-support
,bats-file
, andbats-assert
).As for managing the dependency, I wasn't sure if git modules or subtrees were preferred, so I went with
npm
since it seemed like the simplest and cleanest approach.TODO
$output
checks with bats testing functions[ -f
checks with bats testing functions