Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion .github/workflows/python-tooling.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ on:
paths:
- "misc/bazel/**"
- "misc/codegen/**"
- "misc/just/**"
- "misc/scripts/models-as-data/*.py"
- "*.bazel*"
- .github/workflows/codegen.yml
- .github/workflows/python-tooling.yml
- .pre-commit-config.yaml
branches:
- main
Expand All @@ -33,3 +34,7 @@ jobs:
shell: bash
run: |
bazel test //misc/codegen/...
- name: Run just tooling tests
shell: bash
run: |
bazel test //misc/just/...
Comment on lines +37 to +40
9 changes: 9 additions & 0 deletions actions/justfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import '../lib.just'

[group('build')]
build: (_build_dist "actions")

roots := [source_dir() / 'ql/test']

[group('test')]
language-tests *EXTRA_ARGS: (_language_tests (roots ++ EXTRA_ARGS))
8 changes: 8 additions & 0 deletions actions/ql/integration-tests/justfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import "../../../lib.just"

# Integration tests are slow and need an internal checkout, so they only run when
# asked for by name.
explicit_verbs := ['test']

[no-cd]
test *ARGS=".": (_integration_test ARGS)
6 changes: 6 additions & 0 deletions actions/ql/justfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import "../../lib.just"

[no-cd]
format *ARGS=".": (_format_ql ARGS)

consistency_queries := ""
11 changes: 11 additions & 0 deletions actions/ql/test/justfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import "../justfile"

# A whole language test suite is slow, so it only runs when asked for by name.
explicit_verbs := ['test']

base_flags := []

all_checks := default_db_checks

[no-cd]
test *ARGS=".": (_codeql_test "actions" (base_flags ++ prepend('--extra-check=', all_checks) ++ ARGS))
10 changes: 10 additions & 0 deletions cpp/justfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import '../lib.just'
import? '../../buildutils-internal/just/cpp-coding-standards.just'

[group('build')]
build: (_build_dist "cpp")

roots := [source_dir() / 'ql/test', SEMMLE_CODE / 'semmlecode-cpp-tests']

[group('test')]
language-tests *EXTRA_ARGS: (_language_tests (roots ++ EXTRA_ARGS))
9 changes: 9 additions & 0 deletions cpp/ql/consistency-queries/badLocations.ql
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import cpp

// Locations should either be :0:0:0:0 locations (UnknownLocation, or
// a whole file), or all 4 fields should be positive.
from Location l
where
[l.getStartLine(), l.getEndLine(), l.getStartColumn(), l.getEndColumn()] != 0 and
[l.getStartLine(), l.getEndLine(), l.getStartColumn(), l.getEndColumn()] < 1
select l
5 changes: 5 additions & 0 deletions cpp/ql/consistency-queries/nullInToString.ql
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import cpp

from Element e
where e.toString().matches("%(null)%")
select e
6 changes: 6 additions & 0 deletions cpp/ql/consistency-queries/qlpack.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
name: codeql/cpp-consistency-queries
groups: [cpp, test, consistency-queries]
dependencies:
codeql/cpp-all: ${workspace}
extractor: cpp
warnOnImplicitThis: true
10 changes: 10 additions & 0 deletions cpp/ql/consistency-queries/unusedLocations.ql
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import cpp

from Location l
where
not any(Element e).getLocation() = l and
not any(LambdaCapture lc).getLocation() = l and
not any(MacroAccess ma).getActualLocation() = l and
not any(NamespaceDeclarationEntry nde).getBodyLocation() = l and
not any(XmlLocatable xml).getLocation() = l
select l
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import cpp

from VariableDeclarationEntry i
where not exists(i.getType())
select i
5 changes: 5 additions & 0 deletions cpp/ql/consistency-queries/variablesWithoutTypes.ql
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import cpp

from Variable i
where not exists(i.getType())
select i
8 changes: 8 additions & 0 deletions cpp/ql/integration-tests/justfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import "../../../lib.just"

# Integration tests are slow and need an internal checkout, so they only run when
# asked for by name.
explicit_verbs := ['test']

[no-cd]
test *ARGS=".": (_integration_test ARGS)
6 changes: 6 additions & 0 deletions cpp/ql/justfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import "../../lib.just"

[no-cd]
format *ARGS=".": (_format_ql ARGS)

consistency_queries := source_dir() / "consistency-queries"
11 changes: 11 additions & 0 deletions cpp/ql/test/justfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import "../justfile"

# A whole language test suite is slow, so it only runs when asked for by name.
explicit_verbs := ['test']

base_flags := ['--include-location-in-star']

