mirror of
https://github.com/github/codeql.git
synced 2026-05-23 23:57:06 +02:00
Just: add language-tests.ts helper
This commit is contained in:
@@ -79,7 +79,7 @@ function codeqlTestRun(argv: string[]): number {
|
||||
}
|
||||
if (args.codeql === "build") {
|
||||
if (
|
||||
invoke(["python3", "build", `target/intree/codeql-${language}`], {
|
||||
invoke([process.env["JUST_EXECUTABLE"] || "just", language, "build"], {
|
||||
cwd: semmle_code,
|
||||
}) !== 0
|
||||
) {
|
||||
@@ -114,6 +114,10 @@ function codeqlTestRun(argv: string[]): number {
|
||||
`codeql-${language}`,
|
||||
"codeql",
|
||||
);
|
||||
if (!fs.existsSync(codeql)) {
|
||||
console.error(`CodeQL executable not found: ${codeql}`);
|
||||
return 1;
|
||||
}
|
||||
} else if (args.codeql === "host") {
|
||||
codeql = "codeql";
|
||||
} else {
|
||||
|
||||
@@ -7,7 +7,7 @@ function commonJustfile(paths: string[]): string {
|
||||
const splitPaths = paths.map((p) => p.split(path.sep));
|
||||
let justfile: string | undefined = undefined;
|
||||
for (let i = 0; i < splitPaths[0].length; i++) {
|
||||
let candidate = path.join(...splitPaths[0].slice(0, i), "justfile");
|
||||
let candidate = path.resolve(path.join(splitPaths[0].slice(0, i).join(path.sep), "justfile"));
|
||||
if (fs.existsSync(candidate)) {
|
||||
justfile = candidate;
|
||||
}
|
||||
@@ -57,7 +57,7 @@ function forwardCommand(args: string[]): number {
|
||||
...flags,
|
||||
...positionalArgs,
|
||||
];
|
||||
console.log(`-> ${justfile}: ${invocation.slice(1).join(" ")}`);
|
||||
console.log(`-> just ${invocation.slice(1).join(" ")}`);
|
||||
try {
|
||||
child_process.execFileSync(invocation[0], invocation.slice(1), {
|
||||
stdio: "inherit",
|
||||
|
||||
31
misc/just/language-tests.ts
Normal file
31
misc/just/language-tests.ts
Normal file
@@ -0,0 +1,31 @@
|
||||
import * as path from "path";
|
||||
import * as process from "process"
|
||||
import * as child_process from "child_process";
|
||||
|
||||
function languageTests(argv: string[]): number {
|
||||
const [extra_args, dir, ...relativeRoots] = argv;
|
||||
const semmle_code = process.env["SEMMLE_CODE"]!;
|
||||
let roots = relativeRoots.map((root) => path.relative(semmle_code, path.join(dir, root)));
|
||||
const invocation = [
|
||||
process.env["JUST_EXECUTABLE"] || "just",
|
||||
"--justfile",
|
||||
path.join(roots[0], "justfile"),
|
||||
"test",
|
||||
"--all-checks",
|
||||
"--codeql=built",
|
||||
...extra_args.split(" "),
|
||||
...roots,
|
||||
];
|
||||
console.log(`-> just ${invocation.slice(1).join(" ")}`);
|
||||
try {
|
||||
child_process.execFileSync(invocation[0], invocation.slice(1), {
|
||||
stdio: "inherit",
|
||||
cwd: semmle_code,
|
||||
});
|
||||
} catch (error) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
process.exit(languageTests(process.argv.slice(2)));
|
||||
@@ -39,9 +39,11 @@ default_db_checks := """\
|
||||
|
||||
[no-cd, positional-arguments, no-exit-message]
|
||||
@_codeql_test LANGUAGE BASE_FLAGS ALL_CHECKS_FLAGS EXTRA_ARGS:
|
||||
#$language-tests|{{ LANGUAGE }}|{{{{ BASE_FLAGS }}|{{ ALL_CHECKS_FLAGS }}
|
||||
{{ tsx }} "{{ source_dir() }}/codeql-test-run.ts" "$@"
|
||||
|
||||
[no-cd, positional-arguments, no-exit-message]
|
||||
@_language_tests EXTRA_ARGS SOURCE_DIR +ROOTS: _require_semmle_code
|
||||
{{ tsx }} "{{ source_dir() }}/language-tests.ts" "$@"
|
||||
|
||||
[no-cd, no-exit-message]
|
||||
_ql_format +ARGS: (_maybe_build "nolang")
|
||||
|
||||
Reference in New Issue
Block a user