Skip to content

Commit

Permalink
Go: Add test for AliasType extraction
Browse files Browse the repository at this point in the history
  • Loading branch information
mbg committed Sep 3, 2024
1 parent 11aaf06 commit 7fca405
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 0 deletions.
14 changes: 14 additions & 0 deletions go/ql/test/library-tests/semmle/go/Types/Aliases.expected
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
| github.com/github/codeql-go/ql/test/library-tests/semmle/go/Types.FirstAlias | string | string |
| github.com/github/codeql-go/ql/test/library-tests/semmle/go/Types.SecondAlias | github.com/github/codeql-go/ql/test/library-tests/semmle/go/Types.FirstAlias | string |
| internal/reflectlite.Kind | internal/abi.Kind | uint |
| internal/reflectlite.nameOff | internal/abi.NameOff | int32 |
| internal/reflectlite.textOff | internal/abi.TextOff | int32 |
| internal/reflectlite.typeOff | internal/abi.TypeOff | int32 |
| os.FileMode | io/fs.FileMode | uint32 |
| os.syscallErrorType | syscall.Errno | uintptr |
| reflect.aNameOff | internal/abi.NameOff | int32 |
| reflect.aTextOff | internal/abi.TextOff | int32 |
| reflect.aTypeOff | internal/abi.TypeOff | int32 |
| runtime.nameOff | internal/abi.NameOff | int32 |
| runtime.textOff | internal/abi.TextOff | int32 |
| runtime.typeOff | internal/abi.TypeOff | int32 |
10 changes: 10 additions & 0 deletions go/ql/test/library-tests/semmle/go/Types/Aliases.ql
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import go

Check failure on line 1 in go/ql/test/library-tests/semmle/go/Types/Aliases.ql

View workflow job for this annotation

GitHub Actions / Test Linux (Ubuntu)

[511/529] FAILED(COMPILATION) /home/runner/work/codeql/codeql/go/ql/test/library-tests/semmle/go/Types/Aliases.ql

Check failure on line 1 in go/ql/test/library-tests/semmle/go/Types/Aliases.ql

View workflow job for this annotation

GitHub Actions / Test Windows

[393/529] FAILED(COMPILATION) C:\a\codeql\codeql\go\ql\test\library-tests\semmle\go\Types\Aliases.ql

Check failure on line 1 in go/ql/test/library-tests/semmle/go/Types/Aliases.ql

View workflow job for this annotation

GitHub Actions / Test MacOS

[275/529] FAILED(COMPILATION) /Users/runner/work/codeql/codeql/go/ql/test/library-tests/semmle/go/Types/Aliases.ql

string getQualifiedNameIfExists(Type t) {
if exists(t.getQualifiedName()) then result = t.getQualifiedName() else result = t.getName()
}

from AliasType at
where at.hasLocationInfo(_, _, _, _, _)
select getQualifiedNameIfExists(at), getQualifiedNameIfExists(at.getRhs()),
getQualifiedNameIfExists(at.getUnderlyingType())
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
| aliases.go:3:6:3:15 | FirstAlias | github.com/github/codeql-go/ql/test/library-tests/semmle/go/Types.FirstAlias |
| aliases.go:4:6:4:16 | SecondAlias | github.com/github/codeql-go/ql/test/library-tests/semmle/go/Types.SecondAlias |
| cyclic.go:3:6:3:6 | s | github.com/github/codeql-go/ql/test/library-tests/semmle/go/Types.s |
| cyclic.go:7:6:7:6 | t | github.com/github/codeql-go/ql/test/library-tests/semmle/go/Types.t |
| cyclic.go:12:6:12:6 | u | github.com/github/codeql-go/ql/test/library-tests/semmle/go/Types.u |
Expand Down Expand Up @@ -29,7 +31,9 @@
| generic.go:47:6:47:16 | MyInterface | github.com/github/codeql-go/ql/test/library-tests/semmle/go/Types.MyInterface |
| generic.go:67:6:67:22 | HasBlankTypeParam | github.com/github/codeql-go/ql/test/library-tests/semmle/go/Types.HasBlankTypeParam |
| generic.go:68:6:68:23 | HasBlankTypeParams | github.com/github/codeql-go/ql/test/library-tests/semmle/go/Types.HasBlankTypeParams |
| generic.go:82:6:82:14 | TypeAlias | github.com/github/codeql-go/ql/test/library-tests/semmle/go/Types.TypeAlias |
| generic.go:84:6:84:21 | GenericSignature | github.com/github/codeql-go/ql/test/library-tests/semmle/go/Types.GenericSignature |
| generic.go:85:6:85:26 | GenericSignatureAlias | github.com/github/codeql-go/ql/test/library-tests/semmle/go/Types.GenericSignatureAlias |
| interface.go:3:6:3:7 | i0 | github.com/github/codeql-go/ql/test/library-tests/semmle/go/Types.i0 |
| interface.go:5:6:5:7 | i1 | github.com/github/codeql-go/ql/test/library-tests/semmle/go/Types.i1 |
| interface.go:9:6:9:7 | i2 | github.com/github/codeql-go/ql/test/library-tests/semmle/go/Types.i2 |
Expand Down
4 changes: 4 additions & 0 deletions go/ql/test/library-tests/semmle/go/Types/Types.expected
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
| aliases.go:3:6:3:15 | FirstAlias | FirstAlias |
| aliases.go:4:6:4:16 | SecondAlias | SecondAlias |
| cyclic.go:3:6:3:6 | s | s |
| cyclic.go:7:6:7:6 | t | t |
| cyclic.go:12:6:12:6 | u | u |
Expand Down Expand Up @@ -29,7 +31,9 @@
| generic.go:47:6:47:16 | MyInterface | MyInterface |
| generic.go:67:6:67:22 | HasBlankTypeParam | HasBlankTypeParam |
| generic.go:68:6:68:23 | HasBlankTypeParams | HasBlankTypeParams |
| generic.go:82:6:82:14 | TypeAlias | TypeAlias |
| generic.go:84:6:84:21 | GenericSignature | GenericSignature |
| generic.go:85:6:85:26 | GenericSignatureAlias | GenericSignatureAlias |
| interface.go:3:6:3:7 | i0 | i0 |
| interface.go:5:6:5:7 | i1 | i1 |
| interface.go:9:6:9:7 | i2 | i2 |
Expand Down
4 changes: 4 additions & 0 deletions go/ql/test/library-tests/semmle/go/Types/aliases.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package main

type FirstAlias = string
type SecondAlias = FirstAlias

0 comments on commit 7fca405

Please sign in to comment.