Swift: prepare integration tests for internal running

This harmonizes Swift integration tests with the rest of the repository,
to prepare for the internal integration test runner to run them. The
stripped down runner is kept compatible, so that current CI can still
use it now. Maybe it will be kept for developer use.

This PR includes:
* moving the integration tests inside `ql`
* editing `qlpack.yml` so that the internal runner can use it
* change database directory to be `test-db` rather than `db`
This commit is contained in:
Paolo Tranquilli
2024-03-25 10:17:55 +01:00
parent 45ce988943
commit 762b4ce42e
164 changed files with 18 additions and 18 deletions

View File

@@ -0,0 +1,41 @@
"""
Simplified version of internal `create_database_utils.py` used to run the tests locally, with
minimal and swift-specialized functionality
TODO unify integration testing code across the public and private repositories
"""
import subprocess
import pathlib
import sys
import shutil
def runSuccessfully(cmd):
res = subprocess.run(cmd)
if res.returncode:
print("FAILED", file=sys.stderr)
print(" ", *cmd, f"(exit code {res.returncode})", file=sys.stderr)
sys.exit(res.returncode)
def runUnsuccessfully(cmd):
res = subprocess.run(cmd)
if res.returncode == 0:
print("FAILED", file=sys.stderr)
print(" ", *cmd, f"(exit code 0, expected to fail)", file=sys.stderr)
sys.exit(1)
def run_codeql_database_create(cmds, lang, keep_trap=True, db=None, runFunction=runSuccessfully):
""" db parameter is here solely for compatibility with the internal test runner """
assert lang == 'swift'
codeql_root = pathlib.Path(__file__).parents[3]
shutil.rmtree("test-db", ignore_errors=True)
cmd = [
"codeql", "database", "create",
"-s", ".", "-l", "swift", f"--search-path={codeql_root}", "--no-cleanup",
]
if keep_trap:
cmd.append("--keep-trap")
for c in cmds:
cmd += ["-c", c]
cmd.append("test-db")
runFunction(cmd)