Skip to content

Commit d3b6590

Browse files
redsun82Copilot
andcommitted
Just: port python to new language test definition
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent d358cf3 commit d3b6590

File tree

4 files changed

+64
-1
lines changed

4 files changed

+64
-1
lines changed

misc/just/language_tests.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,20 @@ def main():
2929
]
3030

3131
just = os.environ.get("JUST_EXECUTABLE", "just")
32+
33+
# Find the nearest justfile at or above the first root
34+
justfile_dir = Path(roots[0])
35+
while not (justfile_dir / "justfile").exists():
36+
parent = justfile_dir.parent
37+
if parent == justfile_dir:
38+
print(f"No justfile found above {roots[0]}", file=sys.stderr)
39+
return 1
40+
justfile_dir = parent
41+
3242
invocation = [
3343
just,
3444
"--justfile",
35-
str(Path(roots[0]) / "justfile"),
45+
str(justfile_dir / "justfile"),
3646
"test",
3747
"--all-checks",
3848
"--codeql=built",

python/justfile

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import '../lib.just'
2+
import 'ql/justfile'
3+
4+
[group('build')]
5+
build: (_build_dist "python")
6+
7+
# Long filename needed for extractor tests (too long for Git on Windows)
8+
[no-cd]
9+
@_ensure_long_filename:
10+
#!/usr/bin/env bash
11+
longfile="$SEMMLE_CODE/ql/python/ql/test/extractor-tests/long_path/really_rather_too_long_for_windows_path_length/with_unecessarily_longwinded_and_verbose_sub_folder/extremely_long_module_name_with_lots_of_digits_at_the_end_000000000000000000000000000000000000000000000000000000000000000000/test0000000000000000000000000000000000000000000000000000000.py"
12+
mkdir -p "$(dirname "$longfile")"
13+
touch "$longfile"
14+
15+
[group('test')]
16+
language-tests-2 *EXTRA_ARGS: _ensure_long_filename (_language_tests (
17+
_v2_env + ' ' + EXTRA_ARGS) source_dir()
18+
'ql/test/library-tests'
19+
'ql/test/query-tests'
20+
'ql/test/extractor-tests'
21+
'ql/test/experimental'
22+
'ql/test/2')
23+
24+
[group('test')]
25+
language-tests-3 *EXTRA_ARGS: _ensure_long_filename (_language_tests (
26+
_v3_env + ' ' + EXTRA_ARGS) source_dir()
27+
'ql/test/library-tests'
28+
'ql/test/query-tests'
29+
'ql/test/extractor-tests'
30+
'ql/test/experimental'
31+
'ql/test/modelling'
32+
'ql/test/3')

python/ql/justfile

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import "../../lib.just"
2+
3+
[no-cd]
4+
format *ARGS=".": (_format_ql ARGS)
5+
6+
consistency_queries := source_dir() / "consistency-queries"
7+
8+
python_version := "3"
9+
10+
_v2_env := "CODEQL_EXTRACTOR_PYTHON_ANALYSIS_VERSION=2 CODEQL_PYTHON_LEGACY_TEST_EXTRACTION_VERSION=2"
11+
_v3_env := "CODEQL_PYTHON_LEGACY_TEST_EXTRACTION_VERSION=3"
12+
_python_env := if python_version == "2" { _v2_env } else { _v3_env }

python/ql/test/justfile

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import "../justfile"
2+
3+
base_flags := _python_env
4+
5+
all_checks := default_db_checks + """\
6+
--consistency-queries=""" + consistency_queries
7+
8+
[no-cd]
9+
test *ARGS=".": (_codeql_test "python" base_flags all_checks ARGS)

0 commit comments

Comments
 (0)