|
| 1 | +local match = require('luassert.match') |
| 2 | +local stub = require('luassert.stub') |
| 3 | +local const = require('cmake-tools.const') |
| 4 | +local ctest = require("cmake-tools.test.ctest") |
| 5 | +local utils = require('cmake-tools.utils') |
| 6 | + |
| 7 | +describe("run", function() |
| 8 | + local local_const |
| 9 | + local Config |
| 10 | + local expected |
| 11 | + before_each(function() |
| 12 | + package.loaded['cmake-tools.config'] = nil |
| 13 | + Config = require('cmake-tools.config') |
| 14 | + local_const = vim.deepcopy(const) |
| 15 | + expected = { "--test-dir", "build_dir", "-R", "test_name" } |
| 16 | + stub(utils, "run") |
| 17 | + end) |
| 18 | + |
| 19 | + it("takes extra args from user config", function() |
| 20 | + local_const.ctest_extra_args = { "-j", "6" } |
| 21 | + local config = Config:new(local_const) |
| 22 | + ctest:run("test_name", "build_dir", "env", config, {}) |
| 23 | + table.insert(expected, "-j") |
| 24 | + table.insert(expected, "6") |
| 25 | + assert.stub(utils.run).was.called_with(match._, match._, match._, expected, |
| 26 | + match._, match._, match._) |
| 27 | + end) |
| 28 | + |
| 29 | + it("ignores extra args if not provided", function() |
| 30 | + local config = Config:new(const) |
| 31 | + ctest:run("test_name", "build_dir", "env", config, {}) |
| 32 | + assert.stub(utils.run).was.called_with(match._, match._, match._, expected, |
| 33 | + match._, match._, match._) |
| 34 | + end) |
| 35 | +end) |
0 commit comments