@@ -3,7 +3,7 @@ local please = require('please')
33local runner = require (' please.runner' )
44local temptree = require (' tests.temptree' )
55
6- -- require('please.logging').toggle_debug()
6+ require (' please.logging' ).toggle_debug ()
77
88-- When this test file is run multiple times in parallel (in a non-sandboxed environment), at least one of the runs
99-- usually fails because some functionality being tested relies on use of the clipboard which is being shared between
@@ -1007,6 +1007,42 @@ describe('jump_to_target', function()
10071007 end )
10081008end )
10091009
1010+ describe (' look_up_target' , function ()
1011+ it (' should jump to build target which uses it as an input' , function ()
1012+ local root = temptree .create ({
1013+ ' .plzconfig' ,
1014+ [' pkg/' ] = {
1015+ BUILD = [[
1016+ export_file(
1017+ name = "foo1",
1018+ src = "foo1.txt",
1019+ )
1020+
1021+ export_file(
1022+ name = "foo2",
1023+ src = "foo2.txt",
1024+ )
1025+ ]] ,
1026+ },
1027+ })
1028+ local input_fake = InputFake :new ()
1029+
1030+ -- GIVEN we're editing a file
1031+ vim .cmd (' edit ' .. root .. ' /foo1.txt' )
1032+ -- WHEN we call look_up_target
1033+ please .look_up_target ()
1034+ -- THEN we're prompted to enter the build target to look up
1035+ input_fake :assert_prompt (' Enter target to look up' )
1036+ -- WHEN we enter a build target
1037+ input_fake :enter_input (' //pkg:foo2' )
1038+ vim .wait (500 )
1039+ -- THEN the BUILD file containing the build target is opened
1040+ assert .equal (root .. ' /pkg/BUILD' , vim .api .nvim_buf_get_name (0 ), ' incorrect BUILD file' )
1041+ -- AND the cursor is moved to the build target
1042+ assert .same ({ 6 , 0 }, vim .api .nvim_win_get_cursor (0 ), ' incorrect cursor position' )
1043+ end )
1044+ end )
1045+
10101046describe (' yank' , function ()
10111047 local function create_temp_tree ()
10121048 return temptree .create ({
0 commit comments