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

Commit 80ee87b

Browse files
author
Hendrik van Antwerpen
committed
Make test output similar to analyze
1 parent 90a87c8 commit 80ee87b

File tree

1 file changed

+31
-13
lines changed
  • tree-sitter-stack-graphs/src/cli

1 file changed

+31
-13
lines changed

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

Lines changed: 31 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -206,19 +206,24 @@ impl TestArgs {
206206
test_path: &Path,
207207
loader: &mut Loader,
208208
) -> anyhow::Result<TestResult> {
209-
let cancellation_flag = &NoCancellation;
210-
211209
if self.show_skipped && test_path.extension().map_or(false, |e| e == "skip") {
212-
println!("{} {}", "⦵".dimmed(), test_path.display());
210+
println!("{}: {}", test_path.display(), "skipped".yellow());
213211
return Ok(TestResult::new());
214212
}
215213

214+
let cancellation_flag = &NoCancellation;
215+
216216
let mut file_reader = FileReader::new();
217217
let lc = match loader.load_for_file(test_path, &mut file_reader, cancellation_flag)? {
218218
Some(sgl) => sgl,
219219
None => return Ok(TestResult::new()),
220220
};
221221
let source = file_reader.get(test_path)?;
222+
223+
if !self.hide_passing {
224+
print!("{}: ", test_path.display());
225+
}
226+
222227
let default_fragment_path = test_path.strip_prefix(test_root).unwrap();
223228
let mut test = Test::from_source(&test_path, &source, default_fragment_path)?;
224229
self.load_builtins_into(&lc, &mut test.graph)
@@ -311,18 +316,27 @@ impl TestArgs {
311316

312317
fn handle_result(&self, test_path: &Path, result: &TestResult) -> anyhow::Result<bool> {
313318
let success = result.failure_count() == 0;
314-
if !success || !self.hide_passing {
319+
if success {
320+
if !self.hide_passing {
321+
println!("{}", "success".green());
322+
}
323+
} else {
324+
if self.hide_passing {
325+
print!("{}: ", test_path.display());
326+
}
315327
println!(
316-
"{} {}: {}/{} assertions",
317-
if success { "✓".green() } else { "✗".red() },
318-
test_path.display(),
319-
result.success_count(),
320-
result.count()
328+
"{}",
329+
format!(
330+
"{}/{} assertions failed",
331+
result.failure_count(),
332+
result.count(),
333+
)
334+
.red()
321335
);
322336
}
323337
if !success && !self.hide_failure_errors {
324338
for failure in result.failures_iter() {
325-
println!(" {}", failure);
339+
println!("{}", failure);
326340
}
327341
}
328342
Ok(success)
@@ -344,7 +358,7 @@ impl TestArgs {
344358
{
345359
self.save_graph(&path, &graph, filter)?;
346360
if !success || !self.hide_passing {
347-
println!(" Graph: {}", path.display());
361+
println!("{}: graph at {}", test_path.display(), path.display());
348362
}
349363
}
350364
if let Some(path) = self
@@ -354,7 +368,7 @@ impl TestArgs {
354368
{
355369
self.save_paths(&path, paths, graph, filter)?;
356370
if !success || !self.hide_passing {
357-
println!(" Paths: {}", path.display());
371+
println!("{}: paths at {}", test_path.display(), path.display());
358372
}
359373
}
360374
if let Some(path) = self
@@ -364,7 +378,11 @@ impl TestArgs {
364378
{
365379
self.save_visualization(&path, paths, graph, filter, &test_path)?;
366380
if !success || !self.hide_passing {
367-
println!(" Visualization: {}", path.display());
381+
println!(
382+
"{}: visualization at {}",
383+
test_path.display(),
384+
path.display()
385+
);
368386
}
369387
}
370388
Ok(())

0 commit comments

Comments
 (0)