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

Fixing test folder browsing #4

Closed
wants to merge 1 commit into from
Closed

Fixing test folder browsing #4

wants to merge 1 commit into from

Conversation

badouralix
Copy link

When running with no argument (or a directory name), zunit fails with :

find: unrecognized: 1

In find man page, the following can be read about -depth option (which takes no parameter):

Process each directory's contents before the directory itself.

Which is actually not what is desired. The expected behaviour of zunit seems to be browsing each unit test folder recursively. To avoid infinite recursion, I propose to select only files using the find built-in option -type.

@molovo
Copy link
Member

molovo commented Dec 21, 2016

@badouralix First of all, thanks very much for contributing to ZUnit.

Am I right in thinking you're using GNU find, rather than the BSD equivalent? The issue doesn't appear on a Mac OS system, but on Ubuntu 16.04 (using GNU find 4.4.2) I get a similiar error: find: paths must precede expression: 1. Would you mind sharing your OS, find version, and ZSH version please?

I'm reluctant to merge your PR at the moment, because whilst it does fix the immediate issue, it breaks ZUnit's tests, as we need the recursion to allow files/dirs beginning with a _ to be ignored. Your fix works for files beginning with _, but files within a directory beginning with _ would still be picked up. ZUnit's own tests use support files (in tests/_support) which without this recursion would be processed as test files.

If we can find a way to exclude those files consistently without recursion, I'm all for it, so please share any ideas you may have.

@molovo
Copy link
Member

molovo commented Dec 21, 2016

Did a little more testing on a linux machine, and whilst using -depth does throw an error, we can cheat and use find $argument -mindepth 1 -maxdepth 1 for the same effect, and still allow the recursion to take place.

I've added that fix to the version-0.3.x branch which contains a host of other fixes for linux systems. Can you try that branch and let me know if it solves your issue please?

@molovo molovo added the bug label Dec 21, 2016
@molovo molovo added this to the v0.3.0 milestone Dec 21, 2016
@badouralix
Copy link
Author

You raised a very good point! I didn't try with the BSD find. Currently, I'm working on ArchLinux with zsh 5.3 and find (GNU findutils) 4.6.0. Among that, my goal was to build a Docker image of ZUnit, based on Alpine 3.4 with zsh 5.2 and BusyBox find v1.24.2.

Using -mindepth (and -maxdepth to ensure single read of each file) is definitely a good fix.

About the files beginning with _, doesn't the zunit shebang prevent those files to be processed? Another fix, chosen by BATS, is to ask for a specific file extension: .zunit for instance.

@molovo
Copy link
Member

molovo commented Dec 21, 2016

Ah! A docker image would be great.

The shebang will prevent them being processed, yes, but it throws an error, so the entire test suite would fail. I could remove the error, but then if a test file was added that was perfectly valid, only missing the shebang, it would be skipped without any notification to the user.

The _ folders keep non-test files nicely separated from the tests themselves. It's a hangover from testing frameworks I've used in other languages which usually have _support, _data, _output and _coverage folders (and I hope one day to implement features into ZUnit which will make use of them).

@molovo
Copy link
Member

molovo commented Dec 22, 2016

I'm going to close this PR, as a fix for the issue is included in v0.3.0 (#6). Thanks @badouralix, please do continue to contribute.

@molovo molovo closed this Dec 22, 2016
@badouralix
Copy link
Author

Good idea for further features, v0.3.0 will be awesome 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants