]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
tests: pr: add checks for +... parameter handling
authorPádraig Brady <P@draigBrady.com>
Fri, 12 Jun 2026 12:07:25 +0000 (13:07 +0100)
committerPádraig Brady <P@draigBrady.com>
Fri, 12 Jun 2026 12:24:42 +0000 (13:24 +0100)
* tests/pr/options.sh: Ad a new test.
* tests/local.mk: Reference new test.
Addresses https://bugs.gnu.org/81225

tests/local.mk
tests/pr/options.sh [new file with mode: 0755]

index 63a437318607eb2bcaed87ab576cdfb530a51ba3..6d572e679b1b5a35faaf6e9311b514be85fd0120 100644 (file)
@@ -290,6 +290,7 @@ all_tests =                                 \
   tests/mktemp/write-error.sh                  \
   tests/misc/arch.sh                           \
   tests/pr/bounded-memory.sh                   \
+  tests/pr/options.sh                          \
   tests/pr/pr-tests.pl                         \
   tests/pwd/argument.sh                                \
   tests/pwd/pwd-option.sh                      \
diff --git a/tests/pr/options.sh b/tests/pr/options.sh
new file mode 100755 (executable)
index 0000000..bbd1e8d
--- /dev/null
@@ -0,0 +1,40 @@
+#!/bin/sh
+# Test 'pr' option handling
+
+# Copyright (C) 2026 Free Software Foundation, Inc.
+
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <https://www.gnu.org/licenses/>.
+
+. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
+print_ver_ pr
+getlimits_
+
+# Ensure pr treats all invalid +page ranges as a file
+for p in +0 +0foo; do
+  returns_ 1 pr "$p" 2>err </dev/null
+  printf '%s\n' "pr: $p: $ENOENT" >exp || framework_failure_
+  compare exp err || fail=1
+done
+
+# number parsing issue
+returns_ 1 pr --pages=-0 2>err </dev/null
+printf '%s\n' "pr: invalid --pages argument '-0'" >exp
+compare exp err || fail=1
+
+# number validation issue
+returns_ 1 pr --pages=0 2>err </dev/null
+printf '%s\n' "pr: invalid page range '0'" >exp
+compare exp err || fail=1
+
+Exit $fail