fix: support extra_lua_path in test framework #12759
Open
+250
−2
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.
Description
This PR adds support for setting custom Lua paths (
extra_lua_pathandextra_lua_cpath) in test files, aligning the test framework behavior with APISIX runtime configuration.Previously, while APISIX runtime supported
apisix.extra_lua_pathinconfig.yamlto load custom plugins from specified directories, the test framework (t/APISIX.pm) did not respect this configuration. This made it impossible to write tests for custom plugins located in custom directories.This PR implements two complementary methods for setting custom Lua paths in tests:
Method 1: Block definitions (preferred)
--- extra_lua_path: /custom/path/?.lua
--- extra_lua_cpath: /custom/path/?.soMethod 2: Automatic parsing from extra_yaml_config
--- extra_yaml_config
apisix:
extra_lua_path: "/custom/path/?.lua"
extra_lua_cpath: "/custom/path/?.so"The implementation:
lua_package_pathandlua_package_cpath(matching runtime behavior)Which issue(s) this PR fixes:
Fixes #12389
Checklist
Test Coverage:
Added comprehensive test suite in
t/admin/extra-lua-path.tcovering:Backward Compatibility:
This change is fully backward compatible. It only adds new optional block definitions (
extra_lua_path,extra_lua_cpath) and parsing logic for existingextra_yaml_config. All existing tests continue to work without modification.