-
Notifications
You must be signed in to change notification settings - Fork 327
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Do not artificially restrict the set of supported languages #779
Draft
esbena
wants to merge
3
commits into
main
Choose a base branch
from
esbena/no-lang
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 2 commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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 |
---|---|---|
|
@@ -9,7 +9,7 @@ import * as sinon from "sinon"; | |
import * as api from "./api-client"; | ||
import { getCachedCodeQL, setCodeQL } from "./codeql"; | ||
import * as configUtils from "./config-utils"; | ||
import { Language } from "./languages"; | ||
import { KnownLanguage, Language } from "./languages"; | ||
import { getRunnerLogger } from "./logging"; | ||
import { setupTests } from "./testing-utils"; | ||
import * as util from "./util"; | ||
|
@@ -299,7 +299,7 @@ test("load non-empty input", async (t) => { | |
|
||
// And the config we expect it to parse to | ||
const expectedConfig: configUtils.Config = { | ||
languages: [Language.javascript], | ||
languages: [KnownLanguage.javascript], | ||
queries: { | ||
javascript: { | ||
builtin: [], | ||
|
@@ -998,7 +998,7 @@ test("Unknown languages", async (t) => { | |
} catch (err) { | ||
t.deepEqual( | ||
err, | ||
new Error(configUtils.getUnknownLanguagesError(["rubbish", "english"])) | ||
new Error(configUtils.getUnsupportedLanguagesError(["rubbish", "english"])) | ||
); | ||
} | ||
}); | ||
|
@@ -1044,7 +1044,7 @@ test("Config specifies packages", async (t) => { | |
getRunnerLogger(true) | ||
); | ||
t.deepEqual(packs as unknown, { | ||
[Language.javascript]: [ | ||
[KnownLanguage.javascript]: [ | ||
{ | ||
packName: "a/b", | ||
version: clean("1.2.3"), | ||
|
@@ -1102,13 +1102,13 @@ test("Config specifies packages for multiple languages", async (t) => { | |
getRunnerLogger(true) | ||
); | ||
t.deepEqual(packs as unknown, { | ||
[Language.javascript]: [ | ||
[KnownLanguage.javascript]: [ | ||
{ | ||
packName: "a/b", | ||
version: clean("1.2.3"), | ||
}, | ||
], | ||
[Language.python]: [ | ||
[KnownLanguage.python]: [ | ||
{ | ||
packName: "c/d", | ||
version: clean("1.2.3"), | ||
|
@@ -1377,8 +1377,8 @@ parsePacksErrorMacro.title = (providedTitle: string) => | |
function invalidPackNameMacro(t: ExecutionContext<unknown>, name: string) { | ||
parsePacksErrorMacro( | ||
t, | ||
{ [Language.cpp]: [name] }, | ||
[Language.cpp], | ||
{ [KnownLanguage.cpp]: [name] }, | ||
[KnownLanguage.cpp], | ||
new RegExp( | ||
`The configuration file "/a/b" is invalid: property "packs" "${name}" is not a valid pack` | ||
) | ||
|
@@ -1388,8 +1388,8 @@ invalidPackNameMacro.title = (_: string, arg: string) => | |
`Invalid pack string: ${arg}`; | ||
|
||
test("no packs", parsePacksMacro, {}, [], {}); | ||
test("two packs", parsePacksMacro, ["a/b", "c/[email protected]"], [Language.cpp], { | ||
[Language.cpp]: [ | ||
test("two packs", parsePacksMacro, ["a/b", "c/[email protected]"], [KnownLanguage.cpp], { | ||
[KnownLanguage.cpp]: [ | ||
{ packName: "a/b", version: undefined }, | ||
{ packName: "c/d", version: clean("1.2.3") }, | ||
], | ||
|
@@ -1398,9 +1398,9 @@ test( | |
"two packs with spaces", | ||
parsePacksMacro, | ||
[" a/b ", " c/[email protected] "], | ||
[Language.cpp], | ||
[KnownLanguage.cpp], | ||
{ | ||
[Language.cpp]: [ | ||
[KnownLanguage.cpp]: [ | ||
{ packName: "a/b", version: undefined }, | ||
{ packName: "c/d", version: clean("1.2.3") }, | ||
], | ||
|
@@ -1410,16 +1410,16 @@ test( | |
"two packs with language", | ||
parsePacksMacro, | ||
{ | ||
[Language.cpp]: ["a/b", "c/[email protected]"], | ||
[Language.java]: ["d/e", "f/[email protected]"], | ||
[KnownLanguage.cpp]: ["a/b", "c/[email protected]"], | ||
[KnownLanguage.java]: ["d/e", "f/[email protected]"], | ||
}, | ||
[Language.cpp, Language.java, Language.csharp], | ||
[KnownLanguage.cpp, KnownLanguage.java, KnownLanguage.csharp], | ||
{ | ||
[Language.cpp]: [ | ||
[KnownLanguage.cpp]: [ | ||
{ packName: "a/b", version: undefined }, | ||
{ packName: "c/d", version: clean("1.2.3") }, | ||
], | ||
[Language.java]: [ | ||
[KnownLanguage.java]: [ | ||
{ packName: "d/e", version: undefined }, | ||
{ packName: "f/g", version: clean("1.2.3") }, | ||
], | ||
|
@@ -1430,21 +1430,21 @@ test( | |
"no language", | ||
parsePacksErrorMacro, | ||
["a/[email protected]"], | ||
[Language.java, Language.python], | ||
[KnownLanguage.java, KnownLanguage.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], | ||
{ [KnownLanguage.java]: ["c/d"] }, | ||
[KnownLanguage.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, | ||
{ [Language.cpp]: "c/d" }, | ||
[Language.cpp], | ||
{ [KnownLanguage.cpp]: "c/d" }, | ||
[KnownLanguage.cpp], | ||
/The configuration file "\/a\/b" is invalid: property "packs" must be an array of non-empty strings/ | ||
); | ||
|
||
|
@@ -1496,18 +1496,18 @@ function parseInputAndConfigErrorMacro( | |
parseInputAndConfigErrorMacro.title = (providedTitle: string) => | ||
`Parse Packs input and config Error: ${providedTitle}`; | ||
|
||
test("input only", parseInputAndConfigMacro, {}, " c/d ", [Language.cpp], { | ||
[Language.cpp]: [{ packName: "c/d", version: undefined }], | ||
test("input only", parseInputAndConfigMacro, {}, " c/d ", [KnownLanguage.cpp], { | ||
[KnownLanguage.cpp]: [{ packName: "c/d", version: undefined }], | ||
}); | ||
|
||
test( | ||
"input only with multiple", | ||
parseInputAndConfigMacro, | ||
{}, | ||
"a/b , c/[email protected]", | ||
[Language.cpp], | ||
[KnownLanguage.cpp], | ||
{ | ||
[Language.cpp]: [ | ||
[KnownLanguage.cpp]: [ | ||
{ packName: "a/b", version: undefined }, | ||
{ packName: "c/d", version: "1.2.3" }, | ||
], | ||
|
@@ -1519,9 +1519,9 @@ test( | |
parseInputAndConfigMacro, | ||
{}, | ||
" + a/b , c/[email protected] ", | ||
[Language.cpp], | ||
[KnownLanguage.cpp], | ||
{ | ||
[Language.cpp]: [ | ||
[KnownLanguage.cpp]: [ | ||
{ packName: "a/b", version: undefined }, | ||
{ packName: "c/d", version: "1.2.3" }, | ||
], | ||
|
@@ -1533,9 +1533,9 @@ test( | |
parseInputAndConfigMacro, | ||
["a/b", "c/d"], | ||
" ", | ||
[Language.cpp], | ||
[KnownLanguage.cpp], | ||
{ | ||
[Language.cpp]: [ | ||
[KnownLanguage.cpp]: [ | ||
{ packName: "a/b", version: undefined }, | ||
{ packName: "c/d", version: undefined }, | ||
], | ||
|
@@ -1547,9 +1547,9 @@ test( | |
parseInputAndConfigMacro, | ||
["a/b", "c/d"], | ||
" e/f, g/[email protected] ", | ||
[Language.cpp], | ||
[KnownLanguage.cpp], | ||
{ | ||
[Language.cpp]: [ | ||
[KnownLanguage.cpp]: [ | ||
{ packName: "e/f", version: undefined }, | ||
{ packName: "g/h", version: "1.2.3" }, | ||
], | ||
|
@@ -1561,9 +1561,9 @@ test( | |
parseInputAndConfigMacro, | ||
["a/b", "c/d"], | ||
" +e/f, g/[email protected] ", | ||
[Language.cpp], | ||
[KnownLanguage.cpp], | ||
{ | ||
[Language.cpp]: [ | ||
[KnownLanguage.cpp]: [ | ||
{ packName: "e/f", version: undefined }, | ||
{ packName: "g/h", version: "1.2.3" }, | ||
{ packName: "a/b", version: undefined }, | ||
|
@@ -1586,7 +1586,7 @@ test( | |
parseInputAndConfigErrorMacro, | ||
{}, | ||
"c/d", | ||
[Language.cpp, Language.csharp], | ||
[KnownLanguage.cpp, KnownLanguage.csharp], | ||
/multi-language analysis/ | ||
); | ||
|
||
|
@@ -1595,7 +1595,7 @@ test( | |
parseInputAndConfigErrorMacro, | ||
{}, | ||
" + ", | ||
[Language.cpp], | ||
[KnownLanguage.cpp], | ||
/remove the '\+'/ | ||
); | ||
|
||
|
@@ -1604,7 +1604,7 @@ test( | |
parseInputAndConfigErrorMacro, | ||
{}, | ||
" xxx", | ||
[Language.cpp], | ||
[KnownLanguage.cpp], | ||
/"xxx" is not a valid pack/ | ||
); | ||
|
||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should have a new unit test here for a language is not a known language, but it is valid since it was returned by a mocked call to
codeql resolve languages
.