sstephenson / bats

Bash Automated Testing System
MIT License
7.12k stars 520 forks source link

Multi threaded bats #143

Open pickfire opened 8 years ago

pickfire commented 8 years ago

Hi, is there a way that I can run multiple bats at the same time using 1 thread for a bats and have a limit for the thread that I use?

ztombol commented 8 years ago

Do you mean executing individual tests of the same suite in parallel? Bats, can't do that. It should be possible to implement, but extra care should be taken to prevent interleaving output from tests.

pickfire commented 8 years ago

@ztombol Yeah, if it is parallel, it will possibly benefict those computer that have a lot of processer.

Well, most of the things I did in my scripts are parallel, probably there should be a wait for some tests so that it won't brake.

ztombol commented 8 years ago

If you are looking to implement this feature, probably this is where you want to start.

pickfire commented 8 years ago

@ztombol, I am actually not very sure about how to start it just only by bash. I actually do parallelism using Makefile, well it is not the best choice, I don't have much experience with xargs and parallel.

ztombol commented 8 years ago

@pickfire You don't need parallel. Pure bash should do it. I don't have the time to implement this right now, but hang around and see if anyone is interested.

pickfire commented 8 years ago

Probably we could use something like http://stackoverflow.com/questions/5547787/running-shell-script-in-parallel/5547845#5547845 with the help of -j so that it can run parallelly, I don't have time to implement this right now, should I close this first?

ztombol commented 8 years ago

Do you mean make -j? I don't think you need that either. Just plain old command & and wait, like in the Stack Overflow answer you linked. Actually output handling would be the trickier part.

You can leave the issue open to see what others have to say.

cyphar commented 5 years ago

I would suggest using GNU parallel, which will handle parallelism and collating output all for us. There's no need to make it more complicated than that.