Skip to content

Commit 276a825

Browse files
committed
Python: Allow same function name in call-graph tests
1 parent 8a56b48 commit 276a825

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

python/ql/test/experimental/library-tests/CallGraph/InlineCallGraphTest.expected

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
failures
22
debug_callableNotUnique
3-
| code/class_properties.py:10:5:10:18 | Function arg | Qualified function name 'Prop.arg' is not unique within its file. Please fix. |
4-
| code/class_properties.py:15:5:15:25 | Function arg | Qualified function name 'Prop.arg' is not unique within its file. Please fix. |
5-
| code/class_properties.py:20:5:20:18 | Function arg | Qualified function name 'Prop.arg' is not unique within its file. Please fix. |
63
pointsTo_found_typeTracker_notFound
74
| code/class_attr_assign.py:10:9:10:27 | ControlFlowNode for Attribute() | my_func |
85
| code/class_attr_assign.py:11:9:11:25 | ControlFlowNode for Attribute() | my_func |

python/ql/test/experimental/library-tests/CallGraph/InlineCallGraphTest.ql

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,13 @@ bindingset[func]
7676
string betterQualName(Function func) {
7777
// note: `target.getQualifiedName` for Lambdas is just "lambda", so is not very useful :|
7878
not func.isLambda() and
79-
result = func.getQualifiedName()
79+
if
80+
strictcount(Function f |
81+
f.getEnclosingModule() = func.getEnclosingModule() and
82+
f.getQualifiedName() = func.getQualifiedName()
83+
) = 1
84+
then result = func.getQualifiedName()
85+
else result = func.getLocation().getStartLine() + ":" + func.getQualifiedName()
8086
or
8187
func.isLambda() and
8288
result =
@@ -88,7 +94,7 @@ query predicate debug_callableNotUnique(Function callable, string message) {
8894
exists(callable.getLocation().getFile().getRelativePath()) and
8995
exists(Function f |
9096
f != callable and
91-
f.getQualifiedName() = callable.getQualifiedName() and
97+
betterQualName(f) = betterQualName(callable) and
9298
f.getLocation().getFile() = callable.getLocation().getFile()
9399
) and
94100
message =

0 commit comments

Comments
 (0)