Skip to content
This repository was archived by the owner on Jan 5, 2023. It is now read-only.

Commit 0de8ac3

Browse files
author
Sauyon Lee
authored
Merge pull request #305 from max-schaefer/consistency-queries
Enable consistency queries in tests
2 parents 42c1116 + b72c4f9 commit 0de8ac3

34 files changed

+318
-93
lines changed

.github/workflows/codeqltest.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
echo "Done"
2121
cd $HOME
2222
echo "Downloading CodeQL CLI..."
23-
curl https://github.com/github/codeql-cli-binaries/releases/download/v2.2.0/codeql.zip -L -o codeql.zip
23+
curl https://github.com/github/codeql-cli-binaries/releases/download/v2.2.5/codeql.zip -L -o codeql.zip
2424
echo "Done"
2525
echo "Unpacking CodeQL CLI..."
2626
unzip -q codeql.zip
@@ -56,7 +56,7 @@ jobs:
5656
echo "Done"
5757
cd $HOME
5858
echo "Downloading CodeQL CLI..."
59-
curl https://github.com/github/codeql-cli-binaries/releases/download/v2.2.0/codeql.zip -L -o codeql.zip
59+
curl https://github.com/github/codeql-cli-binaries/releases/download/v2.2.5/codeql.zip -L -o codeql.zip
6060
echo "Done"
6161
echo "Unpacking CodeQL CLI..."
6262
unzip -q codeql.zip
@@ -89,7 +89,7 @@ jobs:
8989
echo "Done"
9090
cd "$HOME"
9191
echo "Downloading CodeQL CLI..."
92-
Invoke-WebRequest -Uri https://github.com/github/codeql-cli-binaries/releases/download/v2.2.0/codeql.zip -OutFile codeql.zip
92+
Invoke-WebRequest -Uri https://github.com/github/codeql-cli-binaries/releases/download/v2.2.5/codeql.zip -OutFile codeql.zip
9393
echo "Done"
9494
echo "Unpacking CodeQL CLI..."
9595
Expand-Archive codeql.zip -DestinationPath $HOME

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,8 @@ ql/src/go.dbscheme.stats: ql/src/go.dbscheme build/stats/src.stamp extractor
106106
codeql dataset measure -o $@ build/stats/database/db-go
107107

108108
test: all build/testdb/check-upgrade-path
109-
codeql test run ql/test --search-path .
110-
env GOARCH=386 codeql$(EXE) test run ql/test/query-tests/Security/CWE-681 --search-path .
109+
codeql test run ql/test --search-path . --consistency-queries ql/test/consistency
110+
env GOARCH=386 codeql$(EXE) test run ql/test/query-tests/Security/CWE-681 --search-path . --consistency-queries ql/test/consistency
111111
cd extractor; go test -mod=vendor ./... | grep -vF "[no test files]"
112112

113113
.PHONY: build/testdb/check-upgrade-path
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
| test.go:7:1:7:1 | expected declaration, found This |
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
| test.go:7:1:7:1 | expected declaration, found This |
Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,11 @@
11
/**
22
* @name Unexpected frontend error
33
* @description This query produces a list of all errors produced by the Go frontend
4-
* during extraction, except for those occurring in files annotated with
5-
* "// codeql test: expect frontend errors".
4+
* during extraction.
65
* @id go/unexpected-frontend-error
76
*/
87

98
import go
109

1110
from Error e
12-
where
13-
not exists(Comment c | c.getFile() = e.getFile() |
14-
c.getText().trim() = "codeql test: expect frontend errors"
15-
)
1611
select e

ql/test/consistency/test.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ package main
22

33
// autoformat-ignore (gofmt chokes on invalid programs)
44

5-
// Example file with a syntax error to demonstrate use of "expect frontend errors" directive
6-
7-
// codeql test: expect frontend errors
5+
// Example file with a syntax error to demonstrate use of consistency queries
86

97
This is not a valid Go program

ql/test/library-tests/semmle/go/Expr/BasicLit_getText.expected

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,15 @@
2626
| consts.go:46:16:46:16 | 2 | 2 |
2727
| consts.go:47:16:47:18 | 1.0 | 1.0 |
2828
| consts.go:48:16:48:19 | "hi" | "hi" |
29-
| ellipsis.go:7:4:7:4 | 1 | 1 |
30-
| ellipsis.go:8:4:8:4 | 1 | 1 |
31-
| ellipsis.go:8:7:8:7 | 2 | 2 |
32-
| ellipsis.go:9:4:9:4 | 1 | 1 |
33-
| ellipsis.go:9:7:9:7 | 2 | 2 |
34-
| ellipsis.go:9:10:9:10 | 3 | 3 |
35-
| ellipsis.go:10:4:10:4 | 1 | 1 |
36-
| ellipsis.go:10:13:10:13 | 2 | 2 |
37-
| ellipsis.go:10:16:10:16 | 3 | 3 |
29+
| ellipsis.go:7:5:7:5 | 1 | 1 |
30+
| ellipsis.go:8:5:8:5 | 1 | 1 |
31+
| ellipsis.go:8:8:8:8 | 2 | 2 |
32+
| ellipsis.go:9:5:9:5 | 1 | 1 |
33+
| ellipsis.go:9:8:9:8 | 2 | 2 |
34+
| ellipsis.go:9:11:9:11 | 3 | 3 |
35+
| ellipsis.go:10:5:10:5 | 1 | 1 |
36+
| ellipsis.go:10:14:10:14 | 2 | 2 |
37+
| ellipsis.go:10:17:10:17 | 3 | 3 |
3838
| literals.go:3:8:3:12 | "fmt" | "fmt" |
3939
| literals.go:8:2:8:10 | "decimal" | "decimal" |
4040
| literals.go:8:17:8:18 | 42 | 42 |

ql/test/library-tests/semmle/go/Expr/BasicLit_getValue.expected

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,15 @@
2626
| consts.go:46:16:46:16 | 2 | 2 |
2727
| consts.go:47:16:47:18 | 1.0 | 1.0 |
2828
| consts.go:48:16:48:19 | "hi" | hi |
29-
| ellipsis.go:7:4:7:4 | 1 | 1 |
30-
| ellipsis.go:8:4:8:4 | 1 | 1 |
31-
| ellipsis.go:8:7:8:7 | 2 | 2 |
32-
| ellipsis.go:9:4:9:4 | 1 | 1 |
33-
| ellipsis.go:9:7:9:7 | 2 | 2 |
34-
| ellipsis.go:9:10:9:10 | 3 | 3 |
35-
| ellipsis.go:10:4:10:4 | 1 | 1 |
36-
| ellipsis.go:10:13:10:13 | 2 | 2 |
37-
| ellipsis.go:10:16:10:16 | 3 | 3 |
29+
| ellipsis.go:7:5:7:5 | 1 | 1 |
30+
| ellipsis.go:8:5:8:5 | 1 | 1 |
31+
| ellipsis.go:8:8:8:8 | 2 | 2 |
32+
| ellipsis.go:9:5:9:5 | 1 | 1 |
33+
| ellipsis.go:9:8:9:8 | 2 | 2 |
34+
| ellipsis.go:9:11:9:11 | 3 | 3 |
35+
| ellipsis.go:10:5:10:5 | 1 | 1 |
36+
| ellipsis.go:10:14:10:14 | 2 | 2 |
37+
| ellipsis.go:10:17:10:17 | 3 | 3 |
3838
| literals.go:3:8:3:12 | "fmt" | fmt |
3939
| literals.go:8:2:8:10 | "decimal" | decimal |
4040
| literals.go:8:17:8:18 | 42 | 42 |

ql/test/library-tests/semmle/go/Expr/CompositeLit.expected

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
| ellipsis.go:10:7:10:17 | composite literal | 0 | value | ellipsis.go:10:13:10:13 | 2 |
2-
| ellipsis.go:10:7:10:17 | composite literal | 1 | value | ellipsis.go:10:16:10:16 | 3 |
1+
| ellipsis.go:10:8:10:18 | slice literal | 0 | value | ellipsis.go:10:14:10:14 | 2 |
2+
| ellipsis.go:10:8:10:18 | slice literal | 1 | value | ellipsis.go:10:17:10:17 | 3 |
33
| literals.go:7:15:11:1 | map literal | 0 | key | literals.go:8:2:8:10 | "decimal" |
44
| literals.go:7:15:11:1 | map literal | 0 | value | literals.go:8:17:8:18 | 42 |
55
| literals.go:7:15:11:1 | map literal | 1 | key | literals.go:9:2:9:8 | "octal" |

ql/test/library-tests/semmle/go/Expr/ConstantValues.expected

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,12 @@
3131
| consts.go:34:20:34:20 | k | k | 2, 2 |
3232
| consts.go:34:23:34:23 | l | l | 1, 1 |
3333
| consts.go:34:26:34:26 | m | m | hi |
34+
| ellipsis.go:7:5:7:5 | 1 | 1 | 1, 1 |
35+
| ellipsis.go:8:5:8:5 | 1 | 1 | 1, 1 |
36+
| ellipsis.go:8:8:8:8 | 2 | 2 | 2, 2 |
37+
| ellipsis.go:9:5:9:5 | 1 | 1 | 1, 1 |
38+
| ellipsis.go:9:8:9:8 | 2 | 2 | 2, 2 |
39+
| ellipsis.go:9:11:9:11 | 3 | 3 | 3, 3 |
40+
| ellipsis.go:10:5:10:5 | 1 | 1 | 1, 1 |
41+
| ellipsis.go:10:14:10:14 | 2 | 2 | 2, 2 |
42+
| ellipsis.go:10:17:10:17 | 3 | 3 | 3, 3 |

0 commit comments

Comments
 (0)