tests/functions: Don't compare diff output

Turns out busybox diff (used on alpine) defaults to unified output,
which we can't use because that prints filenames, and those are
tempfiles made by psub.

Instead, we use builtins to print the first line and compare the others.
This commit is contained in:
Fabian Homborg 2018-12-16 20:23:41 +01:00
parent 54438f8dc1
commit ba8748877a
2 changed files with 18 additions and 10 deletions

View File

@ -43,8 +43,18 @@ functions -q name3a
or echo "Function name3a not found as expected"
logmsg Checking that the copied functions are identical other than the name
diff (functions name1 | psub) (functions name1a | psub)
diff (functions name3 | psub) (functions name3a | psub)
# Poor man's diff because on some systems diff defaults to unified output, but that prints filenames.
#
set -l name1 (functions name1)
set -l name1a (functions name1a)
set -l name3 (functions name3)
set -l name3a (functions name3a)
echo $name1[1]
echo $name1a[1]
test "$name1[2..-1]" = "$name1a[2..-1]"; and echo "1 = 1a"
echo $name3[1]
echo $name3a[1]
test "$name3[2..-1]" = "$name3a[2..-1]"; and echo "3 = 3a"
logmsg Checking reserved names
function test; echo banana; end

View File

@ -62,14 +62,12 @@ Function name4 not found as expected
####################
# Checking that the copied functions are identical other than the name
1c1
< function name1 --argument arg1 arg2
---
> function name1a --argument arg1 arg2
1c1
< function name3 --argument arg1 arg2
---
> function name3a --argument arg1 arg2
function name1 --argument arg1 arg2
function name1a --argument arg1 arg2
1 = 1a
function name3 --argument arg1 arg2
function name3a --argument arg1 arg2
3 = 3a
####################
# Checking reserved names