mirror of
https://github.com/github/codeql.git
synced 2025-12-16 16:53:25 +01:00
Convert extract-tests option to an official extractor option
This commit is contained in:
@@ -19,3 +19,11 @@ file_types:
|
||||
extensions:
|
||||
- .go
|
||||
legacy_qltest_extraction: true
|
||||
options:
|
||||
extract_tests:
|
||||
title: Whether to include Go test files and functions in the CodeQL database.
|
||||
description: >
|
||||
A value indicating whether Go test files and functions should be included in the CodeQL database.
|
||||
The default is 'false'.
|
||||
type: string
|
||||
pattern: "^(false|true)$"
|
||||
|
||||
@@ -94,7 +94,7 @@ func parseFlags(args []string, mimic bool, extractTests bool) ([]string, []strin
|
||||
}
|
||||
|
||||
func main() {
|
||||
extractTestsDefault := os.Getenv("CODEQL_EXTRACTOR_GO_EXTRACT_TESTS") == "true"
|
||||
extractTestsDefault := os.Getenv("CODEQL_EXTRACTOR_GO_OPTION_EXTRACT_TESTS") == "true"
|
||||
buildFlags, patterns, extractTests := parseFlags(os.Args[1:], false, extractTestsDefault)
|
||||
|
||||
if cpuprofile != "" {
|
||||
|
||||
@@ -88,7 +88,7 @@ func ExtractWithFlags(buildFlags []string, patterns []string, extractTests bool)
|
||||
log.Printf("Running packages.Load%s.", testMessage)
|
||||
|
||||
// This includes test packages if either we're tracing a `go test` command,
|
||||
// or if CODEQL_EXTRACTOR_GO_EXTRACT_TESTS is set to "true".
|
||||
// or if CODEQL_EXTRACTOR_GO_OPTION_EXTRACT_TESTS is set to "true".
|
||||
cfg := &packages.Config{
|
||||
Mode: packages.NeedName | packages.NeedFiles |
|
||||
packages.NeedCompiledGoFiles |
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import os
|
||||
|
||||
def test(codeql, go):
|
||||
os.environ["CODEQL_EXTRACTOR_GO_EXTRACT_TESTS"] = "true"
|
||||
codeql.database.create(source_root="src")
|
||||
codeql.database.create(source_root="src", extractor_option = ["extract_tests=true"])
|
||||
|
||||
Reference in New Issue
Block a user