Skip to content

Commit 46c9825

Browse files
committed
Fix Go call graph query tests and VSIX packaging
Go query test fixes: - Add go.mod to CallGraphFromTo, CallGraphFrom, CallGraphTo test dirs (Go extractor requires module file for proper extraction) - Add main() function to all Go Example1.go test files - Fix fallback filter in all 3 Go call graph queries: getParentContainer().getParentContainer().getBaseName() = "test" → getFile().getBaseName() = "Example1.go" - Update all Go .expected files with non-empty results (4-5 rows each) VSIX packaging fix: - Add .tmp/** to .vscodeignore (was bundling 177MB of test databases) - VSIX size: 71.48MB → 788KB
1 parent bf397c1 commit 46c9825

File tree

13 files changed

+36
-8
lines changed

13 files changed

+36
-8
lines changed

extensions/vscode/.vscodeignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ esbuild.config.js
1616
coverage/**
1717

1818
# Build artifacts that shouldn't be in the VSIX
19+
.tmp/**
1920
**/*.test.ts
2021
**/*.test.js
2122
**/*.test.cjs

server/ql/go/tools/src/CallGraphFrom/CallGraphFrom.ql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ where
2727
// Use external predicate if available
2828
source.getName() = getSourceFunctionName()
2929
or
30-
// Fallback for unit tests: include test files
30+
// Fallback for unit tests: include calls from the example test file
3131
not exists(getSourceFunctionName()) and
32-
source.getFile().getParentContainer().getParentContainer().getBaseName() = "test"
32+
source.getFile().getBaseName() = "Example1.go"
3333
)
3434
select call, "Call from `" + source.getName() + "` to `" + call.getTarget().getName() + "`"

server/ql/go/tools/src/CallGraphFromTo/CallGraphFromTo.ql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,10 @@ where
5656
)
5757
)
5858
or
59-
// Fallback for unit tests: include test files
59+
// Fallback for unit tests: include calls from the example test file
6060
not exists(getSourceFunctionName()) and
6161
not exists(getTargetFunctionName()) and
62-
caller.getFile().getParentContainer().getParentContainer().getBaseName() = "test"
62+
caller.getFile().getBaseName() = "Example1.go"
6363
)
6464
select call,
6565
"Reachable call from `" + caller.getName() + "` to `" + call.getTarget().getName() + "`"

server/ql/go/tools/src/CallGraphTo/CallGraphTo.ql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ where
3535
// Use external predicate if available
3636
call.getTarget().getName() = getTargetFunctionName()
3737
or
38-
// Fallback for unit tests: include test files
38+
// Fallback for unit tests: include calls from the example test file
3939
not exists(getTargetFunctionName()) and
40-
call.getFile().getParentContainer().getParentContainer().getBaseName() = "test"
40+
call.getFile().getBaseName() = "Example1.go"
4141
)
4242
select call, "Call to `" + call.getTarget().getName() + "` from `" + getCallerName(call) + "`"
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
| Example1.go:9:2:9:13 | call to unrelated1 | Call from `unrelated2` to `unrelated1` |
2+
| Example1.go:14:2:14:13 | call to unrelated1 | Call from `sourceFunc` to `unrelated1` |
3+
| Example1.go:15:2:15:13 | call to unrelated2 | Call from `sourceFunc` to `unrelated2` |
4+
| Example1.go:19:2:19:13 | call to sourceFunc | Call from `main` to `sourceFunc` |

server/ql/go/tools/test/CallGraphFrom/Example1.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,7 @@ func sourceFunc() {
1414
unrelated1()
1515
unrelated2()
1616
}
17+
18+
func main() {
19+
sourceFunc()
20+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module languages/go/tools/test/CallGraphFrom
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
1-
1+
| Example1.go:7:2:7:12 | call to unrelated | Reachable call from `target` to `unrelated` |
2+
| Example1.go:11:2:11:9 | call to target | Reachable call from `intermediate` to `target` |
3+
| Example1.go:15:2:15:15 | call to intermediate | Reachable call from `source` to `intermediate` |
4+
| Example1.go:19:2:19:9 | call to source | Reachable call from `main` to `source` |

server/ql/go/tools/test/CallGraphFromTo/Example1.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package main
22

33
func unrelated() {
4-
// No calls
54
}
65

76
func target() {
@@ -15,3 +14,7 @@ func intermediate() {
1514
func source() {
1615
intermediate()
1716
}
17+
18+
func main() {
19+
source()
20+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module languages/go/tools/test/CallGraphFromTo

0 commit comments

Comments
 (0)