Re: [hackers] [sbase][PATCH] Test framework created. See tests/README for details. Individual test cases can be run from tests dir using command line. Entire test suite can be run using: make && make tests
Hi,
On Thu, Nov 06, 2025 at 09:47:56PM +1100, Xan Phung wrote:
> I notice 0001-echo.sh generates an expected file & an output file using $$
> (PID) - so essentially a random number with no way to know which tests
> produced which output.
You have a test.log file with the diff, and that file has a header with
the name of the test. In case that for any reason you need the file, you
can just edit the file and remove the rm. Apply the KISS rule and keep it
simple, and please don't force policies. In fact, that test does not need
any file at all:
#!/bin/sh
s="`../echo -n --hello-- --world--!`
if test "$s" != '--hello-- --world--!'
then
echo "$s != '--hello-- --world--!'"
exit 1
fi
If you impose policies like having a expected file then this simpler
shell script couldn't be used. In fact, for something like the 80%
of the test cases in sabse you don't need a file.
> I recommend instead scripts generate files using the names "$0.expected"
> and "$0.out" (for test output) - ie: prefix these files with test script's
> name, as "$0.out" becomes "0001-echo.sh.out", etc. This allows a whole
> batch of tests to be run, then the output of each test can later be
> examined by the user at their leisure & diff'ed manually by the user,
> without tracing which PID's belong to which tests scripts.
If you need the file of a test just re execute it. If your test is not
reproductible then fix it.
> 2. Shell variables can be good (optional) programming practice (like how
> #define MAX_STRING 100 might be used in self contained C source files):
Environment variables were not designed for that. You want something like
global variables. No.
I would proceed to push the previous diff with that enhanced version that
does not use a temporary file.
Regards,
Received on Fri Nov 07 2025 - 14:12:09 CET
This archive was generated by hypermail 2.3.0
: Fri Nov 07 2025 - 14:12:56 CET