Skip to content

Commit

Permalink
Add --not-clean parameter and dont clean workdir
Browse files Browse the repository at this point in the history
Now luatest will always clear the server vardir (`/tmp/t` by default)
before running tests. You should be specify a new `--not-clean` parameter
to disable this deletion.

Also luatest does not delete the server workdir in the Server:drop().

Part of tarantool#308
  • Loading branch information
Oleg Chaplashkin committed Sep 12, 2023
1 parent a188577 commit fba6eb2
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 10 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
- Save server artifacts (logs, snapshots, etc.) if the test fails.
- Group working directories of servers inside a replica set into one directory.
- Fix collecting coverage if tarantool binary has a suffix.
- Add `--not-clean` option to disable deletion of the server vardir.

## 0.5.7

Expand Down
8 changes: 8 additions & 0 deletions luatest/runner.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ local GenericOutput = require('luatest.output.generic')
local hooks = require('luatest.hooks')
local loader = require('luatest.loader')
local pp = require('luatest.pp')
local Server = require('luatest.server')
local sorted_pairs = require('luatest.sorted_pairs')
local TestInstance = require('luatest.test_instance')
local utils = require('luatest.utils')
Expand Down Expand Up @@ -107,6 +108,8 @@ Options:
May be repeated to exclude several patterns
Make sure you escape magic chars like +? with %
--coverage: Use luacov to collect code coverage.
--not-clean: Do not clean the working directory (/tmp/t).
This is cleared by default.
]]

function Runner.parse_cmd_line(args)
Expand Down Expand Up @@ -170,6 +173,8 @@ function Runner.parse_cmd_line(args)
result.enable_capture = false
elseif arg == '--coverage' then
result.coverage_report = true
elseif arg == '--not-clean' then
result.not_clean = true
elseif arg:sub(1,1) == '-' then
error('Unknown option: ' .. arg)
elseif arg:find('/') then
Expand Down Expand Up @@ -266,6 +271,9 @@ function Runner.mt:initialize()
end

function Runner.mt:bootstrap()
if not self.not_clean then
fio.rmtree(Server.vardir)
end
local load_tests = self.load_tests or loader.require_tests
for _, path in pairs(self.paths) do
load_tests(path)
Expand Down
2 changes: 0 additions & 2 deletions luatest/server.lua
Original file line number Diff line number Diff line change
Expand Up @@ -443,8 +443,6 @@ function Server:drop()
self:stop()
self:save_artifacts()

fio.rmtree(self.workdir)

self.instance_id = nil
self.instance_uuid = nil
end
Expand Down
8 changes: 0 additions & 8 deletions test/server_test.lua
Original file line number Diff line number Diff line change
Expand Up @@ -373,14 +373,6 @@ g.test_save_server_artifacts_when_test_failed = function()
t.assert_equals(fio.path.is_dir(s2_artifacts), true)
end

g.test_remove_server_artifacts_when_test_success = function()
local s = Server:new()
s:start()
s:drop()

t.assert_equals(fio.path.exists(s.workdir), false)
end

g.test_server_build_listen_uri = function()
local uri = Server.build_listen_uri('foo')
t.assert_equals(uri, ('%s/foo.sock'):format(Server.vardir))
Expand Down

0 comments on commit fba6eb2

Please sign in to comment.