Skip to content

Commit 6e20ea9

Browse files
committed
Don't always sort the test output, move into a direction where we don't do this in general
1 parent 22bf662 commit 6e20ea9

2 files changed

Lines changed: 14 additions & 5 deletions

File tree

crates/zuban_python/tests/mypylike/main.rs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -534,9 +534,14 @@ impl TestCase<'_, '_> {
534534
actual.push_str(r);
535535
actual.push('\n');
536536
}
537+
// Generally we should not sort any of the tests we wrote ourselves, but this might be
538+
// tricky for now due to determinism, so get closer slowly.
539+
let should_sort = !ide_test_results.iter().any(|s| s.contains("Symbols:"));
537540
actual_lines.extend(ide_test_results);
538541

539-
actual_lines.sort();
542+
if should_sort {
543+
actual_lines.sort();
544+
}
540545

541546
let mut wanted_cleaned_up: Vec<_> = wanted
542547
.iter()
@@ -551,11 +556,15 @@ impl TestCase<'_, '_> {
551556
})
552557
.filter_map(temporarily_skip)
553558
.collect();
554-
wanted_cleaned_up.sort();
559+
if should_sort {
560+
wanted_cleaned_up.sort();
561+
}
555562

556563
if wanted_cleaned_up != actual_lines {
557-
// To check output only sort by filenames, which should be enough.
558-
wanted.sort_by_key(|line| line.split(':').next().unwrap().to_owned());
564+
if should_sort {
565+
// To check output only sort by filenames, which should be enough.
566+
wanted.sort_by_key(|line| line.split(':').next().unwrap().to_owned());
567+
}
559568

560569
let wanted = wanted.iter().fold(String::new(), |a, b| a + b + "\n");
561570
result = Err(anyhow::anyhow!(

crates/zuban_python/tests/mypylike/tests/symbols.test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ global_var = 1
1515
[out]
1616
__main__.py:2: Symbols:
1717
- Class C (parent: None) (target-range: 2:0-12:0)
18+
- Constructor __init__ (parent: C) (target-range: 3:4-7:4)
1819
- Method foo (parent: C) (target-range: 7:4-10:4)
1920
- Field class_var (parent: C) (target-range: 10:4-10:17)
20-
- Constructor __init__ (parent: C) (target-range: 3:4-7:4)
2121
- Variable global_var (parent: None) (target-range: 12:0-12:14)
2222

2323
[case test_symbols_order]

0 commit comments

Comments
 (0)