commit: 48543f627400bf374a43532873174e2ff8fcc61b
parent 28c0d4015ffb52a95c003055acfadfc01c899560
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date: Tue, 30 Jul 2024 09:17:21 +0200
test-cmd/head: Change from cram to tap.sh
Diffstat:
3 files changed, 37 insertions(+), 73 deletions(-)
diff --git a/test-cmd/Kyuafile b/test-cmd/Kyuafile
@@ -21,6 +21,7 @@ tap_test_program{name="dirname.sh", required_files=basedir.."/cmd/dirname", time
tap_test_program{name="echo.sh", required_files=basedir.."/cmd/echo", timeout=1}
tap_test_program{name="env.sh", required_files=basedir.."/cmd/env", timeout=1}
tap_test_program{name="false.sh", required_files=basedir.."/cmd/false", timeout=1}
+tap_test_program{name="head.sh", required_files=basedir.."/cmd/head", timeout=1}
tap_test_program{name="id.sh", required_files=basedir.."/cmd/id", timeout=1}
tap_test_program{name="link.sh", required_files=basedir.."/cmd/link", timeout=1}
tap_test_program{name="logname.sh", required_files=basedir.."/cmd/logname", timeout=1}
diff --git a/test-cmd/head.sh b/test-cmd/head.sh
@@ -0,0 +1,36 @@
+#!/bin/sh
+# SPDX-FileCopyrightText: 2017 Haelwenn (lanodan) Monnier <contact+utils@hacktivis.me>
+# SPDX-License-Identifier: MPL-2.0
+
+target="$(dirname "$0")/../cmd/head"
+plans=11
+. "$(dirname "$0")/tap.sh"
+
+t --input="$(seq 1 20)" 20l '' "$(seq 1 10)
+"
+
+t --input="$(seq 1 20)" 20l5l '-n 5' "$(seq 1 5)
+"
+
+t --input="$(seq 1 20)" 20l-5l '-5' "$(seq 1 5)
+"
+
+t --input="$(seq 1 5)" 5l '' "$(seq 1 5)"
+
+t --input="$(seq 1 5)" 5l40l '-n 40' "$(seq 1 5)"
+
+t --input='' empty '' ''
+t --input='' empty3l '-n 3' ''
+t --input='' empty3c '-c 3' ''
+
+t --input="$(seq 1 2)" devnull+2l '- /dev/null' '==> - <==
+1
+2
+==> /dev/null <==
+'
+
+t --input="$(seq 1 2)" opt_q '-q - /dev/null' '1
+2'
+
+t opt_v '-v /dev/null' '==> /dev/null <==
+'
diff --git a/test-cmd/head.t b/test-cmd/head.t
@@ -8,47 +8,6 @@
$ set -o pipefail
- $ seq 1 20 | head
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
-
- $ seq 1 20 | head -n 5
- 1
- 2
- 3
- 4
- 5
-
- $ seq 1 20 | head -5
- 1
- 2
- 3
- 4
- 5
-
- $ seq 1 5 | head
- 1
- 2
- 3
- 4
- 5
-
- $ seq 1 5 | head -n 40
- 1
- 2
- 3
- 4
- 5
-
-
$ </dev/zero head -c 40 | wc -c
40
$ </dev/zero head -c 40K | wc -c
@@ -58,35 +17,3 @@
0
[1]
- $ printf '' > empty
-
- $ head -c 3 <empty | wc -c
- 0
- $ head -c 3 empty | wc -c
- 0
-
- $ head -n 3 <empty | wc -l
- 0
- $ head -n 3 empty | wc -l
- 0
-
- $ seq 1 2 | head - empty
- ==> - <==
- 1
- 2
-
- ==> empty <==
-
- $ seq 1 2 | head -v -
- ==> - <==
- 1
- 2
-
- $ seq 1 2 | head -q - empty
- 1
- 2
-
- $ rm empty
-
- $ find .
- .