Skip to content

Commit f5ff822

Browse files
committed
Convert extract-tests option to an official extractor option
1 parent 94cb99e commit f5ff822

File tree

4 files changed

+11
-4
lines changed

4 files changed

+11
-4
lines changed

go/codeql-extractor.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,11 @@ file_types:
1919
extensions:
2020
- .go
2121
legacy_qltest_extraction: true
22+
options:
23+
extract_tests:
24+
title: Whether to include Go test files and functions in the CodeQL database.
25+
description: >
26+
A value indicating whether Go test files and functions should be included in the CodeQL database.
27+
The default is 'false'.
28+
type: string
29+
pattern: "^(false|true)$"

go/extractor/cli/go-extractor/go-extractor.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ func parseFlags(args []string, mimic bool, extractTests bool) ([]string, []strin
9494
}
9595

9696
func main() {
97-
extractTestsDefault := os.Getenv("CODEQL_EXTRACTOR_GO_EXTRACT_TESTS") == "true"
97+
extractTestsDefault := os.Getenv("CODEQL_EXTRACTOR_GO_OPTION_EXTRACT_TESTS") == "true"
9898
buildFlags, patterns, extractTests := parseFlags(os.Args[1:], false, extractTestsDefault)
9999

100100
if cpuprofile != "" {

go/extractor/extractor.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ func ExtractWithFlags(buildFlags []string, patterns []string, extractTests bool)
8888
log.Printf("Running packages.Load%s.", testMessage)
8989

9090
// This includes test packages if either we're tracing a `go test` command,
91-
// or if CODEQL_EXTRACTOR_GO_EXTRACT_TESTS is set to "true".
91+
// or if CODEQL_EXTRACTOR_GO_OPTION_EXTRACT_TESTS is set to "true".
9292
cfg := &packages.Config{
9393
Mode: packages.NeedName | packages.NeedFiles |
9494
packages.NeedCompiledGoFiles |
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import os
22

33
def test(codeql, go):
4-
os.environ["CODEQL_EXTRACTOR_GO_EXTRACT_TESTS"] = "true"
5-
codeql.database.create(source_root="src")
4+
codeql.database.create(source_root="src", extractor_option = ["extract_tests=true"])

0 commit comments

Comments
 (0)