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

Commit 2974046

Browse files
author
Hendrik van Antwerpen
committed
Change more tests to use minimal partial paths set directly
1 parent da499ac commit 2974046

File tree

2 files changed

+15
-64
lines changed

2 files changed

+15
-64
lines changed

stack-graphs/tests/it/can_find_node_partial_paths_in_database.rs

Lines changed: 7 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ use stack_graphs::graph::StackGraph;
1414
use stack_graphs::partial::PartialPath;
1515
use stack_graphs::partial::PartialPaths;
1616
use stack_graphs::stitching::Database;
17-
use stack_graphs::stitching::ForwardPartialPathStitcher;
1817
use stack_graphs::NoCancellation;
1918

2019
use crate::test_graphs;
@@ -28,29 +27,17 @@ fn check_node_partial_paths(
2827
let id = NodeID::new_in_file(file, id.1);
2928
let node = graph.node_for_id(id).expect("Cannot find node");
3029
let mut partials = PartialPaths::new();
31-
let mut db0 = Database::new();
30+
let mut db = Database::new();
3231
partials
3332
.find_minimal_partial_paths_set_in_file(
3433
graph,
3534
file,
3635
&NoCancellation,
3736
|graph, partials, path| {
38-
db0.add_partial_path(graph, partials, path);
37+
db.add_partial_path(graph, partials, path);
3938
},
4039
)
4140
.expect("should never be cancelled");
42-
let mut db = Database::new();
43-
#[allow(deprecated)]
44-
ForwardPartialPathStitcher::find_locally_complete_partial_paths(
45-
graph,
46-
&mut partials,
47-
&mut db0,
48-
&NoCancellation,
49-
|g, ps, p| {
50-
db.add_partial_path(g, ps, p.clone());
51-
},
52-
)
53-
.expect("should never be cancelled");
5441

5542
let mut results = Vec::<Handle<PartialPath>>::new();
5643
db.find_candidate_partial_paths_from_node(graph, &mut partials, node, &mut results);
@@ -77,8 +64,7 @@ fn class_field_through_function_parameter() {
7764
&mut graph,
7865
("main.py", 10),
7966
&[
80-
"<%1> ($1) [main.py(10) reference bar] -> [root] <a.foo()/([main.py(7)],$1).bar,%1> ($1)",
81-
"<%1> ($1) [main.py(10) reference bar] -> [root] <b.foo()/([main.py(7)],$1).bar,%1> ($1)",
67+
"<%1> ($1) [main.py(10) reference bar] -> [main.py(13) reference foo] <foo()/([main.py(7)],$1).bar,%1> ($1)",
8268
],
8369
);
8470
check_node_partial_paths(
@@ -99,7 +85,7 @@ fn cyclic_imports_python() {
9985
check_node_partial_paths(
10086
&mut graph,
10187
("main.py", 6),
102-
&["<%1> ($1) [main.py(6) reference foo] -> [root] <a.foo,%1> ($1)"],
88+
&["<%1> ($1) [main.py(6) reference foo] -> [main.py(8) reference a] <a.foo,%1> ($1)"],
10389
);
10490
check_node_partial_paths(
10591
&mut graph,
@@ -119,15 +105,12 @@ fn cyclic_imports_rust() {
119105
check_node_partial_paths(
120106
&mut graph,
121107
("test.rs", 101),
122-
&[
123-
"<%1> ($1) [test.rs(101) reference FOO] -> [test.rs(204) definition BAR] <%1> ($1)",
124-
"<%1> ($1) [test.rs(101) reference FOO] -> [test.rs(304) definition FOO] <%1> ($1)",
125-
],
108+
&["<%1> ($1) [test.rs(101) reference FOO] -> [test.rs(103) reference a] <a::FOO,%1> ($1)"],
126109
);
127110
check_node_partial_paths(
128111
&mut graph,
129112
("test.rs", 305),
130-
&["<%1> ($1) [test.rs(305) reference BAR] -> [test.rs(204) definition BAR] <%1> ($1)"],
113+
&["<%1> ($1) [test.rs(305) reference BAR] -> [test.rs(307) reference a] <a::BAR,%1> ($1)"],
131114
);
132115
}
133116

@@ -137,7 +120,7 @@ fn sequenced_import_star() {
137120
check_node_partial_paths(
138121
&mut graph,
139122
("main.py", 6),
140-
&["<%1> ($1) [main.py(6) reference foo] -> [root] <a.foo,%1> ($1)"],
123+
&["<%1> ($1) [main.py(6) reference foo] -> [main.py(8) reference a] <a.foo,%1> ($1)"],
141124
);
142125
check_node_partial_paths(
143126
&mut graph,

stack-graphs/tests/it/can_find_root_partial_paths_in_database.rs

Lines changed: 8 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ use stack_graphs::paths::Paths;
1717
use stack_graphs::paths::ScopedSymbol;
1818
use stack_graphs::paths::SymbolStack;
1919
use stack_graphs::stitching::Database;
20-
use stack_graphs::stitching::ForwardPartialPathStitcher;
2120
use stack_graphs::stitching::SymbolStackKey;
2221
use stack_graphs::NoCancellation;
2322

@@ -32,29 +31,17 @@ fn check_root_partial_paths(
3231
let file = graph.get_file_unchecked(file);
3332
let mut paths = Paths::new();
3433
let mut partials = PartialPaths::new();
35-
let mut db0 = Database::new();
34+
let mut db = Database::new();
3635
partials
3736
.find_minimal_partial_paths_set_in_file(
3837
graph,
3938
file,
4039
&NoCancellation,
4140
|graph, partials, path| {
42-
db0.add_partial_path(graph, partials, path);
41+
db.add_partial_path(graph, partials, path);
4342
},
4443
)
4544
.expect("should never be cancelled");
46-
let mut db = Database::new();
47-
#[allow(deprecated)]
48-
ForwardPartialPathStitcher::find_locally_complete_partial_paths(
49-
graph,
50-
&mut partials,
51-
&mut db0,
52-
&NoCancellation,
53-
|g, ps, p| {
54-
db.add_partial_path(g, ps, p.clone());
55-
},
56-
)
57-
.expect("should never be cancelled");
5845

5946
let mut symbol_stack = SymbolStack::empty();
6047
for symbol in precondition.iter().rev() {
@@ -92,11 +79,7 @@ fn class_field_through_function_parameter() {
9279
&mut graph,
9380
"main.py",
9481
&["__main__", ".", "baz"],
95-
&[
96-
"<__main__.,%2> ($1) [root] -> [root] <a.,%2> ($1)",
97-
"<__main__.,%2> ($1) [root] -> [root] <b.,%2> ($1)",
98-
"<__main__,%1> ($1) [root] -> [main.py(0) definition __main__] <%1> ($1)",
99-
],
82+
&["<__main__,%1> ($1) [root] -> [main.py(0) definition __main__] <%1> ($1)"],
10083
);
10184
check_root_partial_paths(
10285
&mut graph,
@@ -119,28 +102,19 @@ fn cyclic_imports_python() {
119102
&mut graph,
120103
"main.py",
121104
&["__main__", ".", "baz"],
122-
&[
123-
"<__main__,%1> ($1) [root] -> [main.py(0) definition __main__] <%1> ($1)",
124-
"<__main__.,%2> ($1) [root] -> [root] <a.,%2> ($1)",
125-
],
105+
&["<__main__,%1> ($1) [root] -> [main.py(0) definition __main__] <%1> ($1)"],
126106
);
127107
check_root_partial_paths(
128108
&mut graph,
129109
"a.py",
130110
&["a", ".", "baz"],
131-
&[
132-
"<a,%1> ($1) [root] -> [a.py(0) definition a] <%1> ($1)",
133-
"<a.,%2> ($1) [root] -> [root] <b.,%2> ($1)",
134-
],
111+
&["<a,%1> ($1) [root] -> [a.py(0) definition a] <%1> ($1)"],
135112
);
136113
check_root_partial_paths(
137114
&mut graph,
138115
"b.py",
139116
&["b", ".", "baz"],
140-
&[
141-
"<b,%1> ($1) [root] -> [b.py(0) definition b] <%1> ($1)",
142-
"<b.,%2> ($1) [root] -> [root] <a.,%2> ($1)",
143-
],
117+
&["<b,%1> ($1) [root] -> [b.py(0) definition b] <%1> ($1)"],
144118
);
145119
}
146120

@@ -164,19 +138,13 @@ fn sequenced_import_star() {
164138
&mut graph,
165139
"main.py",
166140
&["__main__", ".", "baz"],
167-
&[
168-
"<__main__,%1> ($1) [root] -> [main.py(0) definition __main__] <%1> ($1)",
169-
"<__main__.,%2> ($1) [root] -> [root] <a.,%2> ($1)",
170-
],
141+
&["<__main__,%1> ($1) [root] -> [main.py(0) definition __main__] <%1> ($1)"],
171142
);
172143
check_root_partial_paths(
173144
&mut graph,
174145
"a.py",
175146
&["a", ".", "baz"],
176-
&[
177-
"<a,%1> ($1) [root] -> [a.py(0) definition a] <%1> ($1)",
178-
"<a.,%2> ($1) [root] -> [root] <b.,%2> ($1)",
179-
],
147+
&["<a,%1> ($1) [root] -> [a.py(0) definition a] <%1> ($1)"],
180148
);
181149
check_root_partial_paths(
182150
&mut graph,

0 commit comments

Comments
 (0)