Skip to content

Merge av_value_to_string & av_replace_placeholders into av_error_messages (option B) - #29

Draft
matapatos wants to merge 1 commit into
mainfrom
vibe/merge-error-messages-tu-58fa39
Draft

Merge av_value_to_string & av_replace_placeholders into av_error_messages (option B)#29
matapatos wants to merge 1 commit into
mainfrom
vibe/merge-error-messages-tu-58fa39

Conversation

@matapatos

Copy link
Copy Markdown
Contributor

Summary

  • Merge av_value_to_string.c and av_replace_placeholders.c into av_error_messages.c, consolidating the three error-message translation units into one. The two old .c files are removed and dropped from config.m4.
  • Make the merged TU linkable in the Ceedling unit-test build (which has no Zend engine) by routing every previously-direct Zend/library call through the mockable av_wrappers: zend_hash_find / zend_hash_next_index_insert / zend_hash_add, zend_new_array, zend_lookup_class_ex, ZVAL_STRINGLav_zval_stringl, snprintfav_snprintf, and fmaxav_fmax.
  • Drop the hand-written build_union_type_string stub in test_error_messages.c; the test now links the real implementation and constructs zend_type values by mask (MAY_BE_LONG, MAY_BE_STRING, MAY_BE_DOUBLE), so the {expected} placeholder tests exercise the genuine type-to-article logic.
  • Add ap_php_snprintf / ap_php_vsnprintf stubs to the test helpers (delegating to __builtin_vsnprintf) so test files keep using snprintf() after php.h redefines it.

Verification

  • C unit tests (Ceedling): TESTED: 129, PASSED: 129, FAILED: 0 (baseline was 129 passing too).
  • PHP integration tests: 2 failed, 703 passedidentical to the unmodified main baseline. The 2 failures are pre-existing in ErrorHandlingTest (an unwired enum "selected is invalid" code path) and unrelated to this refactor.
  • clang-format --dry-run --Werror on all .c/.h: clean (no violations in changed files).
  • clang-tidy (config.m4 sources): 6 warnings, all in pre-existing files (av_call_function.c, av_model_configs.c, av_validate_function.c) — same count as baseline; none in av_error_messages.c or av_wrappers.c. WarningsAsErrors is empty, so CI passes.
  • Extension builds and loads (phpize && ./configure && make).

Notes

  • The 2 ErrorHandlingTest failures exist on main without my changes (verified by stashing and re-running). They stem from generate_error_message/is_type_enum being defined but never called — out of scope for this consolidation.

…v_error_messages

Consolidate the three error-message translation units into a single
av_error_messages.c. To keep the merged TU linkable in the Ceedling
unit-test build (which has no Zend engine), route every direct Zend
call through av_wrappers: zend_hash_find/next_index_insert/add,
zend_new_array, zend_lookup_class_ex, zend_string_init (via a new
av_zval_stringl), snprintf (av_snprintf) and fmax (av_fmax).

Drop the hand-written build_union_type_string stub in
test_error_messages.c; the tests now link the real implementation and
build zend_type values by mask, exercising the genuine type-to-article
logic. Add ap_php_snprintf/ap_php_vsnprintf stubs to the test helpers
so test files can keep using snprintf() after php.h redefines it.

Co-authored-by: matapatos <matapatos@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants