[hackers] [sbase][PATCH] ed: Split tests

From: Santtu Lakkala <inz_AT_inz.fi>
Date: Mon, 1 Dec 2025 17:02:51 +0200

Use multiple separate test scripts for ed to make it more obvious which
test failed.
---
 tests/0003-ed.sh | 38 --------------------------------------
 tests/0004-ed.sh | 33 +++++++++++++++++++++++++++++++++
 tests/0005-ed.sh | 34 ++++++++++++++++++++++++++++++++++
 3 files changed, 67 insertions(+), 38 deletions(-)
 create mode 100755 tests/0004-ed.sh
 create mode 100755 tests/0005-ed.sh
diff --git a/tests/0003-ed.sh b/tests/0003-ed.sh
index ee44132..f4a0acb 100755
--- a/tests/0003-ed.sh
+++ b/tests/0003-ed.sh
_AT_@ -72,41 +72,3 @@ fizz
 foobar
 buzz
 EOF
-
-printf foo >$tmp1
-../ed $tmp1 <<EOF >$tmp2
-,p
-w
-EOF
-
-# This is somewhat opinionated test for files without trailing newline, more
-# documenting the current behavior, which differs from BSD and GNU eds.
-diff -u - $tmp2 <<EOF || true
-3
-foo
-4
-EOF
-
-diff -u - $tmp1 <<EOF
-foo
-EOF
-
-../ed <<EOF >$tmp2
-i
-foo
-bar
-.
-,t
-1t
-2t
-2,3t
-3,7p
-EOF
-
-diff -u - $tmp2 <<EOF
-foo
-bar
-foo
-bar
-bar
-EOF
diff --git a/tests/0004-ed.sh b/tests/0004-ed.sh
new file mode 100755
index 0000000..fe8e998
--- /dev/null
+++ b/tests/0004-ed.sh
_AT_@ -0,0 +1,33 @@
+#!/bin/sh
+
+set -e
+
+tmp1=tmp1.$$
+tmp2=tmp2.$$
+
+cleanup()
+{
+	st=$?
+	rm -f $tmp1 $tmp2
+	exit $st
+}
+
+trap cleanup EXIT
+
+printf foo >$tmp1
+../ed $tmp1 <<EOF >$tmp2
+,p
+w
+EOF
+
+# This is somewhat opinionated test for files without trailing newline, more
+# documenting the current behavior, which differs from BSD and GNU eds.
+diff -u - $tmp2 <<EOF || true
+3
+foo
+4
+EOF
+
+diff -u - $tmp1 <<EOF
+foo
+EOF
diff --git a/tests/0005-ed.sh b/tests/0005-ed.sh
new file mode 100755
index 0000000..7a55180
--- /dev/null
+++ b/tests/0005-ed.sh
_AT_@ -0,0 +1,34 @@
+#!/bin/sh
+
+set -e
+
+tmp1=tmp1.$$
+
+cleanup()
+{
+	st=$?
+	rm -f $tmp1
+	exit $st
+}
+
+trap cleanup EXIT
+
+../ed <<EOF >$tmp1
+i
+foo
+bar
+.
+,t
+1t
+2t
+2,3t
+3,7p
+EOF
+
+diff -u - $tmp1 <<EOF
+foo
+bar
+foo
+bar
+bar
+EOF
-- 
2.42.0
Received on Mon Dec 01 2025 - 16:02:51 CET

This archive was generated by hypermail 2.3.0 : Mon Dec 01 2025 - 16:12:56 CET