NIHTEST-CASE(5)
π NIHTEST-CASE π
ok so this is nihtest-case, straight out of the File Formats Manual β and yes bestie, it's the whole vibe of how .test files are written. buckle up, it's giving documentation but make it cute π
β¨ NAME β¨
nihtest-case β the test case format for nihtest, like, the actual file format you write your tests in π
πΈ DESCRIPTION πΈ
nihtest(1) is a testing tool. it eats .test files as input, and this man page is here to explain the format of those test files. that's the whole assignment π«Ά
lines that start with # are comments. no cap, that's it, that's the comment rule.
here's the thing β these are the commands it recognizes. the return and args... wait no, <italic>return</italic> and <italic>args</italic>... ok so the return and arguments commands must appear exactly once, and every other one is optional. so don't be out here duplicating them, iykyk π
arguments [argument ...]β run the program with the command line arguments args. shell style quoting is supported, so you can be fancy with your quotes β¨description textβ describes the purpose of the test. like a little caption for the group chat πdirectory name create [result]β describe the directory name.createandresultcan each be either<>if the directory is expected to exist, or{}if it isn't.createis the state before the test runs,resultis the state afterwards. ifresultis omitted, it defaults tocreateβ so it just assumes nothing changed πenvironment-clearβ only variables explicitly set or passed through are included in the environment passed to the tested program. clean slate energy π§Όenvironment-passthrough variable ...β passes the named environment variables from the environmentnihtest(1)is run in through to the tested program π¦environment-set variable valueβ sets the environment variable variable to value. simple as πenvironment-unset variable ...β removes the named environment variables. bye bestie πfeatures feature ...β only run the test if all features are present, otherwise skip it. the features are extracted from a top-levelconfig.hfile. if the stringFOOis defined in the file, the featureFOOis assumed to be available, otherwise not. see also the description oftop-build-directoryinnihtest-config(5)πfile name in [out]β the arguments in and out specify the contents of the file name in the test directory before and after the program is run, respectively. if out is omitted, the file is expected to remain unchanged.
{} specifies that the file does not exist (i. e. that it is created or deleted by the program) π
for <inline> the contents of the file are taken from the test case, up to a line consisting of end-of-inline-data. if both in and out are <inline>, the input data comes first. otherwise the argument specifies the name of the file to copy or compare against. very demure, very mindful π
mkdir nameβ create directory name in the test directory. β οΈ this directive is deprecated β usedirectory name <>instead, bestie, we're moving on π«Άprecheck command [argument ...]β if command exits with non-zero status, skip the test. a lil vibe check before the main event β¨preload objectβ pre-load the shared object object before running the program.
this is not supported on Windows, where tests with preload will be skipped. windows said no thanks π
program nameβ run name. see the description ofargumentsabove for its command line arguments. if this directive is omitted,default-programfromnihtest.confis run πread-only nameβ the file or directory name will be made read-only. no touching πreturn exit-codeβ exit-code is the expected exit code (usually0on success) πset-modification-time file timeβ set the modification of file in the sandbox to time, which can be either in ISO-8601 format or seconds since Unix epoch. time travel, lowkey π°οΈstderr [file]β specify the expect standard error output (stderr). if file is given, the output is compared with that file, otherwise the expected text is taken from the following lines of the test case, up to a line consisting ofend-of-inline-dataπstderr-replace pattern replacementβ run regular expression replacement over the standard error output and the expected output as provided bystderrbefore comparing them. pattern is the match expression, replacement is the replacement expression. in the replacement expression,$1to$9are replaced with the content of the corresponding(...)match in the pattern. seere_format(7)for details. regex girlies rise π₯stdin [file]β if file is given, standard input (stdin) is redirected from this file, which means the program has direct access to the file, including the ability to seek within it.
otherwise the text provided to the program via a pipe is taken from the test case, up to a line consisting of end-of-inline-data. two very different vibes, pick one π
stdout [file]β specify the expect standard output (stdout). if file is given, the output is compared with that file, otherwise the expected text is taken from the following lines of the test case, up to a line consisting ofend-of-inline-dataπΈstdout-replace pattern replacementβ run regular expression replacement over the standard output and the expected output as provided bystdoutbefore comparing them. seestderr-replacefor details. same energy, different stream πtest-case-source filenameβ use filename to refer to test case in error messages. this is useful if the test case is created by a script π€working-directory directoryβ run the program in the subdirectory directory inside the sandbox. the directory will be created if it doesn't exist. main character energy, moving itself in π§
π¦ SEE ALSO π¦
nihtest(1), nihtest-config(5) β go read your siblings, they're iconic too π
and that's the page!! brought to you by NiH, version dated May 18, 2026 β mwah, go write some slay tests πβ¨π
π¦ where this page comes from
- alpine 3.24: nihtest-doc 1.11.1-r0 Β· BSD-3-Clause
- Copyright (C) 2020-2023 Dieter Baron and Thomas Klausner
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms