-
Notifications
You must be signed in to change notification settings - Fork 43
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
feat: use --run flag when executing single test ( run single test instead of all of them ) #81
base: main
Are you sure you want to change the base?
Changes from all commits
1bc720a
89b601a
6f8ddea
ba5d536
97c2785
8a00ccf
dd03b1a
b955680
70a38ab
3760d92
be07d75
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 |
---|---|---|
|
@@ -134,7 +134,7 @@ describe("discover_positions", function() | |
id = vim.loop.cwd() .. "/neotest_go/cases_test.go", | ||
name = "cases_test.go", | ||
path = vim.loop.cwd() .. "/neotest_go/cases_test.go", | ||
range = { 0, 0, 49, 0 }, | ||
range = { 0, 0, 55, 0 }, | ||
type = "file", | ||
}, | ||
{ | ||
|
@@ -169,7 +169,7 @@ describe("discover_positions", function() | |
id = vim.loop.cwd() .. "/neotest_go/cases_test.go::TestAdd", | ||
name = "TestAdd", | ||
path = vim.loop.cwd() .. "/neotest_go/cases_test.go", | ||
range = { 35, 0, 48, 1 }, | ||
range = { 35, 0, 54, 1 }, | ||
type = "test", | ||
}, | ||
{ | ||
|
@@ -190,6 +190,24 @@ describe("discover_positions", function() | |
type = "test", | ||
}, | ||
}, | ||
{ | ||
{ | ||
id = vim.loop.cwd() .. "/neotest_go/cases_test.go::TestAdd::test_three", | ||
name = '"test three"', | ||
path = vim.loop.cwd() .. "/neotest_go/cases_test.go", | ||
range = { 44, 1, 48, 3 }, | ||
type = "test", | ||
}, | ||
{ | ||
{ | ||
id = vim.loop.cwd() .. '/neotest_go/cases_test.go::TestAdd::"test three"::test_four', | ||
name = '"test four"', | ||
path = vim.loop.cwd() .. "/neotest_go/cases_test.go", | ||
range = { 45, 2, 47, 4 }, | ||
type = "test", | ||
}, | ||
}, | ||
}, | ||
}, | ||
} | ||
|
||
|
@@ -355,6 +373,33 @@ describe("build_spec", function() | |
assert.are.same(expected_command, result.command) | ||
assert.are.same(path, result.context.file) | ||
end) | ||
async.it("build specification for single test", function() | ||
local path = vim.loop.cwd() .. "/neotest_go/main_test.go" | ||
local tree = plugin.discover_positions(path):children()[1] | ||
|
||
local args = { tree = tree } | ||
local expected_command = "cd " | ||
.. vim.loop.cwd() | ||
.. "/neotest_go && go test -v -json -count=1 -timeout=60s -run ^TestAddOne$ ./" | ||
local result = plugin.build_spec(args) | ||
assert.are.same(expected_command, result.command) | ||
assert.are.same(path, result.context.file) | ||
end) | ||
|
||
async.it("build specification for single nested test", function() | ||
local path = vim.loop.cwd() .. "/neotest_go/cases_test.go" | ||
local tree = plugin.discover_positions(path) | ||
local test_tree = tree:children()[2]:children()[3]:children()[1] | ||
|
||
local args = { tree = test_tree } | ||
local expected_command = "cd " | ||
.. vim.loop.cwd() | ||
.. "/neotest_go && go test -v -json -count=1 -timeout=60s -run ^TestAdd/test_three/test_four$ ./" | ||
local result = plugin.build_spec(args) | ||
assert.are.same(expected_command, result.command) | ||
assert.are.same(path, result.context.file) | ||
end) | ||
-- This test is overwriting plugin global state, keep it at end of the file or face the consequences ¯\_(ツ)_/¯ | ||
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. How does it overwrite plugin global state? 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. I don't know enough about lua module imports, but... i think you can't set recursive_run to false, after it was set to something 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. Anyway, if you try to move the test anywhere in the spec file. The test will fail |
||
async.it("build specification for many_table_test.go recuresive run", function() | ||
local plugin_with_recursive_run = require("neotest-go")({ recursive_run = true }) | ||
local path = vim.loop.cwd() .. "/neotest_go/many_table_test.go" | ||
|
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.
So we don't need that check anymore, do we?
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.
Which check do you mean?