Commit Graph

14518 Commits

Author SHA1 Message Date
Mahmoud Al-Qudsi
c35113aef1 Remove now-extraneous re-init of XDG dirs in tests
test_driver.sh is guaranteed to take care of them.
2021-08-29 08:56:12 +02:00
Mahmoud Al-Qudsi
c82d1980bf Prevent same history test from running multiple times at once
The default matching logic for fish_tests was prefix based, so when we
were running `history` we were also running all history tests. This
causes the test to fail for an unknown reason.
2021-08-29 08:56:12 +02:00
Mahmoud Al-Qudsi
77b332221a Fix complete.fish test
It depends on `mktemp -d TAG` returning a relative path, which isn't guaranteed to be the case (and
isn't the case when run by our test driver).
2021-08-29 08:56:12 +02:00
Mahmoud Al-Qudsi
04a3065d73 Fix mktemp -d under macOS 10.10 2021-08-29 08:56:12 +02:00
Mahmoud Al-Qudsi
1fd92f493a Try disabling CMP00037 regardless of CMake version 2021-08-29 08:56:12 +02:00
Mahmoud Al-Qudsi
aa25c4eccc Run tests serially under CI 2021-08-29 08:56:12 +02:00
Mahmoud Al-Qudsi
2962fbcf7a Add pexpect tests to new test driver 2021-08-29 08:56:12 +02:00
Mahmoud Al-Qudsi
aaac759d9a Make test a custom target again and add top-level test targets
Even though we are using CMake's ctest for testing, we still define our
own `make test` target rather than use its default for many reasons:

 * CMake doesn't run tests in-proc or even add each tests as an
   individual node in the ninja dependency tree, instead it just bundles
   all tests into a target called `test` that always just shells out to
   `ctest`, so there are no build-related benefits to not doing that
   ourselves.
 * CMake devs insist that it is appropriate for `make test` to never
   depend on `make all`, i.e. running `make test` does not require any
   of the binaries to be built before testing.
 * The only way to have a test depend on a binary is to add a fake test
   with a name like "build_fish" that executes CMake recursively to
   build the `fish` target.
 * It is not possible to set top-level CTest options/settings such as
   CTEST_PARALLEL_LEVEL from within the CMake configuration file.
 * Circling back to the point about individual tests not being actual
   Makefile targets, CMake does not offer any way to execute a named
   test via the `make`/`ninja`/whatever interface; the only way to
   manually invoke test `foo` is to to manually run `ctest` and specify
   a regex matching `foo` as an argument, e.g. `ctest -R ^foo$`... which
   is really crazy.

With this patch, it is now possible to execute any single test by name,
by invoking the build directly, e.g. to run the `universal.fish` check:
`cmake --build build --target universal.fish` or
`ninja -C build universal.fish`. Unfortunately, this is not integrated
into the Makefile wrapper, so `make universal.fish` won't work (although
this can potentially be hacked around).
2021-08-29 08:56:12 +02:00
Mahmoud Al-Qudsi
26092456d4 Add CMake enumeration of low-level fish_tests.cpp tests
Instead of compiling `fish_tests.cpp` dynamically with weakly-linked
symbols and asking it to print the list of all available tests, we
use a magic string `#define`'d as a no-op to allow CMake to regex search
for matching test groups. This speeds up configuration somewhat (by not
compiling anything), but more importantly, it's much less brittle and
doesn't involve and linker dark magic.

There's of course still no getting around the fact that it's really ugly.
2021-08-29 08:56:12 +02:00
Mahmoud Al-Qudsi
7bcf527f84 Remove cmake test_prep target
This is now carried out more cleanly and more correctly by
test_driver.sh
2021-08-29 08:56:12 +02:00
Mahmoud Al-Qudsi
35975d83af Run each test fully independently in own environment 2021-08-29 08:56:12 +02:00
Mahmoud Al-Qudsi
498e5fa9b0 [tests] Set permissions on tmux socket after creation 2021-08-28 22:55:53 +02:00
Evan Chen
878bfa94cb Typo funcions -> functions 2021-08-28 22:47:00 +02:00
Akatsuki Rui
9022b9bef6 feat(completions/coredumpctl.fish): new complete for systemd 249 2021-08-28 19:36:23 +02:00
Akatsuki Rui
a113b3a755 fix(completions/coredumpctl.fish): missing --arguments 2021-08-28 19:36:23 +02:00
ridiculousfish
7a1c005b42 Switch to using timef instead of gettimeofday
This encapsulates the tricky arithmetic inside timef(), which uses
gettimeofday.
2021-08-27 16:25:33 -07:00
ridiculousfish
7d537eefbb proc_get_jiffies to accept pid directly
No need to accept the mutable proc here.
2021-08-27 13:05:27 -07:00
ridiculousfish
f577c221eb Introduce get_by_sorted_name
Given that we have several lists of things sorted by name, replace a
bunch of ad-hoc lower_bound calls with a single function.
2021-08-26 13:40:37 -07:00
Fabian Homborg
ee2d2caeaa escape_code_length: Test colors last
We have a *lot* of color sequences to try and tparm is slow (on the
whole, when you do this thousands of times).

So let's just check colors last, which makes everything else (which is
comparatively nothing) faster, while barely impacting
colors (benchmarking confirms no measurable difference).

Fixes #8253.
2021-08-26 21:01:55 +02:00
Rosen Penev
a36a26c28b clang-tidy: replace NULL with nullptr
Signed-off-by: Rosen Penev <rosenp@gmail.com>
2021-08-25 16:10:17 -07:00
Rosen Penev
ffd5716e70 clang-tidy: replace push_back with emplace_back
clang-tidy marks these as needing emplace_back as the types to not
match.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2021-08-25 03:19:46 +02:00
Takumi Kameyama
6bd25ed599
Fix completions/ls.fish (#8249)
* Fix ls.fish: add -l option to GNU ls

* Sort alphabetically and remove --lcontext and --scontext (what are these?) on shared and GNU part.

* Revert --lcontext and --scontext options.
2021-08-24 19:29:32 +02:00
Kid
48e4ce2f6d Add and fix completions for new options 2021-08-23 18:04:11 +02:00
Lars Lenckowski
284b7d8eb0 complete "mpc load" 2021-08-23 18:03:57 +02:00
Fabian Homborg
f8a46c027d Add script to extract help sections
Unfortunately, we now need to know which .html file has which sections
to link to the correct one in help.fish.

So this script helps extract the sections from pre-built docs. It's
not supposed to be run at build time because

1. These change rarely.
2. We should link to the correct document even if the user doesn't
have the docs built.

And before anyone mentions it: This does *not* parse html with regex.

This "parses" the restricted subset of "class followed by href without
embedded quotes" that sphinx uses here in practice.
2021-08-23 18:01:31 +02:00
Fabian Homborg
0e06a53dff help: Add sections directly via the <span id>
This should add all the sections that aren't linked internally,
including "identifiers".

(also give up on the line breaking because it makes it annoying to do
automatically)

Fixes #8245.
2021-08-22 13:14:59 +02:00
Rosen Penev
a9b4127f68 clang-tidy: run through normal checks
There's a .clang-tidy file in here.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2021-08-21 21:59:05 +02:00
Fabian Homborg
70e3e0beac Also remove ephemeral item if command is effectively empty
Fixes #8232.

Note that this needed to have expect_prompt used in the pexpect test -
we might want to add a "catchup" there so you can just ignore the
prompt counter for a bit and pick it back up later.
2021-08-20 19:38:16 +02:00
Rosen Penev
b748417af7 clang-tidy: replace size comparisons with empty
Signed-off-by: Rosen Penev <rosenp@gmail.com>
2021-08-20 18:32:45 +02:00
Rosen Penev
1af9e5d21e clang-tidy: simplify two bool returns
Signed-off-by: Rosen Penev <rosenp@gmail.com>
2021-08-20 18:32:15 +02:00
Fabian Homborg
fe71e62a68 help: Update sections
This was semi-automated with

```fish
for file in $argv
    set -l varname (string replace -r '.*/(.*).html' '$1' -- $file | string escape --style=var)pages
    set -l sections (string replace -rf '.*class="headerlink" href="#([^"]*)".*' '$1' <$file)

    echo set -l $varname $sections
end
```

(where $argv contains the path to faq, fish_for_bash_users,
interactive, language and tutorial.html)

Building help.fish at compile time would work, but only for users who
build the docs.
2021-08-20 17:40:57 +02:00
Fabian Homborg
d4f7e25584
Replace strerror/sys_errlist after fork with our own errors (#8234)
* Remove safe_strerror, safe_perror and safe_append

This no longer works on new glibcs because they removed sys_errlist.

So just hardcode the relevant errno messages (and phrase them better).

Fixes #4183.

Co-authored-by: Johannes Altmanninger <aclopte@gmail.com>
2021-08-20 17:17:01 +02:00
Rosen Penev
90f006b1cd clang-tidy: use delete
The clang warning for pending_signals_t was about the operator=
return type being wrong (misc-unconventional-assign-operator).

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2021-08-20 01:33:33 +02:00
Johannes Altmanninger
5de05a810c Tell clang-tidy that expander_t::stage_variables intentionally takes values
We don't want to convert the input to a "wcstring &" because
"stage_variables" needs to have the same type as other stages, so we
can use it in a loop. Communicate that to clang-tidy.

We also don't want to take "wcstring &&". As the Google style guide
states, it's not really beneficial here, and it potentially hurts
readability because it's a relatively obscure feature.
The rest of our code contains a bunch of && parameters.  We might
want to get rid of some of them.

Closes #8227
2021-08-20 01:21:21 +02:00
Rosen Penev
ffa3e0b4f4 convert const ref to value
clang-tidy wrongly sees an std::move to a const ref parameter and
believes it to be pointless. The copy constructor however is deleted.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2021-08-20 01:16:24 +02:00
Rosen Penev
4ea5189c4f clang-tidy: const reference conversions
These are only read from.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2021-08-20 01:15:48 +02:00
Rosen Penev
f9af33f223 clang-tidy: remove pointless virtual
override is already used.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2021-08-20 01:15:23 +02:00
Rosen Penev
faf51e0693 clang-tidy: use for range loops
Signed-off-by: Rosen Penev <rosenp@gmail.com>
2021-08-20 01:14:25 +02:00
David Adam
dffc84712a CHANGELOG: work on 3.4.0 2021-08-18 22:23:32 +08:00
ridiculousfish
2ca66cff53 Disable job control inside command substitutions
This disables job control inside command substitutions. Prior to this
change, a cmdsub might get its own process group. This caused it to fail
to cancel loops properly. For example:

    while true ; echo (sleep 5) ; end

could not be control-C cancelled, because the signal would go to sleep,
and so the loop would continue on. The simplest way to fix this is to
match other shells and not use job control in cmdsubs.

Related is #1362
2021-08-18 22:20:03 +08:00
Mahmoud Al-Qudsi
d27f477ba6 Fix truncated completions for pkg install <foo>
The same hack that is used for `pkg remove <foo>` is required here, too.
Due to the massive number of results, we use `head -n 250` to prevent
the completion from hanging or the shell from being overencumbered by
too many possibe completions. However, this would only generate matches
for any of the first 250 packages, rather than printing the first 250
packages that match.

[ci skip]
2021-08-18 00:20:08 -05:00
Mahmoud Al-Qudsi
3291102045 Refactor deferred_process handling to be more clearly safe
The previous layout confused me for a minute as it suggested it was
possible for `pipe_next_read` to be moved twice (once in the first
conditional block, then again when the deferred process conditional
called `continue` - if and only if the deferred process *was* the last
process in the job. This patch clarifies that can't be the case.
2021-08-17 20:10:19 -05:00
Mahmoud Al-Qudsi
c014c23662 Fix undefined behavior in closing a moved pipe
`pipe_next_read` is moved in the body of the loop, and not
re-initialized the last go around. However, we call
`pipe_next_read.close()` after the loop, which is undefined behavior (as
it's been moved).

Best case scenario, the compiler passed the address of our copy of the
struct to `exec_process_in_job` and beyond, it went out of scope there,
the value of `fd` was set to closed (minus one), and we explicitly call
`.close()` again, in which case it does nothing.

Worst case scenario, the compiler re-uses the storage for the now-moved
struct for something else and our call to `.close()` ends up closing
some other value of `fd` (valid or invalid) and things break.

Aside from the fact that we obviously don't need to close it since it's
not assigned for the last process in the job, it's a RAII object so we
don't have to worry about manually closing it in the first place.
2021-08-17 19:52:15 -05:00
Mahmoud Al-Qudsi
57615504d0 Eliminate variable unused after refactor of wcstringutil.cpp 2021-08-17 19:23:13 -05:00
Mahmoud Al-Qudsi
426fa82f8f Fix recently broken escape_code_length() result
`escape_code_length()` was converted from returning a `size_t` to
returning a `maybe_t<size_t>` but that subtly broke all existing call
sites by forcing all input to go through the slow path of assuming a
zero-length escape sequence was found.

This is because all callers predicated their next action on what amounts
to `if (escape_code_length(...))` which would correctly skip the slow
path when `escape_code_length` returned zero, but after the conversion
to `maybe_t` contained not `maybe_t::none()` but rather
`maybe_t::some(0)` due to coercion of the result from the `size_t` local
`esc_seq_len` to the `maybe_t<size_t>` return value - which, when
coerced to a boolean returns *true* for `maybe_t::some(0)` rather than
false.

The regression was introduced in 7ad855a844
and did not ship in any released versions so no harm, no foul.
2021-08-17 19:04:10 -05:00
Mahmoud Al-Qudsi
daa366eb5a maybe.h: reference header new
This is required for the usage of placement new. Not an issue for fish
as it gets picked up from elsewhere, but it lets one use it in a C++
test directly this way.
2021-08-17 18:57:16 -05:00
Rosen Penev
ba91b39715 replace push_back with emplate_back
The latter forwards the arguments directly.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2021-08-17 18:56:19 -05:00
Fabian Homborg
c055e3ae66 docs: Reword feature flags chapter 2021-08-17 17:32:41 +02:00
Fabian Homborg
7df833acc1 MOAR CHANGELOG 2021-08-17 16:31:22 +02:00
Fabian Homborg
6c5c8e03c5 Move the numeric locale tests to a different file
This lets us check for locales once, and to have littlecheck mark the
test as skipped.
2021-08-17 15:36:07 +02:00