Skip to content
This repository was archived by the owner on Sep 9, 2025. It is now read-only.

Commit 8a98dce

Browse files
committed
fix: add missing paths
1 parent b326053 commit 8a98dce

File tree

2 files changed

+20
-5
lines changed

2 files changed

+20
-5
lines changed

tree-sitter-stack-graphs/tests/it/builder.rs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ use tree_sitter_stack_graphs::StackGraphLanguage;
1414

1515
use crate::edges::check_stack_graph_edges;
1616
use crate::nodes::check_stack_graph_nodes;
17+
use crate::FILE_PATH_VAR;
1718

1819
#[test]
1920
fn 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");

tree-sitter-stack-graphs/tests/it/test.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
// Please see the LICENSE-APACHE or LICENSE-MIT files in this distribution for license details.
66
// ------------------------------------------------------------------------------------------------
77

8+
use crate::FILE_PATH_VAR;
89
use once_cell::sync::Lazy;
910
use pretty_assertions::assert_eq;
1011
use stack_graphs::arena::Handle;
@@ -94,9 +95,18 @@ fn check_test(
9495
expected_successes + expected_failures,
9596
assertion_count,
9697
);
98+
9799
let mut globals = Variables::new();
98100
for fragments in &test.fragments {
99101
globals.clear();
102+
103+
globals
104+
.add(
105+
FILE_PATH_VAR.into(),
106+
fragments.path.to_str().unwrap().into(),
107+
)
108+
.expect("failed to add file path variable");
109+
100110
fragments.add_globals_to(&mut globals);
101111
build_stack_graph_into(
102112
&mut test.graph,

0 commit comments

Comments
 (0)