lua: allow to override a built-in module
This commit finishes implementation of the logic for overriding built-in modules. It adds the loader, which looks into a file system for `override.foo` module when `foo` is required. It works as for `require()` in an application/module code as well as for `require()` called from tarantool during its initialization. Added replacements into the treegen testing helper. Disabled the override loader in the LuaJIT submodule test suites. It is done using `debug.getupvalue()`, which is a fragile way. Don't worry: the next commit reimplements this logic. Fixes #7774 @TarantoolBot document Title: Built-in modules overriding Now it is possible to override a built-in module. Everything is simple here, in fact: if `override.foo` module exists on default search paths, it'll replace built-in `foo` module.
Showing
- changelogs/unreleased/module-override.md 3 additions, 0 deletionschangelogs/unreleased/module-override.md
- src/lua/loaders.lua 40 additions, 4 deletionssrc/lua/loaders.lua
- test/app-luatest/override_test.lua 146 additions, 0 deletionstest/app-luatest/override_test.lua
- test/luajit-test-init.lua 39 additions, 0 deletionstest/luajit-test-init.lua
- test/treegen.lua 9 additions, 6 deletionstest/treegen.lua
Loading
Please register or sign in to comment