OSDN Git Service

- Do not abort testing after running the sort tests
authorElie De Brauwer <eliedebrauwer@gmail.com>
Thu, 5 Jul 2012 20:58:28 +0000 (22:58 +0200)
committerElie De Brauwer <eliedebrauwer@gmail.com>
Thu, 5 Jul 2012 20:58:28 +0000 (22:58 +0200)
- Add tail testcases for input not ending on a newline
- Fix condition where input coming from stdin does not have a trailing newline

scripts/test/sort.test
scripts/test/tail.test
toys/tail.c

index 6449e49..7bd413f 100755 (executable)
@@ -97,4 +97,4 @@ testing "sort -g" "sort -g" \
   "bork\nNaN\n-inf\n0.4\n1.222\n01.37\n2.1\n+infinity\n" "" \
   "01.37\n1.222\n2.1\n0.4\nNaN\nbork\n-inf\n+infinity\n"
 
-exit $FAILCOUNT
+
index 2c8f3c2..77e572e 100755 (executable)
@@ -22,6 +22,9 @@ testing "tail -c+ in bounds" "tail -c +27 file1" \
 testing "tail -c+ out of bonds" "tail -c +999 file1" "" "" ""
 rm file1
 
+testing "tail stdin no trailing newline" "tail -n 1 - " "c" "" "a\nb\nc"
+testing "tail file no trailing newline" "tail -n 1 input" "c" "a\nb\nc" ""
+
 optional TAIL_SEEK
 testing "tail noseek -n in bounds" "tail -n 3" "nine\nten\neleven\n" \
        "" "$BIGTEST"
index 18369cc..a029eca 100644 (file)
@@ -176,7 +176,7 @@ static void do_tail(int fd, char *name)
                                }
 
                                if (lines) {
-                                       if(try[count] != '\n') continue;
+                                       if(try[count] != '\n' && count != len-1) continue;
                                        if (lines<0) {
                                                if (!++lines) ++lines;
                                                continue;