On Saturday 13 January 2007 13:50, Frans Pop wrote: > The testcase included in the busybox testsuite seems to work only by > accident as it is a numeric sort and the last field to be sorted is the > only numerical data in each line.
It turns out the testcase based on the D-I situation is broken in two respects: - The testing function wants the _expected output_ as its 3rd parameter and the _input_ as the 5th parameter. In testsuite/sort.tests these are reversed. - If I run that test with GNU 'sort' (from my regular Etch system), the sort only works correctly if I sort with -k5, not -k4. This means that GNU 'sort' _does_ count the empty field before the leading separator (as also originally reported by Joey). Attached an extra set of testcases, with the corrected D-I case and a full set of cases for sorting with and without leading delimiter. These all PASS if I use GNU sort. Cheers, FJP
testing "sort key edge case with -t" "sort -n -k5 -t/" \ "/usr/lib/finish-install.d/1 /usr/lib/prebaseconfig.d/2 /usr/lib/finish-install.d/4 /usr/lib/prebaseconfig.d/6 " "" "/usr/lib/finish-install.d/1 /usr/lib/finish-install.d/4 /usr/lib/prebaseconfig.d/2 /usr/lib/prebaseconfig.d/6 " testing "sort key with delimiter, field 1" "sort -k1 -t/" \ "a/a/b a/c/a b/b/c " "" "a/c/a b/b/c a/a/b " testing "sort key with delimiter, field 2" "sort -k2 -t/" \ "a/a/b b/b/c a/c/a " "" "a/c/a b/b/c a/a/b " testing "sort key with delimiter, field 3" "sort -k3 -t/" \ "a/c/a a/a/b b/b/c " "" "a/c/a b/b/c a/a/b " testing "sort key with leading delimiter, field 1" "sort -k1 -t/" \ "/a/a/b /a/c/a /b/b/c " "" "/a/c/a /b/b/c /a/a/b " testing "sort key with leading delimiter, field 2" "sort -k2 -t/" \ "/a/a/b /a/c/a /b/b/c " "" "/a/c/a /b/b/c /a/a/b " testing "sort key with leading delimiter, field 3" "sort -k3 -t/" \ "/a/a/b /b/b/c /a/c/a " "" "/a/c/a /b/b/c /a/a/b " testing "sort key with leading delimiter, field 4" "sort -k4 -t/" \ "/a/c/a /a/a/b /b/b/c " "" "/a/c/a /b/b/c /a/a/b "
pgpEQNK2vqnWO.pgp
Description: PGP signature