-
Notifications
You must be signed in to change notification settings - Fork 106
Option to pass extra arguments to ctest #315
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -26,6 +26,7 @@ local Config = { | |
| generate_options = {}, | ||
| build_options = {}, | ||
| show_disabled_build_presets = true, | ||
| ctest_extra_args = {}, | ||
| }, -- general config | ||
| target_settings = {}, -- target specific config | ||
| executor = nil, | ||
|
|
@@ -48,7 +49,9 @@ function Config:new(const) | |
|
|
||
| obj.executor = const.cmake_executor | ||
| obj.runner = const.cmake_runner | ||
|
|
||
| for _, v in pairs(const.ctest_extra_args) do | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Using a for loop here might not have the desired outcome. Or at least only once^^ additionally, |
||
| table.insert(obj.base_settings.ctest_extra_args, v) | ||
| end | ||
| return obj | ||
| end | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| local const = require("cmake-tools.const") | ||
|
|
||
| describe("Config", function() | ||
| local Config | ||
| local local_const | ||
|
|
||
| before_each(function() | ||
| package.loaded["cmake-tools.config"] = nil | ||
| Config = require("cmake-tools.config") | ||
| local_const = vim.deepcopy(const) | ||
| end) | ||
|
|
||
| it("should parse user provided ctest arguments", function() | ||
| local_const.ctest_extra_args = { "-j", "6" } | ||
| local config = Config:new(local_const) | ||
| assert.are_same({ "-j", "6" }, config.base_settings.ctest_extra_args) | ||
| end) | ||
|
|
||
| it("should parse user ctest empty arguments", function() | ||
| local config = Config:new(const) | ||
| assert.are_same({}, config.base_settings.ctest_extra_args) | ||
| end) | ||
| end) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| local match = require("luassert.match") | ||
| local stub = require("luassert.stub") | ||
| local const = require("cmake-tools.const") | ||
| local ctest = require("cmake-tools.test.ctest") | ||
| local utils = require("cmake-tools.utils") | ||
|
|
||
| describe("run", function() | ||
| local local_const | ||
| local Config | ||
| local expected | ||
| before_each(function() | ||
| package.loaded["cmake-tools.config"] = nil | ||
| Config = require("cmake-tools.config") | ||
| local_const = vim.deepcopy(const) | ||
| expected = { "--test-dir", "build_dir", "-R", "test_name" } | ||
| stub(utils, "run") | ||
| end) | ||
|
|
||
| it("takes extra args from user config", function() | ||
| local_const.ctest_extra_args = { "-j", "6" } | ||
| local config = Config:new(local_const) | ||
| ctest:run("test_name", "build_dir", "env", config, {}) | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ctest is not actually an instance. it is a plain table. The colon syntax is not right and passes a wrong value to the |
||
| table.insert(expected, "-j") | ||
| table.insert(expected, "6") | ||
| assert | ||
| .stub(utils.run).was | ||
| .called_with(match._, match._, match._, expected, match._, match._, match._) | ||
| end) | ||
|
|
||
| it("ignores extra args if not provided", function() | ||
| local config = Config:new(const) | ||
| ctest:run("test_name", "build_dir", "env", config, {}) | ||
| assert | ||
| .stub(utils.run).was | ||
| .called_with(match._, match._, match._, expected, match._, match._, match._) | ||
| end) | ||
| end) | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we can put this variable into
Config.base_settings? So we can edit it easily.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the idea. Done.