mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-29 06:13:20 +00:00
Add tests for type
While we use `type -q` a bunch, the other options are kind of unutilized, and so having a test is nice when we want to reimplement it. See #7342.
This commit is contained in:
parent
7ec57f2c50
commit
e8d725e051
1 changed files with 42 additions and 0 deletions
42
tests/checks/type.fish
Normal file
42
tests/checks/type.fish
Normal file
|
@ -0,0 +1,42 @@
|
|||
# RUN: %fish %s
|
||||
#
|
||||
# Tests for the `type` builtin
|
||||
# First type --query, which is the most important part.
|
||||
type -q type
|
||||
echo $status
|
||||
# CHECK: 0
|
||||
type -q realpath
|
||||
echo $status
|
||||
# CHECK: 0
|
||||
type -q sh
|
||||
echo $status
|
||||
# CHECK: 0
|
||||
type -q doesnotexist-pleasedonotexist-2324242
|
||||
echo $status
|
||||
# CHECK: 1
|
||||
type -q doesnotexist-pleasedonotexist-2324242 sh
|
||||
echo $status
|
||||
# CHECK: 0
|
||||
type -q sh doesnotexist-pleasedonotexist-2324242
|
||||
echo $status
|
||||
# CHECK: 0
|
||||
type -q '['
|
||||
echo $status
|
||||
# CHECK: 0
|
||||
|
||||
# Test that we print a command path
|
||||
type sh
|
||||
# (we resolve the path, so if /bin is a symlink to /usr/bin this shows /usr/bin/sh)
|
||||
# CHECK: sh is {{.*}}/bin/sh
|
||||
|
||||
# Test that we print a function definition.
|
||||
# The exact definition here depends on the system, so we'll ignore the actual code.
|
||||
type realpath | grep -v "^ *"
|
||||
# CHECK: realpath is a function with definition
|
||||
# CHECK: # Defined in {{.*}}/functions/realpath.fish @ line {{\d+}}
|
||||
# CHECK: function realpath --description 'print the resolved path [command realpath]'
|
||||
# CHECK: end
|
||||
|
||||
type -t realpath foobar
|
||||
# CHECK: function
|
||||
# CHECKERR: type: Could not find {{.}}foobar{{.}}
|
Loading…
Reference in a new issue