bats-core: update to 1.13.0

This commit is contained in:
Roy Storey
2025-11-24 21:10:58 +13:00
committed by Renee Otten
parent f379e11e85
commit 81e6c72cc5
5 changed files with 45 additions and 71 deletions
+12 -10
View File
@@ -3,7 +3,7 @@
PortSystem 1.0
PortGroup github 1.0
github.setup bats-core bats-core 1.4.1 v
github.setup bats-core bats-core 1.13.0 v
revision 0
categories sysutils
platforms any
@@ -17,23 +17,25 @@ long_description \
github.tarball_from archive
checksums rmd160 86429672c062f4736d49adaaf7302e31ab853f59 \
sha256 bff517da043ae24440ec8272039f396c2a7907076ac67693c0f18d4a17c08f7d \
size 98964
checksums rmd160 ef1ce0fd2f14396ec5d46b4503537ee4e1221097 \
sha256 a85e12b8828271a152b338ca8109aa23493b57950987c8e6dff97ba492772ff3 \
size 178709
patchfiles patch-test-bats.diff \
patch-test-parallel.diff
patchfiles patch-libexec-bats.diff \
patch-test-timeout.diff
depends_run port:bash
depends_run port:bash \
port:parallel
use_configure no
build {}
# test from bats-core github action
# depends_test port:parallel
test.cmd ./bin/bats --formatter tap
test.env TERM=linux BATS_NO_PARALLELIZE_ACROSS_FILES=1 BATS_NUMBER_OF_PARALLEL_JOBS=2
test.cmd ./bin/bats
test.pre_args-prepend --formatter tap --print-output-on-failure
test.env TERM=linux
test.run yes
destroot.cmd ./install.sh
destroot.args ${destroot}${prefix}
destroot.args ${destroot}${prefix} lib
destroot.target-delete install
@@ -0,0 +1,15 @@
--- libexec/bats-core/bats
+++ libexec/bats-core/bats
@@ -128,9 +128,11 @@ export BATS_LINE_REFERENCE_FORMAT=${BATS_LINE_REFERENCE_FORMAT-comma_line}
if [[ ! -d "${BATS_TMPDIR}" ]]; then
printf "Error: BATS_TMPDIR (%s) does not exist or is not a directory" "${BATS_TMPDIR}" >&2
exit 1
-elif [[ ! -w "${BATS_TMPDIR}" ]]; then
+elif ! touch "${BATS_TMPDIR}/.bats_tmp_test_$$" 2>/dev/null; then
printf "Error: BATS_TMPDIR (%s) is not writable" "${BATS_TMPDIR}" >&2
exit 1
+else
+ rm -f "${BATS_TMPDIR}/.bats_tmp_test_$$"
fi
arguments=()
@@ -1,25 +0,0 @@
--- test/bats.bats.orig 2021-09-21 21:37:27.000000000 +1200
+++ test/bats.bats 2021-09-21 21:39:26.000000000 +1200
@@ -782,14 +782,14 @@
[ "${lines[0]}" = "Error: BATS_TMPDIR (${TMPDIR}) does not exist or is not a directory" ]
}
-@test "Setting BATS_TMPDIR is ignored" {
- unset TMPDIR # ensure we don't have a predefined value
- expected="/tmp" run bats "$FIXTURE_ROOT/BATS_TMPDIR.bats"
- echo "$output"
- [ "$status" -eq 0 ]
- BATS_TMPDIR="${BATS_RUN_TMPDIR}" expected="/tmp" run bats "$FIXTURE_ROOT/BATS_TMPDIR.bats"
- [ "$status" -eq 0 ]
-}
+# @test "Setting BATS_TMPDIR is ignored" {
+# unset TMPDIR # ensure we don't have a predefined value
+# expected="/tmp" run bats "$FIXTURE_ROOT/BATS_TMPDIR.bats"
+# echo "$output"
+# [ "$status" -eq 0 ]
+# BATS_TMPDIR="${BATS_RUN_TMPDIR}" expected="/tmp" run bats "$FIXTURE_ROOT/BATS_TMPDIR.bats"
+# [ "$status" -eq 0 ]
+# }
@test "Parallel mode works on MacOS with over subscription (issue #433)" {
type -p parallel &>/dev/null || skip "--jobs requires GNU parallel"
@@ -1,36 +0,0 @@
--- test/parallel.bats.orig 2021-09-21 21:40:08.000000000 +1200
+++ test/parallel.bats 2021-09-21 21:41:54.000000000 +1200
@@ -113,19 +113,20 @@
[[ "${#lines[@]}" -eq 3 ]]
}
-@test "parallelity factor is met exactly" {
- parallelity=5 # run the 10 tests in 2 batches with 5 test each
- bats --jobs $parallelity "$FIXTURE_ROOT/parallel_factor.bats" & # run in background to avoid blocking
- # give it some time to start the tests
- sleep 2
- # find how many semaphores are started in parallel; don't count grep itself
- run bash -c "ps -ef | grep bats-exec-test | grep parallel/parallel_factor.bats | grep -v grep"
- echo "$output"
-
- # This might fail spuriously if we got bad luck with the scheduler
- # and hit the transition between the first and second batch of tests.
- [[ "${#lines[@]}" -eq $parallelity ]]
-}
+# Processes with sandboxing enabled can not run setuid binaries.
+# @test "parallelity factor is met exactly" {
+# parallelity=5 # run the 10 tests in 2 batches with 5 test each
+# bats --jobs $parallelity "$FIXTURE_ROOT/parallel_factor.bats" & # run in background to avoid blocking
+# # give it some time to start the tests
+# sleep 2
+# # find how many semaphores are started in parallel; don't count grep itself
+# run bash -c "ps -ef | grep bats-exec-test | grep parallel/parallel_factor.bats | grep -v grep"
+# echo "$output"
+#
+# # This might fail spuriously if we got bad luck with the scheduler
+# # and hit the transition between the first and second batch of tests.
+# [[ "${#lines[@]}" -eq $parallelity ]]
+# }
@test "parallel mode correctly forwards failure return code" {
run bats --jobs 2 "$FIXTURE_ROOT/../bats/failing.bats"
@@ -0,0 +1,18 @@
--- test/timeout.bats
+++ test/timeout.bats
@@ -16,6 +16,7 @@ bats_require_minimum_version 1.5.0
@test "test longer than timeout" {
SECONDS=0
+ if ! ps -ef 2>/dev/null; then skip "sandbox environment cannot execute ps"; fi
reentrant_run ! env BATS_TEST_TIMEOUT=1 SLEEP=10 bats -T "$FIXTURE_ROOT/sleep2.bats"
[ "${lines[0]}" == '1..1' ]
[[ "${lines[1]}" == 'not ok 1 my sleep 10 in '*'ms # timeout after 1s' ]] || false
@@ -26,6 +27,7 @@ bats_require_minimum_version 1.5.0
@test "run longer than timeout" {
SECONDS=0
+ if ! ps -ef 2>/dev/null; then skip "sandbox environment cannot execute ps"; fi
reentrant_run ! env BATS_TEST_TIMEOUT=1 SLEEP=10 bats -T "$FIXTURE_ROOT/run sleep.bats" --print-output-on-failure
[ "${lines[0]}" == '1..1' ]
[[ "${lines[1]}" == 'not ok 1 my sleep 10 in '*'ms # timeout after 1s' ]] || false