From c7ab35c1382756bee6f4fbadaf13b6854ca618b7 Mon Sep 17 00:00:00 2001 From: Jackson Moore Date: Sat, 5 Sep 2026 13:39:34 +0200 Subject: Verify bundled runtime dependency --- tests/package_shell_test.lua | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'tests/package_shell_test.lua') diff --git a/tests/package_shell_test.lua b/tests/package_shell_test.lua index 8a004ca..da3ab2b 100644 --- a/tests/package_shell_test.lua +++ b/tests/package_shell_test.lua @@ -12,11 +12,27 @@ local first_line = source:match("^([^\r\n]*)") assert(first_line == "--- @since 26.9.1", "invalid compatibility annotation") assert(not source:find("--- @sync entry", 1, true), "entry must use the default async context") +local external_dependency_patterns = { + "%f[%a]require%s*%(", + "%f[%a]dofile%s*%(", + "%f[%a]loadfile%s*%(", + "package%.loadlib%s*%(", + "io%.popen%s*%(", + "os%.execute%s*%(", + "%f[%a]Command%s*%(", +} + +for _, pattern in ipairs(external_dependency_patterns) do + assert(not source:find(pattern), "plugin source references an external runtime dependency") +end + local sync_calls = 0 +local sync_callbacks = {} local environment = { ya = { sync = function(callback) sync_calls = sync_calls + 1 + sync_callbacks[sync_calls] = callback assert(type(callback) == "function", "ya.sync requires a function") return callback end, @@ -29,5 +45,7 @@ local plugin = chunk() assert(sync_calls == 1, "expected one top-level synchronous transaction") assert(type(plugin) == "table", "plugin must export a table") assert(type(plugin.entry) == "function", "plugin must export an entry method") +assert(plugin.entry() == nil, "entry shell must load with the bundled runtime") +assert(sync_callbacks[1]() == 0, "commit shell must load with the bundled runtime") print("package shell checks passed") -- cgit v1.2.3