Skip to content
Snippets Groups Projects
Commit c600e325 authored by Georgy Moshkin's avatar Georgy Moshkin :speech_balloon:
Browse files

fix: `picodata tarantool -- file.lua` was broken after refactoring

parent 0a5bc5c3
No related branches found
No related tags found
1 merge request!1450fix: `picodata tarantool -- file.lua` was broken after refactoring
Pipeline #56228 failed
......@@ -41,8 +41,8 @@ where
let trampoline = trampoline::<E, F>;
let trampoline_arg = Box::<F>::into_raw(Box::new(f)).cast();
// XXX: `argv` is a vec of pointers to data owned by `tt_args`, so
// make sure `tt_args` outlives `argv`, because the compiler is not
// XXX: `argv` is a vec of pointers to data owned by `args`, so
// make sure `args` outlives `argv`, because the compiler is not
// gonna do that for you
let argv: Vec<_> = args.iter().map(|a| a.as_ref().as_ptr()).collect();
......@@ -59,7 +59,23 @@ where
/// Run tarantool's main entry point with cmdline args.
/// See `tarantool_main` and [`crate::tarantool::main`].
pub fn main(args: args::Tarantool) -> ! {
main_cb(&args.tt_args().unwrap(), || {
Ok::<_, std::convert::Infallible>(())
})
let tt_args = args.tt_args().unwrap();
// XXX: `argv` is a vec of pointers to data owned by `tt_args`, so
// make sure `tt_args` outlives `argv`, because the compiler is not
// gonna do that for you
let argv: Vec<_> = tt_args.iter().map(|a| a.as_ref().as_ptr()).collect();
let rc = unsafe {
crate::tarantool::main(
argv.len() as _,
argv.as_ptr() as _,
// This is needed because of a special hack in our tarantool fork.
// Without it executing a lua file would not work.
None,
std::ptr::null_mut(),
)
};
std::process::exit(rc);
}
......@@ -574,3 +574,30 @@ def test_do_not_ban_admin_via_unix_socket(cluster: Cluster):
cli.expect_exact('Connected to admin console by socket path "./admin.sock"')
cli.expect_exact("type '\\help;' for interactive help")
cli.expect_exact("picodata> ")
def test_picodata_tarantool(cluster: Cluster):
test_lua = os.path.join(cluster.data_dir, "test.lua")
with open(test_lua, "w") as f:
print(
"""
print('stdout check')
file, err = io.open('output.txt', 'w')
assert(err == nil)
assert(file:write('it worked!'))
assert(file:close())
""",
file=f,
)
stdout = subprocess.check_output(
[cluster.binary_path, "tarantool", "--", test_lua],
cwd=cluster.data_dir,
)
assert stdout == b"stdout check\n"
output_txt = os.path.join(cluster.data_dir, "output.txt")
with open(output_txt, "r") as f:
result = f.read()
assert result == "it worked!"
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment