-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathrun-tests.ps1
More file actions
57 lines (50 loc) · 1.41 KB
/
run-tests.ps1
File metadata and controls
57 lines (50 loc) · 1.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
param(
[string]$TestsDir = "ql/test"
)
$ErrorActionPreference = "Stop"
# Check for CodeQL binary
if (Get-Command "codeql" -ErrorAction SilentlyContinue) {
$CODEQL_BINARY = "codeql"
}
elseif (Get-Command "gh" -ErrorAction SilentlyContinue) {
try {
gh codeql version 2>&1 | Out-Null
$CODEQL_BINARY = "gh codeql"
}
catch {
Write-Host "Installing gh-codeql extension..."
gh extension install github/gh-codeql
$CODEQL_BINARY = "gh codeql"
}
}
else {
Write-Error "Neither 'codeql' nor 'gh' command found"
exit 1
}
Write-Host "Installing ql/test pack dependencies..."
if ($CODEQL_BINARY -eq "gh codeql") {
gh codeql pack install ql/test
}
else {
codeql pack install ql/test
}
Write-Host "Running tests in $TestsDir"
if ($CODEQL_BINARY -eq "gh codeql") {
gh codeql test run `
-j 0 `
--check-databases --check-unused-labels --check-repeated-labels --check-redefined-labels --check-use-before-definition `
--search-path ./extractor-pack `
"$TestsDir"
}
else {
codeql test run `
-j 0 `
--check-databases --check-unused-labels --check-repeated-labels --check-redefined-labels --check-use-before-definition `
--search-path ./extractor-pack `
"$TestsDir"
}
if ($LASTEXITCODE -ne 0) {
Write-Error "Tests failed with exit code $LASTEXITCODE"
exit $LASTEXITCODE
}
Write-Host "All tests passed!"