From 5520ee3c654ace500407d7220bb29dafbf7a23be Mon Sep 17 00:00:00 2001 From: Fabian Boehm Date: Fri, 27 Dec 2024 21:13:38 +0100 Subject: [PATCH] Document --- CONTRIBUTING.rst | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst index 767cd7d69..5ab1be700 100644 --- a/CONTRIBUTING.rst +++ b/CONTRIBUTING.rst @@ -196,8 +196,13 @@ The tests can be found in three places: - tests/pexpects for interactive tests using `pexpect `__ When in doubt, the bulk of the tests should be added as a littlecheck test in tests/checks, as they are the easiest to modify and run, and much faster and more dependable than pexpect tests. The syntax is fairly self-explanatory. It's a fish script with the expected output in ``# CHECK:`` or ``# CHECKERR:`` (for stderr) comments. +If your littlecheck test has a specific dependency, use ``# REQUIRE: ...`` with a posix sh script. -The pexpects are written in python and can simulate input and output to/from a terminal, so they are needed for anything that needs actual interactivity. The runner is in build_tools/pexpect_helper.py, in case you need to modify something there. +Tests are run in a temporary $HOME, but that is shared among the tests by default. If you need a temporary directory for your test, you should create one (e.g. with ``mktemp``). + +The pexpects are written in python and can simulate input and output to/from a terminal, so they are needed for anything that needs actual interactivity. The runner is in tests/pexpect_helper.py, in case you need to modify something there. + +If you need a command to do something weird to test something, maybe add it to the ``fish_test_helper`` binary (in tests/fish_test_helper.c), or see if it can already do it. Local testing ------------- @@ -209,6 +214,15 @@ The tests can be run on your local computer on all operating systems. cmake path/to/fish-shell make test +Or you can run them on a fish, without involving cmake:: + + cargo build + FISHDIR=target/debug tests/test_driver.sh tests/test.fish # script tests, the checks + FISHDIR=target/debug tests/test_driver.sh tests/interactive.fish # interactive tests, the pexpects + +Here, ``FISHDIR`` refers to a directory with ``fish``, ``fish_indent`` and ``fish_key_reader`` in it. +In this example we're in the root of the git repo and have run ``cargo build`` without ``--release``, so it's a debug build. + Git hooks ---------