all_checks := default_db_checks ++ ['--check-undefined-labels', '--check-unused-labels', '--consistency-queries=' + consistency_queries]

[no-cd]
test *ARGS=".": (_codeql_test "cpp" (base_flags ++ prepend('--extra-check=', all_checks) ++ ARGS))
9 changes: 9 additions & 0 deletions csharp/justfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import '../lib.just'

[group('build')]
build: (_build_dist "csharp")

roots := [source_dir() / 'ql/test']

[group('test')]
language-tests *EXTRA_ARGS: (_language_tests (roots ++ EXTRA_ARGS))
8 changes: 8 additions & 0 deletions csharp/ql/integration-tests/justfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import "../../../lib.just"

# Integration tests are slow and need an internal checkout, so they only run when
# asked for by name.
explicit_verbs := ['test']

[no-cd]
test *ARGS=".": (_integration_test ARGS)
6 changes: 6 additions & 0 deletions csharp/ql/justfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import "../../lib.just"

[no-cd]
format *ARGS=".": (_format_ql ARGS)

consistency_queries := source_dir() / "consistency-queries"
11 changes: 11 additions & 0 deletions csharp/ql/test/justfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import "../justfile"

# A whole language test suite is slow, so it only runs when asked for by name.
explicit_verbs := ['test']

base_flags := []

all_checks := default_db_checks ++ ['--check-undefined-labels', '--check-repeated-labels', '--check-redefined-labels', '--additional-packs=ql', '--consistency-queries=' + consistency_queries]

[no-cd]
test *ARGS=".": (_codeql_test "csharp" (base_flags ++ prepend('--extra-check=', all_checks) ++ ARGS))
17 changes: 17 additions & 0 deletions go/justfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import '../lib.just'

[group('build')]
build: (_build_dist "go")

roots := [source_dir() / 'ql/test']

# The `IncorrectIntegerConversion` query treats `math.MaxInt`/`math.MaxUint` differently on 32- and
# 64-bit targets, so we run its test under `GOARCH=386` as well. `GOOS=linux` because
# `GOOS=darwin GOARCH=386` is no longer supported.
roots_386 := [source_dir() / 'ql/test/query-tests/Security/CWE-681/IncorrectIntegerConversion.qlref']

[group('test')]
language-tests *EXTRA_ARGS: (_language_tests (roots ++ EXTRA_ARGS))

[group('test')]
language-tests-386 *EXTRA_ARGS: (_language_tests (roots_386 ++ ['GOOS=linux', 'GOARCH=386'] ++ EXTRA_ARGS))
8 changes: 8 additions & 0 deletions go/ql/integration-tests/justfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import "../../../lib.just"

# Integration tests are slow and need an internal checkout, so they only run when
# asked for by name.
explicit_verbs := ['test']

[no-cd]
test *ARGS=".": (_integration_test ARGS)
6 changes: 6 additions & 0 deletions go/ql/justfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import "../../lib.just"

[no-cd]
format *ARGS=".": (_format_ql ARGS)

consistency_queries := source_dir() / "consistency-queries"
11 changes: 11 additions & 0 deletions go/ql/test/justfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import "../justfile"

# A whole language test suite is slow, so it only runs when asked for by name.
explicit_verbs := ['test']

base_flags := []

all_checks := default_db_checks ++ ['--check-undefined-labels', '--check-unused-labels', '--check-repeated-labels', '--check-redefined-labels', '--check-use-before-definition', '--consistency-queries=' + consistency_queries]

[no-cd]
test *ARGS=".": (_codeql_test "go" (base_flags ++ prepend('--extra-check=', all_checks) ++ ARGS))
4 changes: 4 additions & 0 deletions java/justfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import '../lib.just'

[group('build')]
build: (_build_dist "java")
8 changes: 8 additions & 0 deletions java/ql/integration-tests/justfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import "../../../lib.just"

# Integration tests are slow and need an internal checkout, so they only run when
# asked for by name.
explicit_verbs := ['test']

[no-cd]
test *ARGS=".": (_integration_test ARGS)
6 changes: 6 additions & 0 deletions java/ql/justfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import "../../lib.just"

[no-cd]
format *ARGS=".": (_format_ql ARGS)

consistency_queries := source_dir() / "consistency-queries"
14 changes: 14 additions & 0 deletions java/ql/test-kotlin1/justfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import "../justfile"

# These are CI shards of the Kotlin language tests, too long to run by accident,
# so a verb coming from above passes over them and they run only when this
# directory is named.
explicit_verbs := ['test']

# Kotlin tests may fail the diags.ql consistency test if the diagnostic limit is set.
base_flags := ['CODEQL_EXTRACTOR_KOTLIN_DIAGNOSTIC_LIMIT=']

all_checks := default_db_checks ++ ['--check-undefined-labels', '--check-repeated-labels', '--check-redefined-labels', '--check-use-before-definition', '--consistency-queries=' + consistency_queries]

[no-cd]
test *ARGS=".": (_codeql_test "java" (base_flags ++ prepend('--extra-check=', all_checks) ++ ARGS))
14 changes: 14 additions & 0 deletions java/ql/test-kotlin2/justfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import "../justfile"

# These are CI shards of the Kotlin language tests, too long to run by accident,
# so a verb coming from above passes over them and they run only when this
# directory is named.
explicit_verbs := ['test']

# Kotlin tests may fail the diags.ql consistency test if the diagnostic limit is set.
base_flags := ['CODEQL_EXTRACTOR_KOTLIN_DIAGNOSTIC_LIMIT=', 'CODEQL_KOTLIN_LEGACY_TEST_EXTRACTION_KOTLIN2=true']

all_checks := default_db_checks ++ ['--check-undefined-labels', '--check-repeated-labels', '--check-redefined-labels', '--check-use-before-definition', '--consistency-queries=' + consistency_queries]

[no-cd]
test *ARGS=".": (_codeql_test "java" (base_flags ++ prepend('--extra-check=', all_checks) ++ ARGS))
12 changes: 12 additions & 0 deletions java/ql/test/justfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import "../justfile"

# A whole language test suite is slow, so it only runs when asked for by name.
explicit_verbs := ['test']

# Kotlin tests may fail the diags.ql consistency test if the diagnostic limit is set.
base_flags := ['CODEQL_EXTRACTOR_KOTLIN_DIAGNOSTIC_LIMIT=']

all_checks := default_db_checks ++ ['--check-undefined-labels', '--check-repeated-labels', '--check-redefined-labels', '--check-use-before-definition', '--consistency-queries=' + consistency_queries]

[no-cd]
test *ARGS=".": (_codeql_test "java" (base_flags ++ prepend('--extra-check=', all_checks) ++ ARGS))
9 changes: 9 additions & 0 deletions javascript/justfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import '../lib.just'

[group('build')]
build: (_build_dist "javascript")

roots := [source_dir() / 'ql/test']

[group('test')]
language-tests *EXTRA_ARGS: (_language_tests (roots ++ EXTRA_ARGS))
8 changes: 8 additions & 0 deletions javascript/ql/integration-tests/justfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import "../../../lib.just"

# Integration tests are slow and need an internal checkout, so they only run when
# asked for by name.
explicit_verbs := ['test']

[no-cd]
test *ARGS=".": (_integration_test ARGS)
6 changes: 6 additions & 0 deletions javascript/ql/justfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import "../../lib.just"

[no-cd]
format *ARGS=".": (_format_ql ARGS)

consistency_queries := ""
11 changes: 11 additions & 0 deletions javascript/ql/test/justfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import "../justfile"

# A whole language test suite is slow, so it only runs when asked for by name.
explicit_verbs := ['test']

base_flags := []

all_checks := default_db_checks

[no-cd]
test *ARGS=".": (_codeql_test "javascript" (base_flags ++ prepend('--extra-check=', all_checks) ++ ARGS))
9 changes: 9 additions & 0 deletions justfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# see misc/just/README.md for an overview

import 'lib.just'
import 'misc/just/forward.just'

# bazel files live all over the repository rather than under any one language, so they
# are formatted from here. `format` itself is the forwarder, hence `_root_`; see
# misc/just/README.md.
_root_format *ARGS=".": (_format_bazel ARGS)
1 change: 1 addition & 0 deletions lib.just
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import "misc/just/lib.just"
5 changes: 5 additions & 0 deletions misc/codegen/justfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import "../just/lib.just"

test *ARGS: (_bazel (['test', '@codeql//misc/codegen/...'] ++ ARGS))

format *ARGS=".": (_format_py ARGS)
27 changes: 27 additions & 0 deletions misc/just/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
load("@rules_python//python:defs.bzl", "py_library", "py_test")

py_library(
name = "tooling",
srcs = [
"codeql_test_run.py",
"forward_command.py",
"language_tests.py",
"run_on_files.py",
],
imports = ["."],
visibility = ["//visibility:public"],
)

[
py_test(
name = src[:-len(".py")],
size = "small",
srcs = [src],
deps = [":tooling"],
)
for src in glob(["test_*.py"])
]

test_suite(
name = "test",
)
Loading
Loading