Skip to content

Commit dea9229

Browse files
authored
Merge pull request #16034 from github/redsun82/swift-move-integration-tests-to-internal
Swift: prepare integration tests for internal running
2 parents 55226c4 + 9c9f4b9 commit dea9229

File tree

169 files changed

+27
-29
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

169 files changed

+27
-29
lines changed

codeql-workspace.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ provide:
2828
- "misc/suite-helpers/qlpack.yml"
2929
- "ruby/extractor-pack/codeql-extractor.yml"
3030
- "swift/extractor-pack/codeql-extractor.yml"
31-
- "swift/integration-tests/qlpack.yml"
3231
- "ql/extractor-pack/codeql-extractor.yml"
3332
- ".github/codeql/extensions/**/codeql-pack.yml"
3433

swift/.python-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.8.14
1+
3.11

swift/actions/run-integration-tests/action.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ runs:
1818
- name: Run integration tests
1919
shell: bash
2020
run: |
21-
python swift/integration-tests/runner.py --compilation-cache "${{ steps.query-cache.outputs.cache-dir }}"
21+
python swift/ql/integration-tests/runner.py --compilation-cache "${{ steps.query-cache.outputs.cache-dir }}"
2222
env:
2323
SEMMLE_DEBUG_TRACER: 10000
2424
- name: Upload test logs
@@ -27,5 +27,5 @@ runs:
2727
with:
2828
name: swift-integration-tests-logs-${{ runner.os }}
2929
path: |
30-
swift/integration-tests/**/db/log
30+
swift/ql/integration-tests/**/db/log
3131
retention-days: 1

swift/integration-tests/posix-only/deduplication/Relevant.qll

Lines changed: 0 additions & 5 deletions
This file was deleted.

swift/integration-tests/qlpack.yml

Lines changed: 0 additions & 7 deletions
This file was deleted.

swift/logging/tests/assertion-diagnostics/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,5 @@ py_test(
1717
"diagnostics.expected",
1818
":assert-false",
1919
],
20-
deps = ["//swift/integration-tests:integration_tests"],
20+
deps = ["//swift/ql/integration-tests:utils"],
2121
)

swift/logging/tests/assertion-diagnostics/test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import os
33
import subprocess
44
# We have to use importlib due to the '-' in the path
5-
diagnostics_test_utils = importlib.import_module("swift.integration-tests.diagnostics_test_utils")
5+
diagnostics_test_utils = importlib.import_module("swift.ql.integration-tests.diagnostics_test_utils")
66

77
test_dir = "swift/logging/tests/assertion-diagnostics"
88

swift/integration-tests/.gitignore renamed to swift/ql/integration-tests/.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ xcuserdata/
66
DerivedData/
77
.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata
88
*.actual
9-
db
9+
test-db
1010
*.swiftmodule

swift/integration-tests/BUILD.bazel renamed to swift/ql/integration-tests/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
py_library(
2-
name = "integration_tests",
2+
name = "utils",
33
srcs = [
44
"create_database_utils.py",
55
"diagnostics_test_utils.py",

swift/integration-tests/create_database_utils.py renamed to swift/ql/integration-tests/create_database_utils.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ def runUnsuccessfully(cmd):
2727
def run_codeql_database_create(cmds, lang, keep_trap=True, db=None, runFunction=runSuccessfully):
2828
""" db parameter is here solely for compatibility with the internal test runner """
2929
assert lang == 'swift'
30-
codeql_root = pathlib.Path(__file__).parents[2]
31-
shutil.rmtree("db", ignore_errors=True)
30+
codeql_root = pathlib.Path(__file__).parents[3]
31+
shutil.rmtree("test-db", ignore_errors=True)
3232
cmd = [
3333
"codeql", "database", "create",
3434
"-s", ".", "-l", "swift", f"--search-path={codeql_root}", "--no-cleanup",
@@ -37,5 +37,5 @@ def run_codeql_database_create(cmds, lang, keep_trap=True, db=None, runFunction=
3737
cmd.append("--keep-trap")
3838
for c in cmds:
3939
cmd += ["-c", c]
40-
cmd.append("db")
40+
cmd.append("test-db")
4141
runFunction(cmd)

swift/integration-tests/diagnostics_test_utils.py renamed to swift/ql/integration-tests/diagnostics_test_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def _normalize_json(data):
5050
return "\n".join(entries)
5151

5252

53-
def check_diagnostics(test_dir=".", test_db="db", actual = None):
53+
def check_diagnostics(test_dir=".", test_db="test-db", actual = None):
5454
test_dir = pathlib.Path(test_dir)
5555
test_db = pathlib.Path(test_db)
5656
if actual is None:
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import swift
2+
3+
predicate relevant(Locatable loc) {
4+
loc.getLocation().getFile().getName().matches("%/swift/ql/integration-tests/%/Sources/%")
5+
}

swift/integration-tests/posix-only/frontend-invocations/test.py renamed to swift/ql/integration-tests/posix-only/frontend-invocations/test.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,16 @@
55

66
run_codeql_database_create([
77
'./build.sh',
8-
], lang='swift')
8+
], lang='swift',
9+
)
910

1011
with open('hashes.expected', 'w') as expected:
1112
for f in sorted(Path().glob("*.swiftmodule")):
1213
with open(f, 'rb') as module:
1314
print(f.name, sha256(module.read()).hexdigest(), file=expected)
1415

1516
with open('hashes.actual', 'w') as actual:
16-
hashes = [(s.name, s.resolve().name) for s in Path("db/working/swift-extraction-artifacts/store").iterdir()]
17+
hashes = [(s.name, s.resolve().name) for s in Path("test-db/working/swift-extraction-artifacts/store").iterdir()]
1718
hashes.sort()
1819
for module, hash in hashes:
1920
print(module, hash, file=actual)

swift/ql/integration-tests/qlpack.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
dependencies:
2+
codeql/swift-all: '*'
3+
codeql/swift-queries: '*'
4+
warnOnImplicitThis: true

swift/integration-tests/runner.py renamed to swift/ql/integration-tests/runner.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import platform
1818

1919
this_dir = pathlib.Path(__file__).parent.resolve()
20+
codeql_root = this_dir.parents[2]
2021

2122
def options():
2223
p = argparse.ArgumentParser()
@@ -30,7 +31,7 @@ def options():
3031

3132

3233
def execute_test(path):
33-
shutil.rmtree(path.parent / "db", ignore_errors=True)
34+
shutil.rmtree(path.parent / "test-db", ignore_errors=True)
3435
return subprocess.run([sys.executable, "-u", path.name], cwd=path.parent).returncode == 0
3536

3637
def skipped(test):
@@ -51,18 +52,18 @@ def main(opts):
5152
return False
5253

5354
os.environ["PYTHONPATH"] = str(this_dir)
55+
os.environ["CODEQL_CONFIG_FILE"] = "/dev/null"
5456
failed_db_creation = []
5557
succesful_db_creation = []
5658
for t in tests:
5759
(succesful_db_creation if execute_test(t) else failed_db_creation).append(t)
5860

5961
if succesful_db_creation:
60-
codeql_root = this_dir.parents[1]
6162
cmd = [
6263
"codeql", "test", "run",
6364
f"--additional-packs={codeql_root}",
6465
"--keep-databases",
65-
"--dataset=db/db-swift",
66+
"--dataset=test-db/db-swift",
6667
f"--threads={opts.threads}",
6768
]
6869
if opts.check_databases:

0 commit comments

Comments
 (0)