logo

utils-std

Collection of commonly available Unix tools git clone https://anongit.hacktivis.me/git/utils-std.git
commit: 172101193b589ab61cb8c4601eb490391b9c0dec
parent 6c8cd66ed06400d73fdbfbb568ab11852dc726c5
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date:   Tue, 17 Sep 2024 15:18:07 +0200

test-cmd/readlink: Change from cram to tap.sh

Diffstat:

Mtest-cmd/Kyuafile1+
Atest-cmd/readlink.sh33+++++++++++++++++++++++++++++++++
Dtest-cmd/readlink.t36------------------------------------
3 files changed, 34 insertions(+), 36 deletions(-)

diff --git a/test-cmd/Kyuafile b/test-cmd/Kyuafile @@ -33,6 +33,7 @@ tap_test_program{name="mktemp.sh", required_files=basedir.."/cmd/mktemp", timeou tap_test_program{name="paste.sh", required_files=basedir.."/cmd/paste", timeout=1} tap_test_program{name="pathchk.sh", required_files=basedir.."/cmd/pathchk", timeout=1} tap_test_program{name="pwd.sh", required_files=basedir.."/cmd/pwd", timeout=1} +tap_test_program{name="readlink.sh", required_files=basedir.."/cmd/readlink", timeout=1} tap_test_program{name="realpath.sh", required_files=basedir.."/cmd/realpath", timeout=1} tap_test_program{name="seq.sh", required_files=basedir.."/cmd/seq", timeout=1} tap_test_program{name="sha1sum.sh", required_files=basedir.."/cmd/sha1sum", timeout=1} diff --git a/test-cmd/readlink.sh b/test-cmd/readlink.sh @@ -0,0 +1,33 @@ +#!/bin/sh +# SPDX-FileCopyrightText: 2017 Haelwenn (lanodan) Monnier <contact+utils@hacktivis.me> +# SPDX-License-Identifier: MPL-2.0 + +target="$(dirname "$0")/../cmd/readlink" +plans=12 +. "$(dirname "$0")/tap.sh" + +t --exit=1 noargs '' 'readlink: Expected one file as argument, got 0 +Usage: readlink [-f|-e] [-n|-z] file... +' + +t_cmd create_foobar '' ln -s //example.org/ foobar + +t read_foobar foobar '//example.org/ +' + +t read_foobar_no_nl '-n foobar' '//example.org/' + +t_cmd rm:foobar '' rm foobar + +t --exit=1 enoent /var/empty/e/no/ent "readlink: Error: Failed reading symbolic link of '/var/empty/e/no/ent': No such file or directory +" + +t_cmd touch:regular '' touch regular +t --exit=1 readlink:regular regular "readlink: Error: Failed reading symbolic link of 'regular': Invalid argument +" +t_cmd rm:regular '' rm regular + +t_cmd mkdir:dir '' mkdir dir +t --exit=1 readlink:dir dir "readlink: Error: Failed reading symbolic link of 'dir': Invalid argument +" +t_cmd rm:dir '' rm -r dir diff --git a/test-cmd/readlink.t b/test-cmd/readlink.t @@ -1,36 +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 readlink)" = "$TESTDIR/../cmd/readlink" - - $ ln -s //example.org/ foobar - $ readlink foobar - //example.org/ - $ readlink -n foobar - //example.org/ (no-eol) - - $ readlink - readlink: Expected one file as argument, got 0 - Usage: readlink [-f|-e] [-n|-z] file... - [1] - $ readlink foo bar - readlink: Error: Failed reading symbolic link of 'foo': No such file or directory - [1] - - $ test ! -f enoent - $ readlink enoent - readlink: Error: Failed reading symbolic link of 'enoent': No such file or directory - [1] - - $ touch regular - $ readlink regular - readlink: Error: Failed reading symbolic link of 'regular': Invalid argument - [1] - - $ mkdir dir - $ readlink dir - readlink: Error: Failed reading symbolic link of 'dir': Invalid argument - [1]