SHTK_UNITTEST_ASSERT_FILE(3)
π SHTK_UNITTEST_ASSERT_FILE(3) β Library Functions Manual
okay bestie, this is a page from the Library Functions Manual and it's all about checking files against golden data. slay.
πΈ NAME
shtk_unittest_assert_file β Validates the contents of a file against golden data
π LIBRARY
shtk_import unittest
β¨ SYNOPSIS
shtk_unittest_assert_file golden_spec actual_file
π DESCRIPTION
okay so shtk_unittest_assert_file verifies that actual_file, which must exist (no cap), matches some predefined contents specified by golden_spec.
The valid values for golden_spec are of the form:
emptyβactual_filemust be empty.not-emptyβactual_filemust not be empty.ignoreβ The contents ofactual_fileare irrelevant.file:<path>β The contents ofactual_filemust match the contents of the filepath.inline:<text>β The contents ofactual_filemust match the inline contents provided intext. Note thattextcan include escape sequences.match:<regexp>β The contents ofactual_filemust match the given regular expression inregexp.not-match:<regexp>β The contents ofactual_filemust not match the given regular expression inregexp.save:<path>βactual_fileis saved topathfor further inspection by the test case. This is not useful in the context ofshtk_unittest_assert_filebut comes in handy when used in conjunction ofshtk_unittest_assert_command(3).stdinβ The contents ofactual_filemust match the golden contents provided via the standard input.
π₯ EXAMPLES
The following examples all pass:
touch my_file
assert_file empty my_file
echo "foo" >my_file
assert_file inline:"foo\n" my_file
echo "bar" >>my_file
cp my_file golden
assert_file file:golden my_file
assert_file stdin my_file <golden
assert_file match:"fo" my_file
assert_file not-match:"abcde" my_file
π SEE ALSO
π¦ HISTORY
shtk_unittest_assert_file first appeared in shtk 1.6.
this page is from Debian, dated November 9, 2014, and it's for SHTK_UNITTEST_ASSERT_FILE(3) β bye bestie π
β¨
π¦ where this page comes from
- nixos 26.05: shtk 1.7
- nixpkgs unstable: shtk 1.7
- Copyright 2014 Google Inc
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms