Commit Graph

1642 Commits

Author SHA1 Message Date
Mahmoud Al-Qudsi
8b7597913e Add tests for string match/replace --max-matches 2024-06-30 17:51:50 -05:00
Mahmoud Al-Qudsi
b5f5fa98bf Fix __fish_describe_command integration test under macOS
__fish_apropos is a huge hack under macOS and it seems that it's either broken
or man pages are missing/not indexed under CI. In all cases, hard-code the
results of __fish_describe_command to test the integration machinery
specifically and get the test to pass under macOS CI.
2024-06-27 21:35:06 -05:00
Mahmoud Al-Qudsi
dd7d537d90 Add regression test for command completion descriptions 2024-06-27 20:45:38 -05:00
Looouiiis
480d48351c feat(math): add round options (#9117)
Add round options, but I think can also add floor, ceiling, etc. And
the default mode is trunc.

Closes #9117

Co-authored-by: Mahmoud Al-Qudsi <mqudsi@neosmart.net>
2024-06-23 17:45:52 -05:00
Mahmoud Al-Qudsi
7d1942a023 Add reduced-accuracy variants of some math tests under x86
Due to the inherent floating point accuracy issues under i586 described
in #10474 and at https://github.com/rust-lang/rust/issues/114479, we need to add
a workaround to our littlecheck math tests to perform less stringent comparisons
when fish was built for x86 without SSE2 support.

This commit addresses the littlecheck issues that caused #10474 to be re-opened,
but I still have to reproduce the cargo test failures for
`negative_precision_width`, `test_float`, `test_float_g`, and `test_locale`.
2024-06-23 16:14:02 -05:00
Fabian Boehm
04da7043a6 tests: Remove skipped tests hack for Cmake < 3.9.0
We require 3.19

This also makes skipped tests visible, which showed that the
print-help test was never run because the REQUIRES line was off.

In sh-mode, bash's `command -v` returns true if *all* commands exist.
2024-06-11 16:55:11 +02:00
Fabian Boehm
652996124d reader: Remove a panic
The special input functions self-insert, self-insert-not-first, and
and or used to be handled by inputter_t::readch, but they aren't
anymore with `commandline -f`.

I am unsure if these *would* have worked, I can't come up with a use.

So, for now, do nothing instead of panicking.
2024-06-10 17:14:13 +02:00
Fabian Boehm
c7d878a8d2 input: Let function_pop_arg return an Option
This would crash if you ran `commandline -f backward-jump`.

The C++ version would read a char (but badly), this doesn't anymore.

So, at least instead of crashing, just do nothing.
2024-06-10 17:02:11 +02:00
Fabian Boehm
f59cdfaa8d fish_add_path: Be more informative in verbose mode
One issue with fish_add_path at the moment is that it is sometimes a bit too intransparent.

You'll try to add a path, but it won't appear - was that because it wasn't a directory,
or because it doesn't exist, or because it was already included?

If it isn't usable after, did fish_add_path not add it because of something or did something *else* remove it?

So we give more explanations - "skipping this because it's a file", "not setting anything because no paths are left to add", ...
2024-06-06 16:47:39 +02:00
ridiculousfish
abf92fcbd1 Fix the bind.py tests
Errant newlines were causing extra prompts.
2024-06-02 15:47:15 -07:00
ridiculousfish
c0766c1844 Fix the histfile.py test
Add missing expect_prompt()
2024-06-02 15:31:19 -07:00
ridiculousfish
cb62ed3e3d Bravely reenable fg.py in CI for Mac 2024-06-02 15:11:51 -07:00
ridiculousfish
96faad247f Fix the fg.py pexpect test 2024-06-02 15:07:23 -07:00
ridiculousfish
25ac5bdb49 Fix the undo pexpect
Add the missing expect_prompts to reflect where we send newlines.
2024-06-02 14:17:36 -07:00
Mahmoud Al-Qudsi
a3e0d64e88 Remove usage of env -u
`env -u` is not supported on all platforms we support (e.g. macOS/OS X 10.10).
We don't need these variables erased, blanked works just fine.
2024-05-30 12:14:43 -05:00
Mahmoud Al-Qudsi
4b840075f4 Patch cd.fish test to support older macOS versions
The sysctl kern.osproductversion is not available on the oldest versions
we support.
2024-05-30 12:14:43 -05:00
Mahmoud Al-Qudsi
f84b1993ec Add path basename -E tests 2024-05-26 22:06:11 -05:00
Fabian Boehm
2c3894993f Remove errant profiling enabling
This enabled the profile in fish_setlocale, which caused startup
profile to always be on, so

```fish
fish --profile file -c 'foo'
```

would show the entire startup as well
2024-05-26 10:32:28 +02:00
Fabian Boehm
d5101e1923 set: Put back zero-index error instead of crashing
This was missed in the initial port in 77aeb6a2a8.
2024-05-25 21:32:40 +02:00
Fabian Boehm
bf9e5583ba Push and pop for-block every run through the loop
We do the same in while loops. This clears the local variables every time.

Fixes #10525
2024-05-25 13:20:05 +02:00
Johannes Altmanninger
2fa98ec20c Fix deadlock when importing universal LC_* variable
The C++ version of this code simply copied the entire uvar table.
Today we take a reference. It's not clear which one is better.

Removal of locale variables like LC_ALL triggers variable change handlers
which call EnvStackImpl::get. This deadlocks because we still hold the lock
to protect the reference to all uvars.  Work around this.

Closes #10513
2024-05-21 23:11:06 +02:00
Johannes Altmanninger
d40d2b786f Work around wants_terminal not begin set inside eval
On this binding we fail to disable CSI u

    bind c-t '
        begin
            set -lx FZF_DEFAULT_OPTS --height 40% --bind=ctrl-z:ignore
            eval fzf | while read -l r; echo read $r; end
        end
    '

because for "fzf", ParseExecutionContext::setup_group() returns early with the
parent process group (which should be fish's own) , hence "wants_terminal"
is false. This seems questionable, I don't think the eval should make a
difference here.

For now, don't touch it; use the more accurate way of detecting whether
a process may read keyboard input. In many of such cases "wants_terminal"
is false, like

    echo (echo 1\n2\n3 | fzf)

Fixes #10504
2024-05-18 20:55:06 +02:00
Johannes Altmanninger
29f2da8d18 Toggle terminal protocols lazily
Closes #10494
2024-05-16 12:26:47 +02:00
Fabian Boehm
f1e19884fb Add set --no-event
This allows running `set` without triggering any event handlers.

That is useful, for example, if you want to set a variable in an event
handler for that variable - we could do it, for example, in the
fish_user_path or fish_key_bindings handlers.

This is something the `block` builtin was supposed to be for, but it
never really worked because it only allows suppressing the event for
the duration, they would fire later. See #9030.

Because it is possible to abuse this, we only have a long-option so
that people see what is up.
2024-05-14 17:31:47 +02:00
Johannes Altmanninger
a19ff4989a Prevent out-of-order execution following repaint
Commit a583fe723 ("commandline -f foo" to skip queue and execute immediately,
2024-04-08) fixed the execution order of some bindings but was partially
backed out in 5ba21cd29 (Send repaint requests through the input queue again,
2024-04-19) because repainting outside toplevel yields surprising results
(wrong $status etc).

Transient prompts wants to first repaint and then execute some more readline
commands, all within a single binding.  This was broken by the second commit
because that one defers the repaint until after the binding has finished.

Work around this problem by deferring input events again while a readline
event was queued. This is closest to the historical behavior.

The implementation feels hacky; we might find odd situations.
For example,

    commandline -f repaint end-of-line
    set token (commandline -t)

sets the wrong token.
Probably not a very important case. We could throw an error or make it work
by letting "commandline -t" drain the input queue.

That seems too complicated, better change repaints to not use the input queue
(and fake $status etc). Let's try to do that in future.

Closes #10492
2024-05-13 10:44:12 +02:00
ridiculousfish
32ba8d93af Disable cd-without-permission test on macOS < 12
This allows the tests to pass on older macOS, before O_SEARCH was introduced.
2024-05-11 13:20:34 -07:00
Jonathan Krebs
4eb0dd623d add testcase for cd without read permission 2024-05-11 11:12:29 -07:00
Fabian Boehm
9e6a661c00 One more sleep 2024-05-08 16:35:00 +02:00
Fabian Boehm
37f0d7c522 Work around more spurious test failures 2024-05-07 17:55:29 +02:00
Fabian Boehm
1d7fde7bf0 tests: Fix apple key "invalid escape sequence" with python 3.12 2024-05-07 17:55:29 +02:00
Fabian Boehm
29f9d3d843 tests/signals.py: Increase a timeout
10ms is *much* too short
2024-05-07 17:55:26 +02:00
ridiculousfish
eba0d56411 Make bind_mode_events.py pass on Mac again 2024-05-06 10:26:32 -07:00
ridiculousfish
f6f1d93df5 Help fg.py test pass more on macOS 2024-05-06 10:26:32 -07:00
ridiculousfish
7b524f6995 Help the torn_escapes test pass on Mac 2024-05-06 10:26:32 -07:00
ridiculousfish
2bbeed157b Further improvements to signals.py test
Get it passing again on macOS.
2024-05-06 10:26:32 -07:00
ridiculousfish
269b18532d Fix Ctrl-C signals test
Prior to this change, signals.py attempted to generate Ctrl-C (SIGINT) by
sending \x03 to stdin. But with the change to use the CSI U sequence, Ctrl-C no
longer generates SIGINT.

Switch to sending SIGINT directly. Also switch up some of the sleep constants so
that a sleep command can't be confused with another one.
2024-05-06 10:26:32 -07:00
Fabian Boehm
2a121ef1aa function: Check if --argument-names gets a valid variable name
These were accepted but then ineffective because the only way these
are used is to set a variable.
2024-05-06 17:00:45 +02:00
Fabian Boehm
39b996332e functions: Fix --argument-names display
Mentioned in #10465
2024-05-06 17:00:45 +02:00
Johannes Altmanninger
4e816212a1 Check for unsupported "time &" in the proper place
This means we can detect this error also for simple blocks.

While at it do some cleanup in the area.
2024-05-03 09:37:56 +02:00
Johannes Altmanninger
d4ecea56df Fix regression spuriously expanding abbr with cursor outside token
Given "abbr foo something", the input sequence

    foo<space><ctrl-z><space>

would re-expand the abbreviation on the second space which is surprising
because the cursor is not at or inside the command token.  This looks to be
a regression from 00432df42 (Trigger abbreviations after inserting process
separators, 2024-04-13)

Happily, 69583f303 (Allow restricting abbreviations to specific commands
(#10452), 2024-04-24) made some changes that mean the bad commit seems no
longer necessary. Not sure why it works but I'll take it.
2024-05-03 08:39:05 +02:00
Fabian Boehm
c43f7fbe9c tests: Add another sleep 2024-04-30 16:47:44 +02:00
Johannes Altmanninger
b00899179f Don't indent multi-line quoted strings; do indent inside ()
On a command with multiline quoted string like

    begin
        echo "line1
    line2"
    end

we actually indent line2 which seeems misleading because the indentation
changes the behavior when typed into a script.

This has become more prominent since commits
- a37629f86 (fish_clipboard_copy: indent multiline commands, 2024-04-13)
- 611a0572b (builtins type/functions: indent interactively-defined functions, 2024-04-12)
- 222673f33 (edit_command_buffer: send indented commandline to editor, 2024-04-12)

which add indentation to an exported commandline.

Never indent quoted strings, to make sure the rendering matches the semantics.
Note that we do need to indent the opening quote which is fine because
it's on the same line.

While at it, indent command substitutions recursively.  That feature should
also be added to fish_indent's formatting mode (which is the default).
Fortunately the formatting mode already works fine with quoted strings;
it does not indent them. Not sure how that's done and whether indentation
can use the same logic.
2024-04-30 14:12:48 +02:00
Johannes Altmanninger
dfd08a1a2c Run fish_indent on checks/expansion.fish 2024-04-30 14:00:06 +02:00
Johannes Altmanninger
5152f6534d Fix test_functions.fish for Ubuntu Noble Numbat Docker build
vared.fish is installed at
/home/fishuser/fish-build/test/buildroot/usr/local/share/fish/functions/vared.fish
as oppposed to being sourced from share/functions/.

I'm not 100% sure why this happens but it doesn't seem wrong.
2024-04-28 10:38:26 +02:00
Johannes Altmanninger
52ef919aee Require mandoc/nroff for print-help test
Ubuntu Noble Numbat doesn't install this by default.
2024-04-28 10:38:26 +02:00
Anurag Singh
62a8b48fd1 Move generated completions to cache directory 2024-04-27 10:39:30 +02:00
Johannes Altmanninger
fb99edae92 Stop using comma from command substitution in brace expansion
Fixes #5048
2024-04-26 18:15:47 +02:00
Fabian Boehm
7ec715ba8b tests: Fix noshebang test
This was silently skipped because of a broken REQUIRES line

(it would be great if our test runner could surface skipped tests)
2024-04-25 21:52:56 +02:00
Fabian Boehm
691acfc28d tests: Disable some slow tests under ASAN
These take over two minutes under ASAN (like ~40 seconds without, so
they aren't quick to begin with), and don't really give any additional
insight.

So we skip them to save time
2024-04-25 21:52:13 +02:00
Fabian Boehm
ac8b1db899 tests: More timeout 2024-04-25 21:36:31 +02:00