The existing vercmp_numbers function only handles, as the name says,
numbers. I noticed that "sort" has had a version sort for a long time
[1] and, rather than re-implement it badly, use this as a version of
vercmp that works a bit more naturally.
This is intended to be used in an "if" statement as in
prog_ver=$(prog_ver --version | grep ...)
if vercmp $prog_ver "<" 2.0; then
...
fi
A test-case is added to test the basic features and some edge-cases.
[1] http://git.savannah.gnu.org/gitweb/?p=coreutils.git;a=commitdiff;h=4c9fae4e97d95a9f89d1399a8aeb03051f0fec96
Change-Id: Ie55283acdc40a095b80b2631a55310072883ad0d
We wish to fail if we have >0 zero errors, not >1 errors (i.e. exactly
one error did not trigger a failure!)
This change also brings consistency to the pass & failure paths by
ensuring report_results exits in both cases, since report_results is
supposed to be the last thing run in a test file.
Change-Id: Id4721dffe13721e6c3cd71bca40c3395627e98bf
Ia0957b47187c3dcadd46154b17022c4213781112 proposes to have bashate
find instances of setting a local value. The issue is that "local"
always returns 0, thus hiding any failure in the commands running to
set the variable.
This is an automated replacement of such instances
Depends-On: I676c805e8f0401f75cc5367eee83b3d880cdef81
Change-Id: I9c8912a8fd596535589b207d7fc553b9d951d3fe
Various cleanup to this file.
Firstly create a temporary space to test, rather than working in the
source directory.
We have "assert_equal" which simplifies a lot. Add "assert_empty"
that is used in a couple of tests too. Remove a couple of duplicate
tests.
Change-Id: I7fd476ed63026e67d66a8ac2891b2e4a6687d09c
I noticed this was taking an argument but not dealing with it. In
general the functions were undocumented, so I added some terse usage.
Also, the intent of the test-case was to expand the values before
using them as the message; make sure this happens by using a temp
variable.
Change-Id: Ib317ad1e9dd2a5d2232b9c64541fe4a601a2b8da
Add two generic "passed" and "failed" functions to the unittest
helper. Also keep a count of passed and failed tests. Later changes
will use these functions to ensure they exit with a correct return
code.
Change-Id: I8574dcb1447b04fcda3d72df0bf8605cf7488d3c
This makes a bunch of variable cleanups that will let -o nounset
function, for the time being we hide nounset behind another setting
variable so that it's not on by default.
Because this is bash, and things are only executed on demand, this
probably only works in the config it was run in. Expect cleaning up
all the paths to be something that takes quite a while.
This also includes a new set of unit tests around the trueorfalse
function, because my change in how it worked, didn't. Tests are good
m'kay.
Change-Id: I71a896623ea9e1f042a73dc0678ce85acf0dc87d