Repository navigation
test: characterize the cf preprocessor before its port (Refs #1499) - #1502
Merged
Merged
Conversation
…#1499) test_cf_lexer.c covers #define, #ifdef/#else, two errors and add/remove of defines. The new test_cf_preprocessor.c covers the rest of cf-lexer.c.h, with the values the C code gives today: - #include relative to the including file, nested, twice, a missing file and a path that is not a string. The missing-file error text runs to the end of the source, not only the path. - <...> includes are skipped without an error, with or without a system include directory. - Macros with parameters, an argument that is a call, too few and too many arguments, a name without a call, an unterminated list. - #undef, an unknown #undef, and a second #define of the same name (two entries, the first is used). - #ifndef, a block inside a skipped block, a #define in a skipped block. - A define that expands to another define, a backslash continuation, a '#' that is not first on its line. - #if with a number or a define value, the six comparators, a hex number, #elif and #else chains, and an #if in a skipped block. On an #if error (an undefined name, a negative number, a define with text, a macro, a wrong comparator) the line is dropped, the block is kept and the #endif is then reported outside of a block. After a true branch, an #elif condition is reported as an unexpected token. - #pragma, a second #else, #else and #elif outside a block, #define without a name or with a number, empty source. The include tests use their own directory, cf_pp_test, made in the group setup and removed in teardown. Every case checks the joined output, the token count, the define and dependency counts, the error count and text, and bnum_allocs. The expected values come from a probe against the C libobs on macOS arm64. The test passes on Linux x86_64 against the C libobs and the libobs-with-rust twin (the preprocessor is C in both). Co-Authored-By: Claude Opus 5.5 <[email protected]>
vpacher
force-pushed
the
test/1499-cf-preprocessor
branch
from
October 20, 2026 06:20
e3a6ffe to
177b950
Compare
This was referenced Oct 22, 2026
6 of 7 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
C-only characterization for #1499, before the Rust port of the cf preprocessor (
libobs/util/cf-lexer.c.h). No libobs change.test_cf_lexer.calready covers#define,#ifdef/#else, two errors and add/remove of defines. The newtest_cf_preprocessor.ccovers the rest, with the values the C code gives today, quirks included:#includerelative to the including file, nested, twice, a missing file, and a path that is not a string. The missing-file error text runs to the end of the source, not only the path.<...>includes are skipped without an error, with or without a system include directory.#undef, an unknown#undef, and a second#defineof the same name (two entries; the first is used).#ifndef, a block inside a skipped block, a#definein a skipped block.#that is not first on its line.#ifwith a number or a define value, the six comparators, a hex number,#elif/#elsechains, and an#ifin a skipped block. On an#iferror (an undefined name, a negative number, a define with text, a macro, a wrong comparator) the line is dropped, the block is kept, and the#endifis then reported outside of a block. After a true branch, an#elifcondition is reported as an unexpected token.#pragma, a second#else,#elseand#elifoutside a block,#definewithout a name or with a number, empty source.The include tests use their own directory,
cf_pp_test, made in the group setup and removed in teardown. Every case checks the joined output, the token count, the define and dependency counts, the error count and text, andbnum_allocs.Testing: the expected values come from a probe against the C libobs on macOS arm64. The test passes 13/13 on Linux x86_64 against the C libobs and against
libobs-with-rust(the preprocessor is C in both).clang-format22.1.3 andgersemi0.25.0 clean.🤖 Generated with Claude Code