commit: c08a0a892cbeb72851f5e070b2be6745b4db724e parent 665aa6080f621075954c70547c967fb222ce726c Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me> Date: Thu, 24 Jul 2025 11:20:45 +0200 test-cmd/ln.t -> test-cmd/ln.shDiffstat:
A | test-cmd/ln.sh | 95 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
D | test-cmd/ln.t | 99 | ------------------------------------------------------------------------------- |
2 files changed, 95 insertions(+), 99 deletions(-)diff --git a/test-cmd/ln.sh b/test-cmd/ln.sh
@@ -0,0 +1,95 @@ +#!/bin/sh +# SPDX-FileCopyrightText: 2017 Haelwenn (lanodan) Monnier <contact+utils@hacktivis.me> +# SPDX-License-Identifier: MPL-2.0 + +plans=55 +WD=$(dirname "$0") +target="${WD}/../cmd/ln" +. "${WD}/tap.sh" + +t_readlink() { + t_cmd "readlink:$1 -> $2" "$2 +" readlink "$1" +} + +t_args --exit=1 hard_enoent \ + "ln: error: Failed creating hard link from 'hard_enoent_src' to 'hard_enoent_dest': No such file or directory +" \ + hard_enoent_src hard_enoent_dest + +t_args --exit=1 soft_enoent \ + "ln: error: Failed creating symlink 'hard_enoent_dest/hard_enoent_ref1': No such file or directory +" \ + -s hard_enoent_ref1 hard_enoent_ref2 hard_enoent_dest + +t_cmd '' '' touch hard_file_src +t_args 'hard_file' '' hard_file_src hard_file_dest +t_cmd '' '' test -f hard_file_dest +t_cmd '' '' rm hard_file_src hard_file_dest + +t_cmd '' '' touch hard_file_src1 ./hard_file_src2 +t_cmd '' '' mkdir hard_dir_dest +t_args 'hard_file_dir' '' hard_file_src1 ./hard_file_src2 hard_dir_dest +t_cmd '' '' test -f hard_dir_dest/hard_file_src1 +t_cmd '' '' test -f hard_dir_dest/hard_file_src2 +t_cmd '' '' rm hard_file_src1 hard_file_src2 +t_cmd '' '' rm -r hard_dir_dest + +t_args 'sym_enoent' '' -s sym_enoent_ref sym_enoent_dest +t_readlink sym_enoent_dest sym_enoent_ref +t_cmd '' '' rm sym_enoent_dest + + +t_args --exit=1 'sym_enoent2' \ +"ln: error: Failed creating symlink 'sym_enoent_dest/sym_enoent_ref1': No such file or directory +" \ + -s sym_enoent_ref1 sym_enoent_ref2 sym_enoent_dest + +t_cmd '' '' mkdir sym_dir_slash +t_args 'sym_dir_slash' '' -s sym_enoent_ref1 ./sym_enoent_ref2 sym_dir_slash/ +t_readlink sym_dir_slash/sym_enoent_ref1 sym_enoent_ref1 +t_readlink sym_dir_slash/sym_enoent_ref2 ./sym_enoent_ref2 +t_cmd '' '' rm -r sym_dir_slash + +t_cmd '' '' mkdir sym_dir_noslash +t_args 'sym_dir_noslash' '' -s sym_enoent_ref1 ./sym_enoent_ref2 sym_dir_noslash +t_readlink sym_dir_noslash/sym_enoent_ref1 sym_enoent_ref1 +t_readlink sym_dir_noslash/sym_enoent_ref2 ./sym_enoent_ref2 +t_cmd '' '' rm -r sym_dir_noslash + +t_cmd '' '' touch force_symlink +t_args --exit=1 'force_symlink' "ln: error: Destination 'force_symlink' already exists +" -s foo force_symlink +t_cmd --exit=1 '' '' test -L force_symlink +t_args 'force_symlink:force' '' -sf foo force_symlink +t_cmd '' '' test -L force_symlink +t_cmd '' '' rm force_symlink + +t_cmd '' '' mkdir n_directory +t_args 'n_directory:n_dir_symlink' '' -s n_directory n_dir_symlink +t_args --exit=1 'n_directory:sn' "ln: error: Destination 'n_dir_symlink' already exists +" -sn //example.org n_dir_symlink +t_readlink n_dir_symlink n_directory +t_args 'n_dir_symlink:snf' '' -snf //example.org n_dir_symlink +t_readlink n_dir_symlink //example.org +t_cmd '' '' rm -r n_directory n_dir_symlink + +t_cmd '' '' mkdir e_target_dir +t_args 'e_ref_dir:e_target_dir' '' -s e_ref_dir e_target_dir +t_cmd '' '' test '!' -e e_ref_dir +t_cmd '' '' test '!' -L e_target_dir +t_cmd '' '' test -d e_target_dir +t_cmd '' '' test -L e_target_dir/e_ref_dir +echo mere copy > e_src_dir +t_cmd '' '' test -f e_src_dir +t_args 'e_src_dir:e_target_dir' '' e_src_dir e_target_dir +echo hardlink > e_src_dir +t_cmd '' '' test -d e_target_dir +t_cmd '' '' test -f e_target_dir/e_src_dir +t_cmd '' 'hardlink +' cat e_target_dir/e_src_dir +t_cmd '' '' rm -r e_target_dir e_src_dir + +t_args 'implicit_dest' '' -sn //example.org +t_readlink ./example.org //example.org +t_cmd '' '' rm ./example.orgdiff --git a/test-cmd/ln.t b/test-cmd/ln.t
@@ -1,99 +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 ln)" = "$TESTDIR/../cmd/ln" - - $ ln hard_enoent_src hard_enoent_dest - ln: error: Failed creating hard link from 'hard_enoent_src' to 'hard_enoent_dest': No such file or directory - [1] - - $ ln -s hard_enoent_ref1 hard_enoent_ref2 hard_enoent_dest - ln: error: Failed creating symlink 'hard_enoent_dest/hard_enoent_ref1': No such file or directory - [1] - - $ touch hard_file_src - $ ln hard_file_src hard_file_dest - $ test -f hard_file_dest - $ rm hard_file_src hard_file_dest - - $ touch hard_file_src1 ./hard_file_src2 - $ mkdir hard_dir_dest - $ ln hard_file_src1 ./hard_file_src2 hard_dir_dest - $ test -f hard_dir_dest/hard_file_src1 - $ test -f hard_dir_dest/hard_file_src2 - $ rm hard_file_src1 hard_file_src2 - $ rm -r hard_dir_dest - - $ ln -s sym_enoent_ref sym_enoent_dest - $ readlink sym_enoent_dest - sym_enoent_ref - $ rm sym_enoent_dest - - $ ln -s sym_enoent_ref1 sym_enoent_ref2 sym_enoent_dest - ln: error: Failed creating symlink 'sym_enoent_dest/sym_enoent_ref1': No such file or directory - [1] - - $ mkdir sym_dir_slash - $ ln -s sym_enoent_ref1 ./sym_enoent_ref2 sym_dir_slash/ - $ readlink sym_dir_slash/sym_enoent_ref1 - sym_enoent_ref1 - $ readlink sym_dir_slash/sym_enoent_ref2 - ./sym_enoent_ref2 - $ rm -r sym_dir_slash - - $ mkdir sym_dir_noslash - $ ln -s sym_enoent_ref1 ./sym_enoent_ref2 sym_dir_noslash - $ readlink sym_dir_noslash/sym_enoent_ref1 - sym_enoent_ref1 - $ readlink sym_dir_noslash/sym_enoent_ref2 - ./sym_enoent_ref2 - $ rm -r sym_dir_noslash - - $ touch force_symlink - $ ln -s foo force_symlink - ln: error: Destination 'force_symlink' already exists - [1] - $ test -L force_symlink - [1] - $ ln -sf foo force_symlink - $ test -L force_symlink - $ rm force_symlink - - $ mkdir n_directory - $ ln -s n_directory n_dir_symlink - $ ln -sn //example.org n_dir_symlink - ln: error: Destination 'n_dir_symlink' already exists - [1] - $ readlink n_dir_symlink - n_directory - $ ln -snf //example.org n_dir_symlink - $ readlink n_dir_symlink - //example.org - $ rm -r n_directory n_dir_symlink - - $ mkdir e_target_dir - $ ln -s e_ref_dir e_target_dir - $ test ! -e e_ref_dir - $ test ! -L e_target_dir - $ test -d e_target_dir - $ test -L e_target_dir/e_ref_dir - $ echo mere copy > e_src_dir - $ test -f e_src_dir - $ ln e_src_dir e_target_dir - $ echo hardlink > e_src_dir - $ test -d e_target_dir - $ test -f e_target_dir/e_src_dir - $ cat e_target_dir/e_src_dir - hardlink - $ rm -r e_target_dir e_src_dir - - $ ln -sn //example.org - $ readlink ./example.org - //example.org - $ rm ./example.org - - $ find . - .