Skip to content

Commit 9d7c524

Browse files
committed
Basic python overlay tests
The base source is in basic-overlay-eval/orig_src, the overlay source is in basic-full-eval. We run two tests: a full evaluation test in basic-full-eval, and an overlay evaluation test in basic-overlay-eval. The test source and expected results are the SAME, due to the .qlref, meaning we expect the same results for full and overlay evaluation.
1 parent 20d4e42 commit 9d7c524

File tree

14 files changed

+201
-0
lines changed

14 files changed

+201
-0
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
from new import *
2+
from lib import *
3+
4+
def get_greeting():
5+
return combine("Goodbye", get_new_target())
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
from greeting import *
2+
3+
if __name__ == "__main__":
4+
print(get_greeting())
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
def combine(a, b): return f"{a}, {b}!"
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
def get_new_target():
2+
return "世界"
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
semmle-extractor-options: -R . -m hello.py --filter exclude:**/*.testproj/**
Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
testStringLiterals
2+
| greeting.py:5:20:5:28 | StringLiteral | Goodbye |
3+
| hello.py:3:16:3:25 | StringLiteral | __main__ |
4+
| lib/__init__.py:1:27:1:29 | StringLiteral | |
5+
| lib/__init__.py:1:31:1:34 | StringLiteral | , |
6+
| lib/__init__.py:1:36:1:38 | StringLiteral | ! |
7+
| new.py:2:12:2:15 | StringLiteral | \u4e16\u754c |
8+
testModules
9+
| greeting.py:0:0:0:0 | Module greeting |
10+
| hello.py:0:0:0:0 | Module hello |
11+
| lib/__init__.py:0:0:0:0 | Module lib.__init__ |
12+
| lib:0:0:0:0 | Package lib |
13+
| new.py:0:0:0:0 | Module new |
14+
testFunctions
15+
| greeting.py:4:1:4:19 | Function get_greeting |
16+
| lib/__init__.py:1:1:1:18 | Function combine |
17+
| new.py:1:1:1:21 | Function get_new_target |
18+
testClasses
19+
testLocations
20+
| greeting.py:0:0:0:0 | greeting.py:0 |
21+
| greeting.py:1:1:1:17 | greeting.py:1 |
22+
| greeting.py:1:6:1:8 | greeting.py:1 |
23+
| greeting.py:2:1:2:17 | greeting.py:2 |
24+
| greeting.py:2:6:2:8 | greeting.py:2 |
25+
| greeting.py:4:1:4:19 | greeting.py:4 |
26+
| greeting.py:4:1:4:19 | greeting.py:4 |
27+
| greeting.py:4:1:4:19 | greeting.py:4 |
28+
| greeting.py:4:5:4:16 | greeting.py:4 |
29+
| greeting.py:5:5:5:47 | greeting.py:5 |
30+
| greeting.py:5:12:5:18 | greeting.py:5 |
31+
| greeting.py:5:12:5:47 | greeting.py:5 |
32+
| greeting.py:5:20:5:28 | greeting.py:5 |
33+
| greeting.py:5:31:5:44 | greeting.py:5 |
34+
| greeting.py:5:31:5:46 | greeting.py:5 |
35+
| hello.py:0:0:0:0 | hello.py:0 |
36+
| hello.py:1:1:1:22 | hello.py:1 |
37+
| hello.py:1:6:1:13 | hello.py:1 |
38+
| hello.py:3:1:3:26 | hello.py:3 |
39+
| hello.py:3:4:3:11 | hello.py:3 |
40+
| hello.py:3:4:3:25 | hello.py:3 |
41+
| hello.py:3:16:3:25 | hello.py:3 |
42+
| hello.py:4:5:4:9 | hello.py:4 |
43+
| hello.py:4:5:4:25 | hello.py:4 |
44+
| hello.py:4:5:4:25 | hello.py:4 |
45+
| hello.py:4:11:4:22 | hello.py:4 |
46+
| hello.py:4:11:4:24 | hello.py:4 |
47+
| lib/__init__.py:0:0:0:0 | lib/__init__.py:0 |
48+
| lib/__init__.py:1:1:1:18 | lib/__init__.py:1 |
49+
| lib/__init__.py:1:1:1:18 | lib/__init__.py:1 |
50+
| lib/__init__.py:1:1:1:18 | lib/__init__.py:1 |
51+
| lib/__init__.py:1:5:1:11 | lib/__init__.py:1 |
52+
| lib/__init__.py:1:13:1:13 | lib/__init__.py:1 |
53+
| lib/__init__.py:1:16:1:16 | lib/__init__.py:1 |
54+
| lib/__init__.py:1:20:1:38 | lib/__init__.py:1 |
55+
| lib/__init__.py:1:27:1:29 | lib/__init__.py:1 |
56+
| lib/__init__.py:1:27:1:38 | lib/__init__.py:1 |
57+
| lib/__init__.py:1:30:1:30 | lib/__init__.py:1 |
58+
| lib/__init__.py:1:31:1:34 | lib/__init__.py:1 |
59+
| lib/__init__.py:1:35:1:35 | lib/__init__.py:1 |
60+
| lib/__init__.py:1:36:1:38 | lib/__init__.py:1 |
61+
| lib:0:0:0:0 | lib:0 |
62+
| new.py:0:0:0:0 | new.py:0 |
63+
| new.py:1:1:1:21 | new.py:1 |
64+
| new.py:1:1:1:21 | new.py:1 |
65+
| new.py:1:1:1:21 | new.py:1 |
66+
| new.py:1:5:1:18 | new.py:1 |
67+
| new.py:2:5:2:15 | new.py:2 |
68+
| new.py:2:12:2:15 | new.py:2 |
69+
testFiles
70+
| greeting.py:0:0:0:0 | greeting.py |
71+
| hello.py:0:0:0:0 | hello.py |
72+
| lib/__init__.py:0:0:0:0 | lib/__init__.py |
73+
| new.py:0:0:0:0 | new.py |
74+
testCfgNodes
75+
| greeting.py:0:0:0:0 | Entry node for Module greeting |
76+
| greeting.py:0:0:0:0 | Exit node for Module greeting |
77+
| greeting.py:1:1:1:17 | ControlFlowNode for from new import * |
78+
| greeting.py:1:6:1:8 | ControlFlowNode for ImportExpr |
79+
| greeting.py:2:1:2:17 | ControlFlowNode for from lib import * |
80+
| greeting.py:2:6:2:8 | ControlFlowNode for ImportExpr |
81+
| greeting.py:4:1:4:19 | ControlFlowNode for FunctionExpr |
82+
| greeting.py:4:1:4:19 | Entry node for Function get_greeting |
83+
| greeting.py:4:1:4:19 | Exit node for Function get_greeting |
84+
| greeting.py:4:5:4:16 | ControlFlowNode for get_greeting |
85+
| greeting.py:5:5:5:47 | ControlFlowNode for Return |
86+
| greeting.py:5:12:5:18 | ControlFlowNode for combine |
87+
| greeting.py:5:12:5:47 | ControlFlowNode for combine() |
88+
| greeting.py:5:20:5:28 | ControlFlowNode for StringLiteral |
89+
| greeting.py:5:31:5:44 | ControlFlowNode for get_new_target |
90+
| greeting.py:5:31:5:46 | ControlFlowNode for get_new_target() |
91+
| hello.py:0:0:0:0 | Entry node for Module hello |
92+
| hello.py:0:0:0:0 | Exit node for Module hello |
93+
| hello.py:1:1:1:22 | ControlFlowNode for from greeting import * |
94+
| hello.py:1:6:1:13 | ControlFlowNode for ImportExpr |
95+
| hello.py:3:4:3:11 | ControlFlowNode for __name__ |
96+
| hello.py:3:4:3:25 | ControlFlowNode for Compare |
97+
| hello.py:3:16:3:25 | ControlFlowNode for StringLiteral |
98+
| hello.py:4:5:4:9 | ControlFlowNode for print |
99+
| hello.py:4:5:4:25 | ControlFlowNode for print() |
100+
| hello.py:4:11:4:22 | ControlFlowNode for get_greeting |
101+
| hello.py:4:11:4:24 | ControlFlowNode for get_greeting() |
102+
| lib/__init__.py:0:0:0:0 | Entry node for Module lib.__init__ |
103+
| lib/__init__.py:0:0:0:0 | Exit node for Module lib.__init__ |
104+
| lib/__init__.py:1:1:1:18 | ControlFlowNode for FunctionExpr |
105+
| lib/__init__.py:1:1:1:18 | Entry node for Function combine |
106+
| lib/__init__.py:1:1:1:18 | Exit node for Function combine |
107+
| lib/__init__.py:1:5:1:11 | ControlFlowNode for combine |
108+
| lib/__init__.py:1:13:1:13 | ControlFlowNode for a |
109+
| lib/__init__.py:1:16:1:16 | ControlFlowNode for b |
110+
| lib/__init__.py:1:20:1:38 | ControlFlowNode for Return |
111+
| lib/__init__.py:1:27:1:29 | ControlFlowNode for StringLiteral |
112+
| lib/__init__.py:1:27:1:38 | ControlFlowNode for Fstring |
113+
| lib/__init__.py:1:30:1:30 | ControlFlowNode for a |
114+
| lib/__init__.py:1:31:1:34 | ControlFlowNode for StringLiteral |
115+
| lib/__init__.py:1:35:1:35 | ControlFlowNode for b |
116+
| lib/__init__.py:1:36:1:38 | ControlFlowNode for StringLiteral |
117+
| lib:0:0:0:0 | Entry node for Package lib |
118+
| new.py:0:0:0:0 | Entry node for Module new |
119+
| new.py:0:0:0:0 | Exit node for Module new |
120+
| new.py:1:1:1:21 | ControlFlowNode for FunctionExpr |
121+
| new.py:1:1:1:21 | Entry node for Function get_new_target |
122+
| new.py:1:1:1:21 | Exit node for Function get_new_target |
123+
| new.py:1:5:1:18 | ControlFlowNode for get_new_target |
124+
| new.py:2:5:2:15 | ControlFlowNode for Return |
125+
| new.py:2:12:2:15 | ControlFlowNode for StringLiteral |
126+
testSsaVars
127+
| file://:0:0:0:0 | SSA Variable __name__ |
128+
| file://:0:0:0:0 | SSA Variable get_greeting |
129+
| file://:0:0:0:0 | SSA Variable print |
130+
| greeting.py:4:5:4:16 | SSA Variable get_greeting |
131+
| lib/__init__.py:1:5:1:11 | SSA Variable combine |
132+
| lib/__init__.py:1:13:1:13 | SSA Variable a |
133+
| lib/__init__.py:1:16:1:16 | SSA Variable b |
134+
| new.py:1:5:1:18 | SSA Variable get_new_target |
135+
testVars
136+
| Global Variable __name__ | greeting.py:0:0:0:0 | Module greeting |
137+
| Global Variable __name__ | hello.py:0:0:0:0 | Module hello |
138+
| Global Variable __name__ | lib/__init__.py:0:0:0:0 | Module lib.__init__ |
139+
| Global Variable __name__ | new.py:0:0:0:0 | Module new |
140+
| Global Variable __package__ | greeting.py:0:0:0:0 | Module greeting |
141+
| Global Variable __package__ | hello.py:0:0:0:0 | Module hello |
142+
| Global Variable __package__ | lib/__init__.py:0:0:0:0 | Module lib.__init__ |
143+
| Global Variable __package__ | new.py:0:0:0:0 | Module new |
144+
| Global Variable combine | greeting.py:0:0:0:0 | Module greeting |
145+
| Global Variable combine | lib/__init__.py:0:0:0:0 | Module lib.__init__ |
146+
| Global Variable get_greeting | greeting.py:0:0:0:0 | Module greeting |
147+
| Global Variable get_greeting | hello.py:0:0:0:0 | Module hello |
148+
| Global Variable get_new_target | greeting.py:0:0:0:0 | Module greeting |
149+
| Global Variable get_new_target | new.py:0:0:0:0 | Module new |
150+
| Global Variable print | hello.py:0:0:0:0 | Module hello |
151+
| Local Variable a | lib/__init__.py:1:1:1:18 | Function combine |
152+
| Local Variable b | lib/__init__.py:1:1:1:18 | Function combine |
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import python
2+
3+
query predicate testStringLiterals(StringLiteral l, string text) { l.getText() = text }
4+
5+
query predicate testModules(Module m) { any() }
6+
7+
query predicate testFunctions(Function f) { any() }
8+
9+
query predicate testClasses(Class c) { any() }
10+
11+
query predicate testLocations(Location l) { any() }
12+
13+
query predicate testFiles(File f) { any() }
14+
15+
query predicate testCfgNodes(ControlFlowNode n) { any() }
16+
17+
query predicate testSsaVars(SsaVariable var) { any() }
18+
19+
query predicate testVars(Variable var, Scope s) { s = var.getScope() }
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
overlay:
2+
base: "orig_src"
3+
overlay: "../basic-full-eval"
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
semmle-extractor-options: -R . -m hello.py --filter exclude:**/*.testproj/**
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
from old import *
2+
from lib import *
3+
4+
def get_greeting():
5+
return combine("Hello", get_old_target())

0 commit comments

Comments
 (0)