mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-25 04:13:08 +00:00
Fix for bad-switch test failing on Darwin; system-specific output.
Because the 'getopt' library differs between systems, it's likely that there will be different output. This is the case between the GNU-based Linux and the BSD-based Darwin, for the 'getopt' library, it seems. It causes the tests to produce different results. To allow us to test, and check for regressions, on the different platforms, the invocation code has been updated to allow a system-specific suffix to be used on the test files. If this suffix is found, the test will also be flagged as being system-specific which should ensure the change in behaviour is noted.
This commit is contained in:
parent
8d83c967d3
commit
bf2a9f3835
2 changed files with 37 additions and 3 deletions
|
@ -27,6 +27,13 @@
|
|||
# processed before comparison with the
|
||||
# 'tests/invocation/<name>.(out|err)' files. A missing file is
|
||||
# considered to be no output.
|
||||
# Either file may be given a further suffix of '.<system name>'
|
||||
# which will be used in preference to the default. This allows
|
||||
# the expected output to change depending on the system being
|
||||
# used - to allow for differences in behaviour.
|
||||
# The '<system name>' can be found with 'uname -s'.
|
||||
# This facility should be used sparingly as system differences
|
||||
# will confuse users.
|
||||
#
|
||||
# * The file 'tests/invocation/<name>.grep' is used to select the
|
||||
# sections of the file we are interested in within the stdout.
|
||||
|
@ -83,6 +90,12 @@ term_cyan="$(tput setaf 6)"
|
|||
term_white="$(tput setaf 7)"
|
||||
term_reset="$(tput sgr0)"
|
||||
|
||||
# Which system are we on.
|
||||
# fish has slightly different behaviour depending on the system it is
|
||||
# running on (and the libraries that it is linked with), so for special
|
||||
# cases, we'll use a suffixed file.
|
||||
system_name="$(uname -s)"
|
||||
|
||||
|
||||
# Check whether we have the 'colordiff' tool - if not, we'll revert to
|
||||
# boring regular 'diff'.
|
||||
|
@ -117,7 +130,7 @@ function clean_environment() {
|
|||
##
|
||||
# Fail completely :-(
|
||||
function fail() {
|
||||
say red "FAIL: $@" >&2
|
||||
say red "FAIL: $*" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
|
@ -159,6 +172,25 @@ function test_file() {
|
|||
# Read the test arguments, escaping things that might be processed by us
|
||||
test_args="$(sed 's/\$/\$/' "$file" | tr '\n' ' ')"
|
||||
|
||||
# Select system-specific files if they are present.
|
||||
system_specific=
|
||||
if [ -f "${test_config}.${system_name}" ] ; then
|
||||
test_config="${test_config}.${system_name}"
|
||||
system_specific=true
|
||||
fi
|
||||
if [ -f "${want_stdout}.${system_name}" ] ; then
|
||||
want_stdout="${want_stdout}.${system_name}"
|
||||
system_specific=true
|
||||
fi
|
||||
if [ -f "${want_stderr}.${system_name}" ] ; then
|
||||
want_stderr="${want_stderr}.${system_name}"
|
||||
system_specific=true
|
||||
fi
|
||||
if [ -f "${grep_stdout}.${system_name}" ] ; then
|
||||
grep_stdout="${grep_stdout}.${system_name}"
|
||||
system_specific=true
|
||||
fi
|
||||
|
||||
# Create an empty file so that we can compare against it if needed
|
||||
echo -n > "${empty}"
|
||||
|
||||
|
@ -179,7 +211,7 @@ function test_file() {
|
|||
filter=('cat')
|
||||
fi
|
||||
|
||||
echo -n "Testing file $file ... "
|
||||
echo -n "Testing file $file ${system_specific:+($system_name specific) }... "
|
||||
|
||||
# The hoops we are jumping through here, with changing directory are
|
||||
# so that we always execute fish as './fish', which means that any
|
||||
|
@ -268,7 +300,7 @@ fi
|
|||
|
||||
clean_environment
|
||||
|
||||
say cyan "Testing shell invocation funtionality"
|
||||
say cyan "Testing shell invocation functionality"
|
||||
|
||||
passed=0
|
||||
failed=0
|
||||
|
|
2
tests/invocation/bad-switch.err.Darwin
Normal file
2
tests/invocation/bad-switch.err.Darwin
Normal file
|
@ -0,0 +1,2 @@
|
|||
fish: invalid option -- Z
|
||||
RC: 1
|
Loading…
Reference in a new issue