@@ -14,6 +14,7 @@ use tree_sitter_stack_graphs::StackGraphLanguage;
1414
1515use crate :: edges:: check_stack_graph_edges;
1616use crate :: nodes:: check_stack_graph_nodes;
17+ use crate :: FILE_PATH_VAR ;
1718
1819#[ test]
1920fn can_support_preexisting_nodes ( ) {
@@ -25,15 +26,17 @@ fn can_support_preexisting_nodes() {
2526 let python = "pass" ;
2627
2728 let file_name = "test.py" ;
28- let source_path = Path :: new ( file_name) ;
29- let source_root = Path :: new ( "" ) ;
3029
3130 let mut graph = StackGraph :: new ( ) ;
3231 let file = graph. get_or_create_file ( file_name) ;
3332 let node_id = graph. new_node_id ( file) ;
3433 let _preexisting_node = graph. add_scope_node ( node_id, true ) . unwrap ( ) ;
3534
36- let globals = Variables :: new ( ) ;
35+ let mut globals = Variables :: new ( ) ;
36+ globals
37+ . add ( FILE_PATH_VAR . into ( ) , file_name. into ( ) )
38+ . expect ( "failed to add file path variable" ) ;
39+
3740 let language = StackGraphLanguage :: from_str ( tree_sitter_python:: language ( ) , tsg) . unwrap ( ) ;
3841 language
3942 . build_stack_graph_into ( & mut graph, file, python, & globals, & NoCancellation )
@@ -52,8 +55,6 @@ fn can_support_injected_nodes() {
5255 let python = "pass" ;
5356
5457 let file_name = "test.py" ;
55- let source_path = Path :: new ( file_name) ;
56- let source_root = Path :: new ( "" ) ;
5758
5859 let mut graph = StackGraph :: new ( ) ;
5960 let file = graph. get_or_create_file ( file_name) ;
@@ -64,6 +65,10 @@ fn can_support_injected_nodes() {
6465 let mut builder = language. builder_into_stack_graph ( & mut graph, file, python) ;
6566
6667 let mut globals = Variables :: new ( ) ;
68+ globals
69+ . add ( FILE_PATH_VAR . into ( ) , file_name. into ( ) )
70+ . expect ( "failed to add file path variable" ) ;
71+
6772 globals
6873 . add ( "EXT_NODE" . into ( ) , builder. inject_node ( node_id) . into ( ) )
6974 . expect ( "Failed to add EXT_NODE variable" ) ;
0 commit comments