commit: 3a33e4b67e6eee4b962a0f238019c53464e515df
parent ee232812cef64b91b9ed26cb079a2842c08ac1d1
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date: Wed, 2 Jul 2025 19:49:15 +0200
test-cmd/install.sh: add
Diffstat:
2 files changed, 28 insertions(+), 52 deletions(-)
diff --git a/test-cmd/install.sh b/test-cmd/install.sh
@@ -0,0 +1,28 @@
+#!/bin/sh
+# SPDX-FileCopyrightText: 2017 Haelwenn (lanodan) Monnier <contact+utils@hacktivis.me>
+# SPDX-License-Identifier: MPL-2.0
+
+plans=10
+WD="$(dirname "$0")"
+target="${WD}/../cmd/install"
+. "${WD}/tap.sh"
+
+env > foo
+mkdir bar
+
+t destnamed 'foo bar/foo_named' ''
+t_cmd destnamed_cmp '' cmp foo bar/foo_named
+
+t dir 'foo bar/' ''
+t_cmd dir_cmp '' cmp foo bar/foo
+
+t mode '-m755 foo bar/exe' ''
+t_cmd mode_test '' test -x bar/exe
+
+t createdirs '-D foo bar/baz/foo'
+t_cmd createdirs_cmp '' cmp foo bar/baz/foo
+
+t makedirs '-d bar/makedirs'
+t_cmd makedirs_test '' test -d bar/makedirs
+
+rm -r foo bar
diff --git a/test-cmd/install.t b/test-cmd/install.t
@@ -4,59 +4,7 @@
$ export PATH="$TESTDIR/../cmd:$PATH"
-# Using chmod -v + to get permission bits, + with no perm nor who doesn't changes mode bits
-
$ test "$(command -v install)" = "$TESTDIR/../cmd/install"
- $ test "$(command -v chmod)" = "$TESTDIR/../cmd/chmod"
-
- $ umask 002
-
- $ test ! -e src
- $ touch src
- $ install -m 755 src dest
- $ chmod -v 755 dest
- chmod: Permissions already set to 00755/-rwxr-xr-x for 'dest'
- $ chmod -v 755 src
- chmod: Permissions changed from 00664/-rw-rw-r-- to 00755/-rwxr-xr-x for 'src'
- $ rm -f src dest
-
-Integrity check
- $ seq 1 2048 > content
- $ wc -c content
- 9133 content
- $ install content content.inst
- $ wc -c content content.inst
- 9133 content
- 9133 content.inst
- 18266 total
- $ cmp content content.inst
- $ rm content content.inst
-
-install -d
- $ test ! -e foo.d
- $ install -d foo.d
- $ test -d foo.d
- $ rm -fr foo.d
-
- $ test ! -e enoent.d
- $ install -d enoent.d/dir
- $ test -d enoent.d
- $ test -d enoent.d/dir
- $ rm -fr enoent.d
-
- $ install -d -m 755 dest.d
- $ chmod -v 755 dest.d
- chmod: Permissions already set to 00755/drwxr-xr-x for 'dest.d'
- $ rm -fr dest.d
-
-install -D, single src
- $ test ! -e gramps
- $ touch FooD
- $ install -D FooD gramps/parent/child
- $ test -d gramps/parent
- $ test -f gramps/parent/child
- $ test -e FooD
- $ rm -r FooD gramps
install -D, multi src
$ test ! -e gran