On 07/01/19 23:16, Bernhard Voelker wrote:
> [forwarding from gnu-annou...@gnu.org]
> 
> On 1/7/19 11:03 PM, Chet Ramey wrote:
>> Introduction
>> ============
>>
>> The first public release of bash-5.0 is now available with the URLs
> [...]
> 
>> +========== NEWS ==========+
> [...]
>> d. New loadable builtins: rm, stat, fdflags.
> [...]
>> nn. There is a new `seq' loadable builtin.
> 
> Doesn't that mean the we'll have to guard the execution of our
> rm, stat and seq utilities in the tests with 'env TOOL' or
> '\TOOL' like we already do e.g. for 'test'?

Huh rm, really?

Anyway that reminds me I was playing around with
centrally overriding builtins in our test suite in the attached.
It does slow things down somewhat.

cheers,
Pádraig

>From c548114b27c59fc6671a891420bd78e2316a25ff Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?P=C3=A1draig=20Brady?= <p...@draigbrady.com>
Date: Sat, 3 Feb 2018 20:25:27 -0800
Subject: [PATCH] tests: prefer our commands over shell builtins

* init.cfg: Iterate over potential builtins and
use our equivalent if built.

base speed
real    1m7.854s
user    1m29.490s
sys     1m42.176s

check subset/leave builtins (neglible overhead for tests)
real    1m3.191s
user    1m34.564s
sys     1m48.687s  # neglible overhead doing builtin check

check subset/disable builtins (the attached patch)
real    1m22.739s  # not much extra wall time on this 4 core system
user    1m49.510s
sys     2m30.901s  # more overhead though starting the processes

check all commands/disable builtins (significant overhead checking all)
real    1m53.188s  # significant overhead checking all commands
user    2m41.149s
sys     3m59.805s

doing in TESTS_ENVIRONMENT is still once per test so no advantage.
Look into doing once per test run. I.E. generate script to source
once per test run.
---
 init.cfg | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/init.cfg b/init.cfg
index 47695a9..e39879e 100644
--- a/init.cfg
+++ b/init.cfg
@@ -723,4 +723,14 @@ require_gnu_()
     || skip_ 'not running on GNU/Hurd'
 }
 
+# Prefer our commands over shell builtins
+is_builtin_() { type "$1" 2>/dev/null | grep builtin >/dev/null; }
+# Note we don't check all $built_programs as it adds noticeable overhead
+# Hmm we'll need check_built_ if doing this!
+# And then don't need is_builtin_!
+for cmd in echo kill printf pwd test true false; do
+  [ "$cmd" = '[' ] && continue
+  is_builtin_ "$cmd" && eval "$cmd() { env $cmd \"\$@\"; }"
+done
+
 sanitize_path_
-- 
2.9.3

Reply via email to