-
Notifications
You must be signed in to change notification settings - Fork 517
bats test cases won't stop #46
Comments
Can you reproduce this behavior from outside bats? Calling your shellscripts directly from the command line? |
nope, calling that script directly won't halt there. and weird thing is If I put invocation of that script in the second test case and make 1st and last one simple assertion. what happens is it prints ok 1, ok 2, and ok 3 and then pause there. |
I just reproduced it with cleaner steps..
running
still trying to figure out what's wrong |
Update: I changed test cases to
Now it can exit successfully without hanging there. Anyone can explain this to me, thanks? |
I had a similar issue. I spend quite some time to figure out what was going on. My setup is bit different but the test is the same: I'm trying to start a Java application leveraging a wrapper (http://wrapper.tanukisoftware.com/doc/english/download.jsp). This wrapper comes with a bash script to perform start, stop and restart operations on the java application. I think this is related to a file descriptor not being closed. If you edit the
to
You'll loose the formatting but your test script will now exit successfully. Bats is using the file descriptor 3, commands run by your test file will inherit this file descriptor (I think). If your Sorry if this is not perfectly clear, I'm not an expert of these things and it's still a bit fuzzy to me. Here is how I've solved it (applied to your example)
The @sstephenson: do you think that bats should take care of closing file descriptor 3 (or not "transmitting it")? |
sstephenson#46 Add error message for bad command line options
Bats 1.1.0 - 2018-07-08 This is the first release with new features relative to the original Bats 0.4.0. Added: * The `-r, --recursive` flag to scan directory arguments recursively for `*.bats` files (sstephenson#109) * The `contrib/rpm/bats.spec` file to build RPMs (sstephenson#111) Changed: * Travis exercises latest versions of Bash from 3.2 through 4.4 (sstephenson#116, sstephenson#117) * Error output highlights invalid command line options (sstephenson#45, sstephenson#46, sstephenson#118) * Replaced `echo` with `printf` (sstephenson#120) Fixed: * Fixed `BATS_ERROR_STATUS` getting lost when `bats_error_trap` fired multiple times under Bash 4.2.x (sstephenson#110) * Updated `bin/bats` symlink resolution, handling the case on CentOS where `/bin` is a symlink to `/usr/bin` (sstephenson#113, sstephenson#115) * tag 'v1.1.0': (198 commits) Bats 1.1.0 bats: Replace echo with printf Extract `abort()` function travis: Remove `bats -c` wrapper travis: Enable build with default Linux image Bash Add Bash version test to Travis job. Revert "Re-add Bash version check to Docker image build" Re-add Bash version check to Docker image build Move timing test to Docker run for Linux jobs Remove version check from Docker image build Bash version via build matrix instead of script loop Fix merge error. Add return code storage for Bash version loop Add Bash version output during 'docker build' Clean up Docker image tags Add default value for Bash version Cover more Bash versions with Docker BATS_ROOT: Elide options to reset shell options BATS_ROOT: Restore comment noting issue sstephenson#113 BATS_ROOT: Use `set -P`, remove `PWD` resolution ...
I am newbie to bash shell programming. Just found this great tool thought give it a shot. one weird thing I met is when all the cases are done. It prints
"ok 1 xxxx
ok 2 xxx
ok 3 xxx"
and it just stops there. only ctrl+c can make it rest.
Some of cases are invoking shell scripts directly.
Would like to know is there anything need to know writing bash program so it can be tested by bats?
Thanks
The text was updated successfully, but these errors were encountered: