git: fa3af3ce5010 - main - tail: Verify correct behavior when input does not end in a newline.

From: Dag-Erling Smørgrav <des_at_FreeBSD.org>
Date: Thu, 16 Mar 2023 15:37:07 UTC
The branch main has been updated by des:

URL: https://cgit.FreeBSD.org/src/commit/?id=fa3af3ce5010740f28faed22e0a1e819491f26b4

commit fa3af3ce5010740f28faed22e0a1e819491f26b4
Author:     Dag-Erling Smørgrav <des@FreeBSD.org>
AuthorDate: 2023-03-16 15:36:49 +0000
Commit:     Dag-Erling Smørgrav <des@FreeBSD.org>
CommitDate: 2023-03-16 15:37:02 +0000

    tail: Verify correct behavior when input does not end in a newline.
    
    Sponsored by:   Klara, Inc.
    Reviewed by:    kevans
    Differential Revision:  https://reviews.freebsd.org/D39116
---
 usr.bin/tail/tests/tail_test.sh | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/usr.bin/tail/tests/tail_test.sh b/usr.bin/tail/tests/tail_test.sh
index e8263864f28c..36d6cdb68692 100755
--- a/usr.bin/tail/tests/tail_test.sh
+++ b/usr.bin/tail/tests/tail_test.sh
@@ -392,6 +392,19 @@ si_number_body() {
 	atf_check cmp outfile expectfile
 }
 
+atf_test_case no_lf_at_eof
+no_lf_at_eof_head()
+{
+	atf_set "descr" "File does not end in newline"
+}
+no_lf_at_eof_body()
+{
+	printf "a\nb\nc" >infile
+	atf_check -o inline:"c" tail -1 infile
+	atf_check -o inline:"b\nc" tail -2 infile
+	atf_check -o inline:"a\nb\nc" tail -3 infile
+	atf_check -o inline:"a\nb\nc" tail -4 infile
+}
 
 atf_init_test_cases()
 {
@@ -416,4 +429,5 @@ atf_init_test_cases()
 	atf_add_test_case silent_header
 	atf_add_test_case verbose_header
 	atf_add_test_case si_number
+	atf_add_test_case no_lf_at_eof
 }