-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
spec runner depends on libxml #5662
Comments
The solution in my eyes is just to dump the spec data into JSON, then have an optional external tool which can reprocess that JSON into the junit XML. |
Or manually |
@ysbaddaden That would also be possible. Maybe this could be the easiest solution. As I understand from the PR adding this feature, #2455, junit output is generally useful when running on circle-ci. I'm not sure it would be so great to make the code for specs depend on the environment where they are run. |
How can a command line arg change that? The only thing that comes to my mind is a |
Moving to a shard may be the cleanest solution – why there is specific code to JUnit in the stdlib?! |
@asterite If This obviously won't work if a spec file is run/build with |
Another solution is to implement XML in Crystal |
Junit is a standard format generated by loads of spec runners and parsed by many tools and ci runners. That's why it's in the stdlib. I also think that the output formats available should be dictated by the user at the commandline, not by having to require more stuff. Implementing xml in crystal would be ideal, perhaps it would be enough to just template together the xml without a proper builder for this limited case. |
You mean essentially reverting #4090? |
Please let's not manually generate XML. I see no problem with this being a shard. JUnit test output isn't something built-in in any language I know. |
Yeah, but which language has a proper spec library built in? I don't think manually creating it would be that bad. It's really trivial markup. I would really prefer that over having to add an extra shard for such a simple feature. |
D, Rust, Go and Ruby all have a built-in way to run tests. I guess Nim too. |
Nim actually comes with a JUnit formatter that creates XML markup manually. |
Cool! Then maybe the easiest solution is to just write that manually (I think it originally was like that and it was working fine). |
That is good to know, specially since the JUnit output was originally manually generated But being a bit more serious, I think JUnit support can remain by doing some refactor on Bear with me with the needed changes:
Will something like that work? I'm missing any other detail? Cheers. |
@luislavena That's what I had initially proposed. But it would actually be better to just implement the JUnit formatter without a dependency on libxml. |
The problem with |
@asterite then perhaps will be good to introduce the refactoring (to allow extending spec.cr CLI) and then Then anyone wanting to use it, simply add it to their In that way |
@straight-shoota are you already working on this or plan to? I might want to hack on some Crystal this week and this could be a nice thing for me to tackle. Let me know so we don't overlap our work. Cheers. |
No, go ahead ;) |
@luislavena any news here? it seems we get more people running into this issue |
@Sija not criticizing, but definitely will send a RFC about complete changes in Spec CLI to be able to test and hook it more easily. But will do that once I have time, lately busy with real life 😁 |
Yeah, I guess it makes sense to discuss some ideas about further improvements for specs first 👍 |
To run specs, you need to require
spec
which includesjunit_formatter
. That formatter requiresxml
which depends onlibxml2
being available. That package is not installed by default - at least not on Debian/Ubuntu or homebrew (the APT package has it as a a suggested dependecy). Didn't check others but I don't expect them to be different.This means, right after installing Crystal using the provided packages, you're not able to run specs. Instead the compiler will print a very cryptic error message (like posted in #5658):
For beginners, this is not trivial to understand. The error message could obviously be improved (see #5291) but that won't solve the problem that you can't use a major feature without manually installing additional libraries.
This is especially iffy considering the JUnit formatter is a very specific feature and won't be needed for most use cases at all.
A possible solution would be to include
libxml2
in the dependencies of the OS packages for Crystal. But I don't think that's the best way because many developers probably won't really use xml anyway so it'd just add an unneccesary dependency.I think it would be better to make the junit formatter optional. Specs are usually compiled and run using
crystal spec
, so it should be possible to only requirejunit_formatter
in the code being compiled if it is configured to use that formatter (as CLI argument).Or remove it entirely from the stdlib into a shard as suggested in #5215.
Related to #5291
The text was updated successfully, but these errors were encountered: