Skip to content

Commit e8e5baf

Browse files
committed
ctest: better test integration
1 parent a340162 commit e8e5baf

2 files changed

Lines changed: 19 additions & 11 deletions

File tree

lua/cmake-tools/init.lua

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1117,10 +1117,27 @@ function cmake.target_settings(opt)
11171117
end
11181118
end
11191119

1120-
function cmake.run_test(opt)
1120+
function cmake.run_test(opt, callback)
1121+
callback = callback or function() end
11211122
if utils.has_active_job(config.runner, config.executor) then
11221123
return
11231124
end
1125+
if get_cmake_configuration_or_notify(callback) == nil then
1126+
return
1127+
end
1128+
1129+
local ct = config:get_codemodel_targets()
1130+
if not (config:has_build_directory()) or not (ct.code == Types.SUCCESS) then
1131+
-- configure it
1132+
return cmake.generate({ bang = false, fargs = {} }, function(result)
1133+
if result:is_ok() then
1134+
cmake.run_test(opt, callback)
1135+
else
1136+
callback(result)
1137+
end
1138+
end)
1139+
end
1140+
11241141
local env = environment.get_build_environment(config)
11251142
local all_tests = ctest.list_all_tests(config:build_directory_path())
11261143
if #all_tests == 0 then

lua/cmake-tools/test/ctest.lua

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -37,16 +37,7 @@ function ctest.run(ctest_command, test_name, build_dir, env, config, opt)
3737
opt = opt or {}
3838

3939
local args = { "--test-dir", utils.transform_path(build_dir), "-R", test_name, opt.args }
40-
utils.run(
41-
cmd,
42-
config.env_script,
43-
env,
44-
args,
45-
config.cwd,
46-
config.runner,
47-
nil,
48-
const.cmake_notifications
49-
)
40+
utils.run(cmd, config.env_script, env, args, config.cwd, config.runner, nil)
5041
end
5142

5243
return ctest

0 commit comments

Comments
 (0)