Closed plicease closed 7 years ago
The binary built from source appears to print to stderr. So you probably actually want to check both stdout and stderr. Both here and in the t/03_binary_version.t
. So this PR isn't exactly right, but hopefully it gives you the idea.
Here is the test failure that I see after applying this patch:
iscah% prove -bv
t/01_use.t ................
1..1
ok 1 - use Alien::astyle;
ok
t/02_binary_executable.t ..
1..10
ok 1 - use Alien::astyle;
not ok 2 - Alien::astyle->bin_dir() is defined
# Failed test 'Alien::astyle->bin_dir() is defined'
# at t/02_binary_executable.t line 11.
ok 3 - Alien::astyle->bin_dir() is not empty
not ok 4 - Alien::astyle->bin_dir() exists
Use of uninitialized value $astyle_bin_dir in -e at t/02_binary_executable.t line 13.
# Failed test 'Alien::astyle->bin_dir() exists'
# at t/02_binary_executable.t line 13.
Use of uninitialized value $astyle_bin_dir in -r at t/02_binary_executable.t line 14.
not ok 5 - Alien::astyle->bin_dir() is readable
# Failed test 'Alien::astyle->bin_dir() is readable'
# at t/02_binary_executable.t line 14.
Use of uninitialized value $astyle_bin_dir in -d at t/02_binary_executable.t line 15.
not ok 6 - Alien::astyle->bin_dir() is a directory
# Failed test 'Alien::astyle->bin_dir() is a directory'
# at t/02_binary_executable.t line 15.
Use of uninitialized value in subroutine entry at t/02_binary_executable.t line 17.
not ok 7 - astyle exists
# Failed test 'astyle exists'
# at t/02_binary_executable.t line 18.
not ok 8 - astyle is readable
# Failed test 'astyle is readable'
# at t/02_binary_executable.t line 19.
not ok 9 - astyle is a file
# Failed test 'astyle is a file'
# at t/02_binary_executable.t line 20.
not ok 10 - astyle is executable
# Failed test 'astyle is executable'
# at t/02_binary_executable.t line 21.
# Looks like you failed 8 tests of 10.
Dubious, test returned 8 (wstat 2048, 0x800)
Failed 8/10 subtests
t/03_binary_version.t .....
1..7
ok 1 - use Alien::astyle;
Use of uninitialized value in subroutine entry at t/03_binary_version.t line 12.
not ok 2 - `astyle --version` executes without displaying errors
# Failed test '`astyle --version` executes without displaying errors'
# at t/03_binary_version.t line 18.
# got: 'Can't exec "/astyle": No such file or directory at t/03_binary_version.t line 16.
# '
# expected: ''
not ok 3 - `astyle --version` executes with 1 line of output
# Failed test '`astyle --version` executes with 1 line of output'
# at t/03_binary_version.t line 19.
# got: 0
# expected: 1
not ok 4 - `astyle --version` 1 line of output is defined
# Failed test '`astyle --version` 1 line of output is defined'
# at t/03_binary_version.t line 22.
Use of uninitialized value within @_ in list assignment at /home/ollisg/.perlbrew/libs/perl-5.25.3tc@dev/lib/perl5/Test/Builder.pm line 730.
not ok 5 - `astyle --version` 1 line of output starts correctly
# Failed test '`astyle --version` 1 line of output starts correctly'
# at t/03_binary_version.t line 23.
# got: ''
# expected: 'Artistic Style Version'
Use of uninitialized value $version_stdout_0 in pattern match (m//) at t/03_binary_version.t line 24.
not ok 6 - `astyle --version` 1 line of output ends correctly
# Failed test '`astyle --version` 1 line of output ends correctly'
# at t/03_binary_version.t line 24.
Use of uninitialized value $1 in split at t/03_binary_version.t line 26.
Use of uninitialized value in addition (+) at t/03_binary_version.t line 27.
not ok 7 - `astyle --version` returns major version 2 or newer
# Failed test '`astyle --version` returns major version 2 or newer'
# at t/03_binary_version.t line 28.
# got: 0
# expected: 2
# Looks like you failed 6 tests of 7.
Dubious, test returned 6 (wstat 1536, 0x600)
Failed 6/7 subtests
Test Summary Report
-------------------
t/02_binary_executable.t (Wstat: 2048 Tests: 10 Failed: 8)
Failed tests: 2, 4-10
Non-zero exit status: 8
t/03_binary_version.t (Wstat: 1536 Tests: 7 Failed: 6)
Failed tests: 2-7
Non-zero exit status: 6
Files=3, Tests=18, 0 wallclock secs ( 0.04 usr 0.00 sys + 0.18 cusr 0.01 csys = 0.23 CPU)
Result: FAIL
the first test fails because Alien::astyle->bin_dir
returns empty list in a system install since astyle is already in the PATH
. The second fails because the Debian version prints the version to stderr. I suspect that this is because the Debian version is older.
At least for the
astyle
provided for my Debian Linux, the version number is printed to stderr, not stdout. Also, checking $? is a reliable way for catching things like "command not found".