logo

utils-std

Collection of commonly available Unix tools
commit: 28c0d4015ffb52a95c003055acfadfc01c899560
parent 2892d28528a0820a3842b9b0289c48b2a2905e35
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date:   Tue, 30 Jul 2024 08:56:23 +0200

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

Diffstat:

Mtest-cmd/Kyuafile1+
Atest-cmd/cmp.sh32++++++++++++++++++++++++++++++++
Dtest-cmd/cmp.t47-----------------------------------------------
3 files changed, 33 insertions(+), 47 deletions(-)

diff --git a/test-cmd/Kyuafile b/test-cmd/Kyuafile @@ -15,6 +15,7 @@ tap_test_program{name="base64.sh", required_files=basedir.."/cmd/base64", timeou tap_test_program{name="basename.sh", required_files=basedir.."/cmd/basename", timeout=1} tap_test_program{name="cat.sh", required_files=basedir.."/cmd/cat", timeout=1} tap_test_program{name="chmod.sh", required_files=basedir.."/cmd/chmod", timeout=1} +tap_test_program{name="cmp.sh", required_files=basedir.."/cmd/cmp", timeout=1} tap_test_program{name="date.sh", required_files=basedir.."/cmd/date", timeout=1} tap_test_program{name="dirname.sh", required_files=basedir.."/cmd/dirname", timeout=1} tap_test_program{name="echo.sh", required_files=basedir.."/cmd/echo", timeout=1} diff --git a/test-cmd/cmp.sh b/test-cmd/cmp.sh @@ -0,0 +1,32 @@ +#!/bin/sh +# SPDX-FileCopyrightText: 2017 Haelwenn (lanodan) Monnier <contact+utils@hacktivis.me> +# SPDX-License-Identifier: MPL-2.0 + +target="$(dirname "$0")/../cmd/cmp" +plans=8 +. "$(dirname "$0")/tap.sh" + +printf foo > foo +printf bar > bar + +t foofoo 'foo foo' +t barbar 'bar bar' + +t --exit=1 foobar 'foo bar' 'foo bar differ: char 1, line 1 +' +t --exit=1 barfoo 'bar foo' 'bar foo differ: char 1, line 1 +' + +t --exit=1 s_foobar '-s foo bar' +t --exit=1 s_barfoo '-s bar foo' + +rm foo bar + +seq 1 3 > seq_1_3 +seq 1 2 > seq_1_2 + +t --exit=1 seq_1_3-1_2 'seq_1_3 seq_1_2' 'cmp: EOF on seq_1_2 line 3 +' +t --exit=1 s_seq_1_3-1_2 '-s seq_1_3 seq_1_2' + +rm seq_1_3 seq_1_2 diff --git a/test-cmd/cmp.t b/test-cmd/cmp.t @@ -1,47 +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 cmp)" = "$TESTDIR/../cmd/cmp" - - $ printf 'foo' > foo - $ printf 'bar' > bar - $ cmp foo foo - $ cmp bar bar - $ cmp foo bar - foo bar differ: char 1, line 1 - [1] - $ cmp -s foo bar - [1] - $ cmp bar foo - bar foo differ: char 1, line 1 - [1] - $ cmp -s bar foo - [1] - - $ seq 1 3 > foo - $ seq 1 2 > bar - $ cmp foo bar - cmp: EOF on bar line 3 - [1] - $ cmp -s foo bar - [1] - $ echo '3 different' > bar - $ cmp foo bar - foo bar differ: char 1, line 1 - [1] - $ cmp -s foo bar - [1] - - $ seq 1 3 > foo - $ seq 1 2 > bar - $ cmp -l foo bar - cmp: EOF on bar line 3 - [1] - $ cmp -n 4 foo bar - - $ rm foo bar - $ find . - .