Skip to content

Commit c7f9fd9

Browse files
committed
fix: check that FILE_PATH variable is none everywhere
1 parent 6bcb5a3 commit c7f9fd9

File tree

2 files changed

+20
-15
lines changed

2 files changed

+20
-15
lines changed

tree-sitter-stack-graphs/src/cli/test.rs

+10-8
Original file line numberDiff line numberDiff line change
@@ -318,15 +318,17 @@ impl TestArgs {
318318
)? {
319319
globals.clear();
320320

321-
// Add FILE_PATH to variables
322-
globals
323-
.add(
324-
FILE_PATH_VAR.into(),
325-
test_fragment.path.to_str().unwrap().into(),
326-
)
327-
.expect("failed to add file path variable");
328-
329321
test_fragment.add_globals_to(&mut globals);
322+
323+
if globals.get(&FILE_PATH_VAR.into()).is_none() {
324+
globals
325+
.add(
326+
FILE_PATH_VAR.into(),
327+
test_fragment.path.to_str().unwrap().into(),
328+
)
329+
.expect("failed to add file path variable");
330+
}
331+
330332
lc.sgl.build_stack_graph_into(
331333
&mut test.graph,
332334
test_fragment.file,

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

+10-7
Original file line numberDiff line numberDiff line change
@@ -100,14 +100,17 @@ fn check_test(
100100
for fragments in &test.fragments {
101101
globals.clear();
102102

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-
110103
fragments.add_globals_to(&mut globals);
104+
105+
if globals.get(&FILE_PATH_VAR.into()).is_none() {
106+
globals
107+
.add(
108+
FILE_PATH_VAR.into(),
109+
fragments.path.to_str().unwrap().into(),
110+
)
111+
.expect("failed to add file path variable");
112+
}
113+
111114
build_stack_graph_into(
112115
&mut test.graph,
113116
fragments.file,

0 commit comments

Comments
 (0)