logo

utils-std

Collection of commonly available Unix tools git clone https://anongit.hacktivis.me/git/utils-std.git/
commit: 7f84b880925e5b2df55b77d980e893d32d17d572
parent 05ba3f9bc9017f2542c002cd2f3d95554a02a102
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date:   Sun,  9 Nov 2025 21:40:04 +0100

test-cmd/timeout.t: switch to tap.sh

Diffstat:

Atest-cmd/timeout.sh40++++++++++++++++++++++++++++++++++++++++
Dtest-cmd/timeout.t34----------------------------------
2 files changed, 40 insertions(+), 34 deletions(-)

diff --git a/test-cmd/timeout.sh b/test-cmd/timeout.sh @@ -0,0 +1,40 @@ +#!/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/timeout" +. "${WD}/test-cmd/tap.sh" + +time_fmt() { + out=$(mktemp time_fmt.XXXXXX) + "$@" 2> "$out" + err=$? + + cut -f1 -d '.' <"$out" + rm -f "$out" + + return $err +} + +t_args --exit=124 longer_sleep '' 0.5 sleep 10 + +t_args shorter_sleep '' 0.5 sleep 0.2 + +t_args true '' 0.5 true +t_args --exit=1 false '' 0.5 false + +t_args --exit=124 kill_longer_sleep '' -s KILL 0.5 sleep 10 + +t_args --exit=124 sigkill_longer_sleep '' -s SIGKILL 0.5 sleep 10 + +t_args --exit=124 sig9_longer_sleep '' -s 9 0.5 sleep 10 + +t_cmd --exit=124 time_longer_sleep_nokill '' time_fmt "$target" -f 0.5 "${WD}/cmd/time" -p sleep 1 + +t_cmd --exit=124 time_longer_sleep '' time_fmt "$target" 0.5 "${WD}/cmd/time" -p sleep 1 + +t_args preserve_status '' -p 0.5 sleep 10 + +wait diff --git a/test-cmd/timeout.t b/test-cmd/timeout.t @@ -1,34 +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 timeout)" = "$TESTDIR/../cmd/timeout" - -Flaky on FreeBSD - $ test "$(uname -s)" != "FreeBSD" || return 80 - - $ timeout 0.5 sleep 10 - [124] - $ timeout 0.5 sleep 0.2 - $ timeout 0.5 true - $ timeout 0.5 false - [1] - - $ timeout -s KILL 0.5 sleep 10 - [124] - $ timeout -s SIGKILL 0.5 sleep 10 - [124] - $ timeout -s 9 0.5 sleep 10 - [124] - - $ timeout -f 0.5 time -p sleep 1 - [124] - $ timeout 0.5 time -p sleep 1 - real 1.\d+ (re) - user 0.\d+ (re) - sys 0.\d+ (re) - [124] - - $ timeout -p 0.5 sleep 10