mirror of
https://github.com/uutils/coreutils.git
synced 2026-06-10 15:48:22 -07:00
Merge pull request #1336 from rinconjc/1321
Fix #1321 tsort handle self-loops
This commit is contained in:
Regular → Executable
+1
-1
@@ -149,7 +149,7 @@ impl Graph {
|
||||
self.init_node(from);
|
||||
}
|
||||
|
||||
if !self.has_edge(from, to) {
|
||||
if from != to && !self.has_edge(from, to) {
|
||||
self.in_edges.get_mut(to).unwrap().insert(from.clone());
|
||||
self.out_edges.get_mut(from).unwrap().push(to.clone());
|
||||
}
|
||||
|
||||
@@ -8,3 +8,10 @@ fn test_sort_call_graph() {
|
||||
.run()
|
||||
.stdout_is_fixture("call_graph.expected");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_sort_self_loop() {
|
||||
new_ucmd!()
|
||||
.pipe_in("first first\nfirst second second second")
|
||||
.succeeds().stdout_only("first\nsecond\n");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user