summaryrefslogtreecommitdiff
path: root/usr.bin/diff/tests
diff options
context:
space:
mode:
authorKyle Evans <kevans@FreeBSD.org>2018-08-19 03:57:20 +0000
committerKyle Evans <kevans@FreeBSD.org>2018-08-19 03:57:20 +0000
commite68edb8cf06a796453378b98d963692c838c400f (patch)
tree477137d7ee0c4b2dd86e3dc4e9815300643d8753 /usr.bin/diff/tests
parentd17f8070a1341a2f35a1f25d85dbe98abddf2033 (diff)
downloadsrc-test2-e68edb8cf06a796453378b98d963692c838c400f.tar.gz
src-test2-e68edb8cf06a796453378b98d963692c838c400f.zip
diff(1): Implement -B/--ignore-blank-lines
As noted by cem in r338035, coccinelle invokes diff(1) with the -B flag. This was not previously implemented here, so one was forced to create a link for GNU diff to /usr/local/bin/diff Implement the -B flag and add some primitive tests for it. It is implemented in the same fashion that -I is implemented; each chunk's lines are scanned, and if a non-blank line is encountered then the chunk will be output. Otherwise, it's skipped. MFC after: 2 weeks
Notes
Notes: svn path=/head/; revision=338039
Diffstat (limited to 'usr.bin/diff/tests')
-rw-r--r--usr.bin/diff/tests/Bflag_C.out2
-rw-r--r--usr.bin/diff/tests/Bflag_D.out2
-rw-r--r--usr.bin/diff/tests/Bflag_F.out4
-rw-r--r--usr.bin/diff/tests/Makefile3
-rwxr-xr-xusr.bin/diff/tests/diff_test.sh17
5 files changed, 28 insertions, 0 deletions
diff --git a/usr.bin/diff/tests/Bflag_C.out b/usr.bin/diff/tests/Bflag_C.out
new file mode 100644
index 000000000000..c7f130aff396
--- /dev/null
+++ b/usr.bin/diff/tests/Bflag_C.out
@@ -0,0 +1,2 @@
+1a2
+>
diff --git a/usr.bin/diff/tests/Bflag_D.out b/usr.bin/diff/tests/Bflag_D.out
new file mode 100644
index 000000000000..4c1170334935
--- /dev/null
+++ b/usr.bin/diff/tests/Bflag_D.out
@@ -0,0 +1,2 @@
+1a2
+> C
diff --git a/usr.bin/diff/tests/Bflag_F.out b/usr.bin/diff/tests/Bflag_F.out
new file mode 100644
index 000000000000..9dc5e5694048
--- /dev/null
+++ b/usr.bin/diff/tests/Bflag_F.out
@@ -0,0 +1,4 @@
+7c8
+< G
+---
+> X
diff --git a/usr.bin/diff/tests/Makefile b/usr.bin/diff/tests/Makefile
index 62a0ab5c6188..78744d3bed8e 100644
--- a/usr.bin/diff/tests/Makefile
+++ b/usr.bin/diff/tests/Makefile
@@ -5,6 +5,9 @@ PACKAGE= tests
ATF_TESTS_SH= diff_test
${PACKAGE}FILES+= \
+ Bflag_C.out \
+ Bflag_D.out \
+ Bflag_F.out \
input1.in \
input2.in \
input_c1.in \
diff --git a/usr.bin/diff/tests/diff_test.sh b/usr.bin/diff/tests/diff_test.sh
index 557eea049d4e..01942192e504 100755
--- a/usr.bin/diff/tests/diff_test.sh
+++ b/usr.bin/diff/tests/diff_test.sh
@@ -9,6 +9,7 @@ atf_test_case group_format
atf_test_case side_by_side
atf_test_case brief_format
atf_test_case b230049
+atf_test_case Bflag
simple_body()
{
@@ -150,6 +151,21 @@ brief_format_body()
diff -Nrq A D
}
+Bflag_body()
+{
+ atf_check -x 'printf "A\nB\n" > A'
+ atf_check -x 'printf "A\n\nB\n" > B'
+ atf_check -x 'printf "A\n \nB\n" > C'
+ atf_check -x 'printf "A\nC\nB\n" > D'
+ atf_check -x 'printf "A\nB\nC\nD\nE\nF\nG\nH" > E'
+ atf_check -x 'printf "A\n\nB\nC\nD\nE\nF\nX\nH" > F'
+
+ atf_check -s exit:0 -o inline:"" diff -B A B
+ atf_check -s exit:1 -o file:"$(atf_get_srcdir)/Bflag_C.out" diff -B A C
+ atf_check -s exit:1 -o file:"$(atf_get_srcdir)/Bflag_D.out" diff -B A D
+ atf_check -s exit:1 -o file:"$(atf_get_srcdir)/Bflag_F.out" diff -B E F
+}
+
atf_init_test_cases()
{
atf_add_test_case simple
@@ -161,4 +177,5 @@ atf_init_test_cases()
atf_add_test_case side_by_side
atf_add_test_case brief_format
atf_add_test_case b230049
+ atf_add_test_case Bflag
}