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

Commit 8704616

Browse files
author
Hendrik van Antwerpen
committed
Use a single cancellation flag
1 parent 7b82481 commit 8704616

File tree

1 file changed

+9
-4
lines changed
  • tree-sitter-stack-graphs/src/cli

1 file changed

+9
-4
lines changed

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

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ use crate::loader::LanguageConfiguration;
2929
use crate::loader::Loader;
3030
use crate::test::Test;
3131
use crate::test::TestResult;
32+
use crate::CancellationFlag;
3233
use crate::LoadError;
3334
use crate::NoCancellation;
3435
use crate::StackGraphLanguage;
@@ -205,8 +206,10 @@ impl TestArgs {
205206
test_path: &Path,
206207
loader: &mut Loader,
207208
) -> anyhow::Result<TestResult> {
209+
let cancellation_flag = &NoCancellation;
210+
208211
let mut file_reader = FileReader::new();
209-
let lc = match loader.load_for_file(test_path, &mut file_reader, &NoCancellation)? {
212+
let lc = match loader.load_for_file(test_path, &mut file_reader, cancellation_flag)? {
210213
Some(sgl) => sgl,
211214
None => {
212215
if self.show_ignored {
@@ -235,7 +238,7 @@ impl TestArgs {
235238
&test_fragment.source,
236239
&mut all_paths,
237240
&test_fragment.globals,
238-
&NoCancellation,
241+
cancellation_flag,
239242
)?;
240243
} else if lc.matches_file(
241244
&test_fragment.path,
@@ -250,6 +253,7 @@ impl TestArgs {
250253
&test_fragment.source,
251254
&globals,
252255
&mut test.graph,
256+
cancellation_flag,
253257
)?;
254258
} else {
255259
return Err(anyhow!(
@@ -259,7 +263,7 @@ impl TestArgs {
259263
));
260264
}
261265
}
262-
let result = test.run(&NoCancellation)?;
266+
let result = test.run(cancellation_flag)?;
263267
let success = self.handle_result(test_path, &result)?;
264268
if self.output_mode.test(!success) {
265269
let files = test.fragments.iter().map(|f| f.file).collect::<Vec<_>>();
@@ -294,8 +298,9 @@ impl TestArgs {
294298
source: &str,
295299
globals: &Variables,
296300
graph: &mut StackGraph,
301+
cancellation_flag: &dyn CancellationFlag,
297302
) -> anyhow::Result<()> {
298-
match sgl.build_stack_graph_into(graph, file, source, globals, &NoCancellation) {
303+
match sgl.build_stack_graph_into(graph, file, source, globals, cancellation_flag) {
299304
Err(LoadError::ParseErrors(parse_errors)) => {
300305
Err(map_parse_errors(test_path, &parse_errors, source, " "))
301306
}

0 commit comments

Comments
 (0)