@@ -23,12 +23,14 @@ suite("Run Task References Test Suite", function () {
2323 document = await vscode . workspace . openTextDocument ( uri ) ;
2424 } ) ;
2525
26- /** Position on `name `, on the fixture line holding it */
27- const positionOf = ( name : string ) : vscode . Position => {
26+ /** Position on `word `, on the fixture line holding `marker` */
27+ const positionOf = ( marker : string , word = marker ) : vscode . Position => {
2828 const lines = document . getText ( ) . split ( "\n" ) ;
29- const line = lines . findIndex ( ( text ) => text . includes ( name ) ) ;
30- assert . ok ( line >= 0 , `"${ name } " should be in the fixture` ) ;
31- return new vscode . Position ( line , ( lines [ line ] ?? "" ) . indexOf ( name ) + 1 ) ;
29+ const line = lines . findIndex ( ( text ) => text . includes ( marker ) ) ;
30+ assert . ok ( line >= 0 , `"${ marker } " should be in the fixture` ) ;
31+ const character = ( lines [ line ] ?? "" ) . indexOf ( word ) ;
32+ assert . ok ( character >= 0 , `"${ word } " should be on the ${ marker } line` ) ;
33+ return new vscode . Position ( line , character + 1 ) ;
3234 } ;
3335
3436 const definitionsAt = async ( position : vscode . Position ) =>
@@ -58,31 +60,32 @@ suite("Run Task References Test Suite", function () {
5860 test ( "goes to the definition of the task of a run entry" , async ( ) => {
5961 const definitions = await definitionsAt ( positionOf ( '"//:root-task"' ) ) ;
6062
61- assert . equal ( definitions . length , 1 ) ;
62- const [ definition ] = definitions ;
63- assert . ok ( definition , "expected a definition for //:root-task" ) ;
64- assert . ok (
65- definition . targetUri . path . endsWith ( "monorepo-workspace/mise.toml" ) ,
66- `expected the root config, got ${ definition . targetUri . path } ` ,
67- ) ;
68- const targetLine = (
69- definition . targetSelectionRange ?? definition . targetRange
70- ) . start . line ;
63+ const targetLines = definitions
64+ . filter ( ( definition ) =>
65+ definition . targetUri . path . endsWith ( "monorepo-workspace/mise.toml" ) ,
66+ )
67+ . map (
68+ ( definition ) =>
69+ document . lineAt (
70+ ( definition . targetSelectionRange ?? definition . targetRange ) . start
71+ . line ,
72+ ) . text ,
73+ ) ;
7174 assert . ok (
72- document . lineAt ( targetLine ) . text . includes ( "[tasks.root-task]" ) ,
73- `expected the root-task header , got " ${ document . lineAt ( targetLine ) . text } " ` ,
75+ targetLines . some ( ( text ) => text . includes ( "[tasks.root-task]" ) ) ,
76+ `expected a link to the declaration , got ${ JSON . stringify ( targetLines ) } ` ,
7477 ) ;
7578 } ) ;
7679
7780 test ( "goes to the definition of a parallel tasks entry" , async ( ) => {
7881 const definitions = await definitionsAt (
7982 positionOf ( '"//crates/agent:build"' ) ,
8083 ) ;
84+ const paths = definitions . map ( ( definition ) => definition . targetUri . path ) ;
8185
82- assert . equal ( definitions . length , 1 ) ;
8386 assert . ok (
84- definitions [ 0 ] ?. targetUri . path . endsWith ( "crates/agent/mise.toml" ) ,
85- `expected the agent crate config, got ${ definitions [ 0 ] ?. targetUri . path } ` ,
87+ paths . some ( ( targetPath ) => targetPath . endsWith ( "crates/agent/mise.toml" ) ) ,
88+ `expected the agent crate config, got ${ JSON . stringify ( paths ) } ` ,
8689 ) ;
8790 } ) ;
8891
@@ -118,9 +121,19 @@ suite("Run Task References Test Suite", function () {
118121 } ) ;
119122
120123 test ( "leaves the shell commands of the same array alone" , async ( ) => {
121- const position = positionOf ( '"echo verified"' ) ;
124+ // a plain entry is a shell command even when it names a task, and the
125+ // toml schema still hovers it: only our own task answers must be absent
126+ const position = positionOf ( '"echo build-all"' , "build-all" ) ;
122127
123- assert . deepEqual ( await definitionsAt ( position ) , [ ] ) ;
124- assert . equal ( await hoverTextAt ( position ) , "" ) ;
128+ const configLinks = ( await definitionsAt ( position ) ) . filter ( ( definition ) =>
129+ definition . targetUri . path . endsWith ( "mise.toml" ) ,
130+ ) ;
131+ assert . deepEqual ( configLinks , [ ] ) ;
132+
133+ const hoverText = await hoverTextAt ( position ) ;
134+ assert . ok (
135+ ! hoverText . includes ( "Build all the projects" ) ,
136+ `the shell command should not describe the task, got ${ hoverText } ` ,
137+ ) ;
125138 } ) ;
126139} ) ;
0 commit comments