[flac-dev] Tests not aborting when appropriate

Martijn van Beurden mvanb1 at gmail.com
Wed Apr 24 23:26:16 PDT 2013


On 25-04-13 05:30, Erik de Castro Lopo wrote:
> The problem is that the failure in the awk script isn't recognised as
> a failure in the shell script.

No, really, it's not only that. With the fixed git, I get this when I 
change one of the expected values to something else:

> [...]
> Testing FLAC file with unknown metadata... OK
> Testing FLAC replaygain 8000 (8000 x 1) ... OK
> Testing FLAC replaygain 11025 (11025 x 1) ... OK
> Testing FLAC replaygain 11025 (11025 x 1) ... OK
> Testing FLAC replaygain 12000 (12000 x 1) ... OK
> Testing FLAC replaygain 16000 (16000 x 1) ... OK
> Testing FLAC replaygain 18900 (18900 x 1) ... OK
> Testing FLAC replaygain 22050 (22050 x 1) ... OK
> Testing FLAC replaygain 24000 (24000 x 1) ... OK
> Testing FLAC replaygain 28000 (28000 x 1) ... OK
> Testing FLAC replaygain 32000 (32000 x 1) ... ERROR, Expected -14.00 
> db instead of comment[1]: REPLAYGAIN_TRACK_GAIN=-14.08 dB
> OK
> Testing FLAC replaygain 36000 (36000 x 1) ... OK
> Testing FLAC replaygain 37800 (37800 x 1) ... OK
> Testing FLAC replaygain 44100 (44100 x 1) ... OK
> Testing FLAC replaygain 48000 (48000 x 1) ... OK
> Testing FLAC replaygain 96000 (48000 x 2) ... OK
> Testing FLAC replaygain 192000 (48000 x 4) ... OK
> [...]

The test just keeps going! Try this snippet

> find * | while read FILE; do if [ "${FILE: -4}" = "flac" ]; then echo 
> "FLAC file found"; exit 1; fi; done; echo "No FLAC file found"

If there are any FLAC files in the directory you try this, it will say 
FLAC file found, but it will also return No FLAC file found because it 
seems exit only exits the loop.

I also found a possible solution: using set -e just above that 
replaygain test for loop. That should exit the whole script if a single 
line returns an non-zero exit status, which makes it possible to let 
'exit' abort not only the loop but the whole script. Maybe there are 
prettier solutions however?


More information about the flac-dev mailing list