commit: 0c3e6b2acefd7208f769727c07d71aa2f1d9f013
parent c08a0a892cbeb72851f5e070b2be6745b4db724e
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date: Thu, 24 Jul 2025 11:45:26 +0200
test-cmd/{rmdir,rmdir_long}.t -> test-cmd/rmdir.sh
Diffstat:
3 files changed, 68 insertions(+), 72 deletions(-)
diff --git a/test-cmd/rmdir.sh b/test-cmd/rmdir.sh
@@ -0,0 +1,68 @@
+#!/bin/sh
+# SPDX-FileCopyrightText: 2017 Haelwenn (lanodan) Monnier <contact+utils@hacktivis.me>
+# SPDX-License-Identifier: MPL-2.0
+
+plans=30
+WD=$(dirname "$0")
+target="${WD}/../cmd/rmdir"
+. "${WD}/tap.sh"
+
+t_cmd '' '' mkdir -p no_p/bar
+t 'no_p/bar' 'no_p/bar'
+t_cmd '' '' test -d no_p
+t_cmd '' '' rm -r no_p
+
+t_cmd '' '' mkdir -p p/bar
+t_args 'p/bar' '' -p p/bar
+t_cmd '' '' test '!' -e p
+
+t_cmd '' '' mkdir -p v_no_p/bar
+t_args '-v v_no_p/bar' "\
+rmdir: Removed 'v_no_p/bar'
+" -v v_no_p/bar
+t_cmd '' '' test -d v_no_p
+t_cmd '' '' rm -r v_no_p
+
+t_cmd '' '' mkdir -p v_p/bar
+t_args '-pv v_p/bar' "\
+rmdir: Removed 'v_p/bar'
+rmdir: Removed 'v_p'
+" -pv v_p/bar
+t_cmd '' '' test '!' -e v_p
+
+t_cmd '' '' touch file
+t --exit=1 file file "\
+rmdir: error: Failed removing 'file': Not a directory
+"
+t --exit=1 '-p file' '-p file' "\
+rmdir: error: Failed removing 'file': Not a directory
+"
+t --exit=1 '-v file' '-v file' "\
+rmdir: error: Failed removing 'file': Not a directory
+"
+t --exit=1 '-pv file' '-pv file' "\
+rmdir: error: Failed removing 'file': Not a directory
+"
+t_cmd '' '' rm file
+
+t_cmd '' '' mkdir -p e_not_empty/a/b/c/d empty/a/b/c
+t_args --exit=1 'e_not_empty' "\
+rmdir: error: Failed removing 'e_not_empty/a/b/c': Directory not empty
+" -p e_not_empty/a/b/c empty/a/b/c
+t_cmd '' '' test -d e_not_empty/a/b/c
+t_cmd '' '' test '!' -e empty
+t_cmd '' '' rm -r e_not_empty
+
+if grep -q HAS_GETOPT_LONG "${WD}/../config.h"; then
+ t_cmd 'mkdir:e_not_empty-ign' '' mkdir -p e_not_empty-ign/a/b/c/d empty-ign/a/b/c
+ t_args 'ignore-fail-on-non-empty' '' -p --ignore-fail-on-non-empty e_not_empty-ign/a/b/c empty-ign/a/b/c
+ t_cmd 'test:e_not_empty-ign/a/b/c' '' test -d e_not_empty-ign/a/b/c
+ t_cmd 'test:empty-ign' '' test '!' -e empty-ign
+ t_cmd 'rm:e_not_empty-ign' '' rm -r e_not_empty-ign
+else
+ skip 'mkdir:e_not_empty-ign'
+ skip 'ignore-fail-on-non-empty'
+ skip 'test:e_not_empty-ign/a/b/c'
+ skip 'test:empty-ign'
+ skip 'rm:e_not_empty-ign'
+fi
diff --git a/test-cmd/rmdir.t b/test-cmd/rmdir.t
@@ -1,54 +0,0 @@
-#!/usr/bin/env cram
-# SPDX-FileCopyrightText: 2017 Haelwenn (lanodan) Monnier <contact+utils@hacktivis.me>
-# SPDX-License-Identifier: MPL-2.0
-
- $ export PATH="$TESTDIR/../cmd:$PATH"
-
- $ test "$(command -v rmdir)" = "$TESTDIR/../cmd/rmdir"
-
- $ mkdir -p no_p/bar
- $ rmdir no_p/bar
- $ test -d no_p
- $ rm -r no_p
-
- $ mkdir -p p/bar
- $ rmdir -p p/bar
- $ test ! -e p
-
- $ mkdir -p v_no_p/bar
- $ rmdir -v v_no_p/bar
- rmdir: Removed 'v_no_p/bar'
- $ test -d v_no_p
- $ rm -r v_no_p
-
- $ mkdir -p v_p/bar
- $ rmdir -pv v_p/bar
- rmdir: Removed 'v_p/bar'
- rmdir: Removed 'v_p'
- $ test ! -e v_p
-
- $ touch file
- $ rmdir file
- rmdir: error: Failed removing 'file': Not a directory
- [1]
- $ rmdir -p file
- rmdir: error: Failed removing 'file': Not a directory
- [1]
- $ rmdir -v file
- rmdir: error: Failed removing 'file': Not a directory
- [1]
- $ rmdir -pv file
- rmdir: error: Failed removing 'file': Not a directory
- [1]
- $ rm file
-
- $ mkdir -p e_not_empty/a/b/c/d empty/a/b/c
- $ rmdir -p e_not_empty/a/b/c empty/a/b/c
- rmdir: error: Failed removing 'e_not_empty/a/b/c': Directory not empty
- [1]
- $ test -d e_not_empty/a/b/c
- $ test ! -e empty
- $ rm -r e_not_empty
-
- $ find .
- .
diff --git a/test-cmd/rmdir_long.t b/test-cmd/rmdir_long.t
@@ -1,18 +0,0 @@
-#!/usr/bin/env cram
-# SPDX-FileCopyrightText: 2017 Haelwenn (lanodan) Monnier <contact+utils@hacktivis.me>
-# SPDX-License-Identifier: MPL-2.0
-
- $ export PATH="$TESTDIR/../cmd:$PATH"
-
- $ test "$(command -v rmdir)" = "$TESTDIR/../cmd/rmdir"
-
- $ grep -q HAS_GETOPT_LONG "${TESTDIR}/../config.h" || return 80
-
- $ mkdir -p e_not_empty-ign/a/b/c/d empty-ign/a/b/c
- $ rmdir -p --ignore-fail-on-non-empty e_not_empty-ign/a/b/c empty-ign/a/b/c
- $ test -d e_not_empty-ign/a/b/c
- $ test ! -e empty-ign
- $ rm -r e_not_empty-ign
-
- $ find .
- .