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
Incorporate bats extension projects #44
Comments
|
see also the discussion in #40 ... this merge is needed from my point of view |
|
I'm open to the possibility—I've done a bunch of my own work in https://github.com/mbland/go-script-bash (see That said, the trend across languages lately appears to be to provide assertion libraries separately from frameworks. Would like to hear more perspectives, particularly from the other @bats-core/bats-core members. |
|
I think that the framework and the assertion libraries are two different things. So there's no need to merge them. We just need to point of those libraries from this one in the documentation. And maybe later create a meta-package that includes all of them. |
|
As we already have assertions in core I'd be tempted to support this proposal and merge the better assertion libraries into core. Assertion libraries tend to provide different styles of assertion (e.g. http://chaijs.com/guide/styles/ for How many styles do we expect bats to have? AFAICS it's a single style, (It might be worth comparing some other languages here) The assertion libraries listed here significantly improve the usability of bats. I'd prefer to carefully merge and fold the existing libraries into core, so core's good enough that it doesn't need extending any more. |
|
Are there any plans to allow for a more defined extension process, like being able to include extensions that could then be used from all tests by just invoking functions and/or using variables and such from included extensions? I ask because for example I have use cases where I want to include some comparator logic, or some result evaluation logic that I want to be available to several tests, perhaps tests in multiple git repos which are otherwise mostly unrelated projects. I don't believe there's anything like that right now. |
|
I'd certainly like to look into this soon-ish, as I just mentioned in #40 and #96. Right now you could come up with your own scheme to |
|
I feel like there's probably room for two methods to do this, one method is to have "include-style" references in individual test files and another method being globally accessible plugins that are enabled at the time command is first executed, and all tests then have access to whatever command(s) a plugin or extension offers. As a means of dealing with name collisions, perhaps it would be possible to have namespaces so that one could have a_useful_thing, b_useful_thing and c_useful_thing. |
|
I think it is a good idea to keep the In the case of assertion libraries, bash already has
+1 Like the rest of |
|
Bash is not a uniform beast, and I would expect Bats to provide a comprehensive range of assertions to prevent users from making standard-bash-mistakes (double brackets are a perfect example - to fix them as per #24 we need to preempt the Bash parser's behaviour).
The library https://github.com/ztombol/bats-assert is a standard
Agree that library loading should be easy nonetheless. |
The bats-core tests would include simple dummy libraries that mimic the way libraries are commonly used. The libraries themselves should also have tests, presumably they wouldn't be an officially recommended library until then.
This is only true for bash 3.x, correct?
What are some other examples that may bite people who write tests using bats? I think such issues should be worked around, and/or appropriate warnings printed (as suggested in the discussion in #24). |
Yep, everything from 3.2.57(1) onwards is supported https://github.com/bats-core/bats-core#supported-bash-versions.
Shellcheck has a good list of gotchas in Bash conditionals https://github.com/koalaman/shellcheck/blob/master/README.md#conditionals The reason #24 has stalled is due to requiring a Bash parser in Bash - which is not a solved problem. There's no Bash-based Bash AST that I know of, some exist in node and golang (like the awesome, well-maintained https://github.com/mvdan/sh - but have a look at the issues list for an idea of the number of edge cases it handles). I would suggest that as we probably can't get an AST in pure Bash, in-Bash static analysis of test code to generate appropriate warnings will be difficult and fraught with edge-cases - which a test runner should avoid at all costs as it should be relied upon for stability. Using a common, well-tested assertion library is my preference as the bounds are well-known and easier to achieve IMHO. |
|
Here's another way to tackle the issues with #24. If running a buggy version of bash, and the test is simple (no multi-line statements or tricks like If the To me the other gotchas fall more under "shells are weird". In order to be successful with shell programming it's necessary to learn those quirks, there's no way around that. |
|
Just FYI - another extension-candidate to join the family #147 (bats-mock). |
|
While decoupling is good design, considering the project almost died, with the speed of change and execution environment, I think ease of use and user adoption should come first. In other words, you either deliver the modular system quickly and be done with it or you park it and prioritise according to "batteries included" approach. |
|
I agree with @schrepfler... I also want to add that at least from where I look, |
@mbland Will GitHub let you update your comment to reflect the new name of your repo? I keep ending up here and trying to click the link and then have to navigate back to your user and to all your repositories to find it's new name. |
|
Whoops, that was a typo. Updated to https://github.com/mbland/go-script-bash. |
|
I just referenced the issue (#135 ). There is a lot here on helper/support script, I think that is best not solved in Bats. Only add something like this maybe? And let bats include any script and override I'm afraid I cant even think of a good, common denominator improvement for 'load'--so just provide the current basic one. But allow to overload things... The current setup makes thinking of Bats extensions (say modules and functions) hard, because it all leans on I think maybe we can think about how or where to customize the current plumbing, and maybe introduce some types of porcelain extension points and probably extension packages. Move bits of current Bats to modules too if we can. A @sublimino I read you look for a Bash parser, ymmv its not in Bash but I recently found a Python one with complete Bash AST in Oil's ASDL (oilshell/oil#200). |
|
Can I just echo some support for this idea? I'm currently working with bats-core and I would greatly prefer it if I didn't have to manage multiple dependencies for what is effectively a singular purpose (testing), other testing frameworks do not ask for addons/extensions to be installed for the use of assertions as I would assume them to be fairly axiomatic in the pursuit of test coverage. Cheers for the hard work all, love the tool, thanks for keeping it alive. |
|
I fully agree with merging these helpers in. I appreciate the want for lightweight components and extensibility, but that's generally promoted in an environment with a reliable package manager. This is bash! My "package manager" is conda which is used in the data science world. It feed contains bats-core, but not the extensions. It's possible for me to try and package them myself, but that's extra stuff to maintain and go wrong. It'd be nice if the useful functionality was bundled in here and came along for the ride downstream. |
|
There have been efforts to create "a reliable package manager" for bash (Basher and BPKG come to mind) and I recall some BATS package already support NPM... But I agree it would make sense to bundle (at the very least) an assert library with BATS-core. I know @jasonkarns is busy getting bats-assert to a state where it could be bundled. For asserts there isn't really another logical alternative. As far as Mocks go, that's a different story... There currently isn't really one clear winner. |
|
The thing about bats is that it could be used in projects with so many different runtimes, and therefore so many different package managers. I use conda because I use Python, I'm sure there are a couple of different JS managers, there may be a C++ usecase, and even a Haskell / .NET Core users. In my opinion it would be more consistent for all of these downstream groups if there was a fatter GitHub blob to build their packages from. Selfishly I would love assert to be included, I could be persuaded either way with mock. |
|
Just re-iterating my previous support for assertion libraries in core, specifically @jasonkarns' bats-assert. 1.2 release roadmap is here. Once the timing PR and refactoring lands in #246 then we can look where to add this "assertion library" feature. I'd suggest this feature is v2.0 -- we maintain backwards compatibility as top priority, but also bump versions as addition of new functions in the namespace may clash with existing test suites. We'll also need to handle suites that load There is also no bats regression/timing suite yet, that would be a useful thing to ship before we start integrating further assertions. |
|
+1 for making this a v2.0 feature. |
|
+1 for the regression/performance tests. I stopped using some bats addons because of performance issues. |
|
+1 |
1 similar comment
|
+1 |
I recently came across
bats-supportandbats-assert. Maybe there are others too. It seems to me that there are useful features in these projects and there is the danger that they become obsolete due to lack of maintenance.I would like to suggest merging such extensions directly into bats due to the following advantages:
Has there been past discussion on this?
The text was updated successfully, but these errors were encountered: