From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtpng3.m.smailru.net (smtpng3.m.smailru.net [94.100.177.149]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id 15152452566 for ; Thu, 14 Nov 2019 19:51:31 +0300 (MSK) Date: Thu, 14 Nov 2019 19:51:30 +0300 From: Nikita Pettik Message-ID: <20191114165130.GB37401@tarantool.org> References: <20191114115020.21091-1-maria.khaydich@tarantool.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20191114115020.21091-1-maria.khaydich@tarantool.org> Subject: Re: [Tarantool-patches] [PATCH] box.execute should be immutable function List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Maria Cc: tarantool-patches@dev.tarantool.org On 14 Nov 14:50, Maria wrote: > Using box.execute method before explicitly > configuring box automatically invoked box.cfg > nonetheless. Any further calls to the latter > caused its reconfiguration which could lead > to an error when trying to use the method. Hello. I'm not going to comment patch iteself, just want to leave a couple of general nits. They are just recommendations. Feel free to use up to 72 characters while making up commit's body. I'd fix commit subject: box.execute should be immutable -> box: make box.execute() immutable despite box.cfg{} (or sort of). > Closes #4231 > Issue: > https://github.com/tarantool/tarantool/issues/4231 > Branch: > https://github.com/tarantool/tarantool/compare/eljashm/gh-4231-box.execute-immutable-function Please, put links under --- delimiter so that it will be ignored by git am. > --- > src/box/lua/load_cfg.lua | 4 +++- > test/box-tap/execute.test.lua | 17 +++++++++++++++++ > 2 files changed, 20 insertions(+), 1 deletion(-) > create mode 100755 test/box-tap/execute.test.lua > > diff --git a/src/box/lua/load_cfg.lua b/src/box/lua/load_cfg.lua > index e7f62cf4e..042edf913 100644 > --- a/src/box/lua/load_cfg.lua > +++ b/src/box/lua/load_cfg.lua > @@ -528,7 +528,9 @@ box.cfg = locked(load_cfg) > -- metatable. > -- > function box.execute(...) > - load_cfg() > + if not box.cfg then > + load_cfg() > + end > return box.execute(...) > end > > diff --git a/test/box-tap/execute.test.lua b/test/box-tap/execute.test.lua > new file mode 100755 > index 000000000..301cf4a1c > --- /dev/null > +++ b/test/box-tap/execute.test.lua I'd better name this test ..box-tap/gh-4231-immutable-execute-func.test.lua It is generally accepted naming way. > @@ -0,0 +1,17 @@ > +#!/usr/bin/env tarantool > + > +local tap = require('tap') > +local test = tap.test('execute') > +test:plan(1) Please, leave comment explaining what exactly is tested here. For instance: -- Make sure that box.execute() method does not change after -- the very first box.cfg{} invokation. -- > + > +local box_execute = box.execute > +box.cfg{} > + > +local status, err = pcall( > + function() > + box_execute("CREATE TABLE t1 (s1 INTEGER, PRIMARY KEY (s1));") > + end) > + > +test:ok(status and err == nil, "box.execute after box.cfg") I guess this should be error message which is displayed in case test fails. If so, I'd rather use message like: "box.execute() is changed after box.cfg{} invokation"