Commit graph

195 commits

Author SHA1 Message Date
Mahmoud Al-Qudsi
372f03ba20 Fix sys/sysctl.h depreciation error under glibc 2.30+
glibc 2.30 and up emit an ugly depreciation warning on
`#include <sys/sysctl.h>` - this patch makes the build system fail the
include test for `sys/sysctl.h` by forcibly setting `-Werror` before the
call to `check_include_files` (which internally uses `try_compile`) to
get `HAVE_SYS_SYSCTL` to not be defined (even if it's there) if it would
cause such a depreciation message to be emitted.

Ideally, we would not have to manually massage `CMAKE_C_FLAGS` before
calling `check_include_files` and could just tweak that to either always
or conditionally try compilation with `-Werror`, but try_compile doesn't
actually use any overridden `CMAKE_C_FLAGS` values [0] (dating back to
2006).

[0]: https://cmake.org/pipermail/cmake/2006-October/011649.html
2022-01-20 11:04:40 -06:00
Aaron Gyes
401d302179 :Revert "Remove CheckIncludeFiles.cmake"
This reverts commit 398f3213d2.
2022-01-19 11:41:16 -08:00
Aaron Gyes
398f3213d2 Remove CheckIncludeFiles.cmake
We apparently vendored it for the sake of attempting to support
old cmake versions:
7aefaff298.
"This file can be dropped once the minimum version of CMake for fish is 3.11.0"

So, drop it like it's hot.
2022-01-19 11:38:41 -08:00
Johannes Altmanninger
c0d1e41313 docs synopsis: add HTML highlighing and automate manpage markup
Recent synopsis changes move from literal code blocks to
[RST line blocks].  This does not translate well to HTML: it's not
rendered in monospace, so aligment is lost.  Additionally, we don't
get syntax highlighting in HTML, which adds differences to our code
samples which are highlighted.

We hard-wrap synopsis lines (like code blocks). To align continuation
lines in manpages we need [backslashes in weird places]. Combined with
the **, *, and `` markup, it's a bit hard to get the alignment right.

Fix these by moving synopsis sources back to code blocks and compute
HTML syntax highlighting and manpage markup with a custom Sphinx
extension.

The new Pygments lexer can tokenize a synopsis and assign the various
highlighting roles, which closely matches fish's syntax highlighing:
- command/keyword (dark blue)
- parameter (light blue)
- operator like and/or/not/&&/|| (cyan)
- grammar metacharacter (black)

For manpage output, we don't project the fish syntax highlighting
but follow the markup convention in GNU's man(1):

	bold text          type exactly as shown.
	italic text        replace with appropriate argument.

To make it easy to separate these two automatically, formalize that
(italic) placeholders must be uppercase; while all lowercase text is
interpreted literally (so rendered bold).
This makes manpages more consistent, see string-join(1) and and(1).

Implementation notes:
Since we want manpage formatting but Sphinx's Pygments highlighing
plugin does not support manpage output, add our custom "synopsis"
directive.  This directive parses differently when manpage output is
specified. This means that the HTML and manpage build processes must
not share a cache, because the parsed doctrees are cached.  Work around
this by using separate cache locations for build targets "sphinx-docs"
(which creates HTML) and "sphinx-manpages".  A better solution would
be to only override Sphinx's ManualPageBuilder but that would take a
bit more code (ideally we could override ManualPageWriter but Sphinx
4.3.2 doesn't really support that).

---

Alternative solution: stick with line blocks but use roles like
:command: or :option: (or custom ones). While this would make it
possible to produce HTML that is consistent with code blocks (by adding
a bit of CSS), the source would look uglier and is harder to maintain.
(Let's say we want to add custom formatting to the [|] metacharacters
in HTML.  This is much easier with the proposed patch.)

---

[RST line blocks]: https://docutils.sourceforge.io/docs/ref/rst/restructuredtext.html#line-blocks
[backslashes in weird places]: https://github.com/fish-shell/fish-shell/pull/8626#discussion_r782837750
2022-01-19 22:56:41 +08:00
Aaron Gyes
1552c526ba Revert "Update Mac.cmake"
This reverts commit 01919f1785.
2022-01-03 08:08:41 -08:00
ridiculousfish
fecc022030 Rename the top-level test target to fish_run_tests
This keeps 'test' as an alias target. The reason is for compatibility
with CMake 3.10  and earlier, where one cannot make a target named
'test'.
2021-11-26 13:13:42 -08:00
Aaron Gyes
eb990c07c8 Let's make src/ easier to grok, move builins to src/builtins
+ No functional change here, just renames and #include changes.
+ CMake can't have slashes in the target names. I'm suspciious of
  that weird machinery for test, but I made it work.
+ A couple of builtins did not include their own headers, that
  is no longer the case.
2021-11-09 17:39:10 -08:00
Aaron Gyes
901dbd71b0 fix build when path has spaces in it.
Now it works.
2021-10-22 02:27:19 -07:00
Fabian Homborg
eba5352576 Also remove the languages from cmake
I'm not sure why this list is hardcoded?
2021-10-18 18:39:07 +02:00
Fabian Homborg
5e3c40207d cmake: Pass the source directory to the tests
Our tests typically run in their own environment, which is great for
normal tests.

However for the coming translation test, we don't want to copy the .po
files into the test environment, so it's nice to have a way out.
2021-10-18 17:02:17 +02:00
Aaron Gyes
87b2c2fdec install the fish.png file itself 2021-10-17 09:20:06 -07:00
Aaron Gyes
5accc67f1a don't install .desktop file and icon on macOS 2021-10-16 14:20:47 -07:00
ridiculousfish
d6d0723e0d cmake: Disable -Wunused-macros for bundled PCRE2
This is a noisy warning when building PCRE2
2021-10-16 13:50:33 -07:00
Fabian Homborg
8dc3982408
Always use LC_NUMERIC=C internally (#8204)
In most cases, like math, we want C-semantics for floating point
numbers. In particular "." needs to be the decimal separator.

Instead, we pay the price in printf, which is currently the sole place
to output in locale-specific numbers and attempt to read them and
C-style ones.
2021-10-13 21:09:40 +02:00
Aaron Gyes
01919f1785 Update Mac.cmake 2021-10-06 19:42:25 -07:00
Aaron Gyes
6fde56ff2d Mac.cmake: set deployment target to 10.10 per new min requirement 2021-10-06 16:51:11 -07:00
Aaron Gyes
f9def20180 Update ConfigureChecks, only do the mtime hack for Linux.. on Linux
- Only check for HAVE_CLOCK_GETTIME and HAVE_FUTIMENS on Linux, since
they are only used to implement a Linux-specific workaround related
to mtime precision.
- Make sure that hack is limited to Linux builds
- HAVE_SYS_SYSCTL_H was unused, but we should have been using it
- HAVE_TERMIOS_H was unused, remove it

The only functional change is that unix machines with clock_gettime
and futimens will not bother with a Linux-specific hack, and won't
waste time checking for either during cmake configuration either.
2021-10-02 17:02:53 -07:00
Aaron Gyes
3fd2da951e remove unused futimes check 2021-09-28 22:02:14 -07:00
ridiculousfish
ecaf455277 sphinx-build to use multiple processes
sphinx-build supports the -j option to use multiple processes. Start using
it. This reduces the time to build the docs on my Linux box from 11 seconds
to about 4.

Note this doesn't work on macOS since -j is ignored there (see sphinx-build
PR 6879).
2021-09-25 12:17:46 -07:00
Fabian Homborg
82a809e2db Check for tputs type via cmake
Instead of testing for ncurses and netbsd.

Fixes #8087.
2021-09-23 10:41:54 +02:00
ridiculousfish
0a277bf8c3 cmake: Group test targets into tests folder in IDEs
This simplifies fish project as shown in IDEs. No change to command line
build systems.
2021-09-20 12:53:12 -07:00
ridiculousfish
dc3e5a233b Generate Xcode schemes in CMake
This makes Xcode a little more pleasant, since we suppress generating a
bunch of schemes for tests.
2021-09-18 22:09:31 -07:00
Mahmoud Al-Qudsi
e0476cf219 Hack around CMake < 3.9 reporting skipped tests as failed 2021-09-07 12:04:05 -05:00
Mahmoud Al-Qudsi
9151acc498 Split test_driver.sh into test_env.sh + test_driver.sh
This lets us run non-fish targets (such as `fish_tests`) under a clean
test environment without running into the fish-specific payload
configuration now carried out by `test_driver.sh` which expects a
`.fish` payload that it will run under a deterministically configured
instance of fish, running in an environment initialized by
`test_env.sh`.

This should fix the problem with in-tree builds leaving detritus behind
after a `make test` when `fish_tests` would be executed without
`test_driver.sh` - it is now executed under `test_env.sh` instead.
2021-09-07 11:33:56 -05:00
Fabian Homborg
4c98757f85 Stop tests from creating a share/functions/functions link 2021-09-02 17:27:10 +02:00
Fabian Homborg
23e6698dc8 cmake: Force color in the tests
For littlecheck/pexpect this just unconditionally enables color.

I have no idea what happens if you run cmake outside of a terminal
, but the worst that can happen is that *errors* have color
escapes in them.

If someone figures out how to get cmake to tell us if it's running in
a terminal, we can add a check.
2021-08-30 17:16:19 +02:00
Fabian Homborg
0bcf5ac88d cmake: Use progress output for tests
This means instead of printing at least two lines per successful test,
we overwrite one line again and again with the current status, and
for *failed* (i.e interesting) tests we print the output.

Makes test failures much more visible.
2021-08-29 23:04:11 +02:00
Mahmoud Al-Qudsi
6fc8038b4e Prefix all ninja/cmake test target names with test_
`test:foo` is not allowed by CMake ("reserved name") and `test/foo`
won't work since CMake doesn't allow targets to have a directory
separator in their name.
2021-08-29 08:56:12 +02:00
Mahmoud Al-Qudsi
1f4d16cb07 Add support for bubbling up skipped tests to cmake
This prevents tests that were skipped (e.g. because of a missing
REQUIRES) from being reported as successes in the CTest overall run
results list.
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
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
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
Jan Palus
0918653510 Handle absolute path in CMAKE_INSTALL_DATADIR
Cmake accepts both absolute and relative paths in CMAKE_INSTALL_DATADIR.
For the latter case CMAKE_INSTALL_PREFIX is being prepended
automatically. %{rel_datadir} is derived from CMAKE_INSTALL_DATADIR
which was assumed to be relative and otherwise causes issues in a .pc
file where prefix is being prepended unconditionally.

Make sure %{rel_datadir} is relative by calculating RELATIVE_PATH from
CMAKE_INSTALL_PREFIX to CMAKE_INSTALL_FULL_DATADIR which is known to be
absolute.

Fixes #8150
2021-07-20 13:43:34 +02:00
Fabian Homborg
fa20dc8141 Do install the themes
This has cheesy pattern matching that I'm not entirely sure adds
anything?

Surely if we add something to share/web_config that should be
installed *by default*?

Anyway, let's just add .theme to it
2021-07-10 11:13:10 +02:00
David Adam
210dda2c4c CMake: bump minimum requirement to 3.5
CMake 3.5.0 was released in March 2016.
2021-06-28 23:56:02 +08:00
David Adam
7aefaff298 CMake/CheckIncludeFiles: use correct variable name
Merged from https://gitlab.kitware.com/cmake/cmake/-/merge_requests/1538

This file can be dropped once the minimum version of CMake for fish is
3.11.0.
2021-06-06 18:10:03 +08:00
Fabian Homborg
a09125897e Tests: Set $XDG_DATA_DIRS to empty instead of unsetting
NetBSD's `env` doesn't have `-u` and this should be harmless.
2021-05-18 12:24:24 +02:00
Johannes Altmanninger
2fff12104d Correct test environment setup
XDG_RUNTIME_DIR was misspelled.
XDG_DATA_DIRS could affect tests. Remove it since it's used read-only.
2021-04-21 00:47:03 +02:00
ridiculousfish
43cc99e1ba Group certain cmake targets into folders
This makes folders in IDEs for certain Mac and gettext targets, reducing
the number of targets which appear at top-level.
2021-03-21 13:29:41 -07:00
ridiculousfish
1b950f5f3b Switch fish.pc dependency from FBVF file to CHECK-FBVF target
Previously, both fish.pc and libfish had generating the
FISH-BUILD-VERSION-FILE attached as a command. In principle they could
both try to run the command simultaneously and now CMake complains about
this with the Xcode generator.

Switch to having fish.pc depend on the CHECK-FISH-BUILD-VERSION-FILE as a
target instead of a command. This allows it to participate in dependency
resolution and CMake will succeed again.

Fixes #7838
2021-03-21 12:39:24 -07:00
Joel Rosdahl
76b6959cad Fix parallel build race condition for test targets
When executing “make test -jX” (with X > 1) to build and run tests in a
build directory, there is a race condition between the
serial_test_low_level target and the test_prep target (a dependency of
serial_test_fishscript and serial_test_interactive).

As far as I can tell, these events happen in a serial build scenario
(“make test” with the “Unix Makefiles” CMake generator):

  1. The fish_tests binary is built and executed.
  2. The test_prep target (a dependency of serial_test_fishscript)
     cleans up test directories.
  3. Tests in test.fish are executed.

In a parallel build scenario, this often happens:

  1. Build of the fish_tests binary is started.
  2. The test_prep target cleans up test directories.
  3. Build of the fish_tests binary is finished.
  4. Execution of the fish_tests binary starts.
  5. Execution of the fish_tests binary finishes.
  6. Tests in test.fish are executed.

However, if building the fish_tests binary is fast enough but not
instant (e.g. when using ccache), this can happen:

  1. Build of the fish_tests binary is started.
  2. Build of the fish_tests binary is finished.
  3. Execution of the fish_tests binary starts.
  4. The test_prep target cleans up test directories.
  5. fish_tests tests that depend on said test directories may,
     depending on timing, fail because they are wiped by test_prep.

Fix this by making test_prep a dependency of serial_test_low_level so
that test_prep can’t interfere with fish_tests execution.
2021-03-09 21:49:52 +01:00
Fabian Homborg
a36dbad3b8 cmake: Stop copying css files
custom no longer exists and pygments is just with the theme
2021-03-02 17:04:47 +01:00
Mahmoud Al-Qudsi
050fd342da Support both GCC's Wno-redundant-move and LLVM's Wredundant-move 2021-02-22 15:44:17 -06:00
Fabian Homborg
9b763581cf cmake: Only check mbrtowc on Apple
The only thing we know ever triggered this is old macOS versions,
there's no need to use it for everyone else.

Since this uses try_run it breaks when cross-compiling, which
shouldn't be a common thing on macOS.

Fixes #7737
2021-02-22 20:17:17 +01:00
ridiculousfish
8066428feb Add fd_event_signaller_t
fd_event_signaller_t exists to expose eventfd under Linux. This is a
more lightweight way of signalling events than using a pipe.
2021-02-07 10:59:10 -08:00
ridiculousfish
b79ec0122a Use pipe2 when creating pipes if avaialble
This allows us to avoid marking the pipe as CLOEXEC in some cases,
saving a system call.
2021-02-05 17:58:08 -08:00