-
Notifications
You must be signed in to change notification settings - Fork 329
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow scans with packs for languages not being scanned
Previously, we were being too strict about checking that a pack's language was being scanned. It was a failure if a pack language was specified for a language not being scanned.
- Loading branch information
1 parent
2e0c6ca
commit 4e14024
Showing
6 changed files
with
89 additions
and
37 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,7 +10,7 @@ import { getCachedCodeQL, setCodeQL } from "./codeql"; | |
import * as configUtils from "./config-utils"; | ||
import { createFeatureFlags, FeatureFlag } from "./feature-flags"; | ||
import { Language } from "./languages"; | ||
import { getRunnerLogger } from "./logging"; | ||
import { getRunnerLogger, Logger } from "./logging"; | ||
import { setupTests } from "./testing-utils"; | ||
import * as util from "./util"; | ||
|
||
|
@@ -1424,7 +1424,12 @@ const parsePacksMacro = test.macro({ | |
expected: Partial<Record<Language, string[]>> | ||
) => | ||
t.deepEqual( | ||
configUtils.parsePacksFromConfig(packsByLanguage, languages, "/a/b"), | ||
configUtils.parsePacksFromConfig( | ||
packsByLanguage, | ||
languages, | ||
"/a/b", | ||
mockLogger | ||
), | ||
expected | ||
), | ||
|
||
|
@@ -1446,7 +1451,8 @@ const parsePacksErrorMacro = test.macro({ | |
configUtils.parsePacksFromConfig( | ||
packsByLanguage as string[] | Record<string, string[]>, | ||
languages, | ||
"/a/b" | ||
"/a/b", | ||
{} as Logger | ||
), | ||
{ | ||
message: expected, | ||
|
@@ -1499,6 +1505,19 @@ test( | |
} | ||
); | ||
|
||
test( | ||
"two packs with unused language in config", | ||
parsePacksMacro, | ||
{ | ||
[Language.cpp]: ["a/b", "c/[email protected]"], | ||
[Language.java]: ["d/e", "f/[email protected]"], | ||
}, | ||
[Language.cpp, Language.csharp], | ||
{ | ||
[Language.cpp]: ["a/b", "c/[email protected]"], | ||
} | ||
); | ||
|
||
test( | ||
"packs with other valid names", | ||
parsePacksMacro, | ||
|
@@ -1544,13 +1563,6 @@ test( | |
[Language.java, Language.python], | ||
/The configuration file "\/a\/b" is invalid: property "packs" must split packages by language/ | ||
); | ||
test( | ||
"invalid language", | ||
parsePacksErrorMacro, | ||
{ [Language.java]: ["c/d"] }, | ||
[Language.cpp], | ||
/The configuration file "\/a\/b" is invalid: property "packs" has "java", but it is not one of the languages to analyze/ | ||
); | ||
test( | ||
"not an array", | ||
parsePacksErrorMacro, | ||
|
@@ -1583,13 +1595,25 @@ function parseInputAndConfigMacro( | |
expected | ||
) { | ||
t.deepEqual( | ||
configUtils.parsePacks(packsFromConfig, packsFromInput, languages, "/a/b"), | ||
configUtils.parsePacks( | ||
packsFromConfig, | ||
packsFromInput, | ||
languages, | ||
"/a/b", | ||
mockLogger | ||
), | ||
expected | ||
); | ||
} | ||
parseInputAndConfigMacro.title = (providedTitle: string) => | ||
`Parse Packs input and config: ${providedTitle}`; | ||
|
||
const mockLogger = { | ||
info: (message: string) => { | ||
console.log(message); | ||
}, | ||
} as Logger; | ||
|
||
function parseInputAndConfigErrorMacro( | ||
t: ExecutionContext<unknown>, | ||
packsFromConfig: string[] | Record<string, string[]>, | ||
|
@@ -1603,7 +1627,8 @@ function parseInputAndConfigErrorMacro( | |
packsFromConfig, | ||
packsFromInput, | ||
languages, | ||
"/a/b" | ||
"/a/b", | ||
mockLogger | ||
); | ||
}, | ||
{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters