|
| 1 | +#!/usr/bin/env python3 |
| 2 | + |
| 3 | +import sys |
| 4 | +import argparse |
| 5 | +import pathlib |
| 6 | +import subprocess |
| 7 | +import os |
| 8 | +from build_support.actions import derive_options_from_args, REPO_ROOT, DownloadBaseSnapshotAction |
| 9 | + |
| 10 | + |
| 11 | +def main(): |
| 12 | + parser = argparse.ArgumentParser( |
| 13 | + description='Run e2e integration tests for Swift SDK') |
| 14 | + parser.add_argument('--swift-sdk', default='wasm32-unknown-wasi', |
| 15 | + help='Swift SDK identifier (default: wasm32-unknown-wasi)') |
| 16 | + parser.add_argument('args', nargs=argparse.REMAINDER, |
| 17 | + help='Extra arguments to pass to lit.py') |
| 18 | + options = derive_options_from_args(sys.argv[1:], parser) |
| 19 | + |
| 20 | + extra_lit_args = options.args |
| 21 | + if len(extra_lit_args) > 0 and extra_lit_args[0] == "--": |
| 22 | + extra_lit_args = extra_lit_args[1:] |
| 23 | + |
| 24 | + repo_path = pathlib.Path(REPO_ROOT) |
| 25 | + base_toolchain_path = DownloadBaseSnapshotAction.toolchain_path(options) |
| 26 | + lit_py_path = repo_path.parent / "llvm-project" / "llvm" / "utils" / "lit" / "lit.py" |
| 27 | + swift_sdks_path = repo_path.parent / "swift-sdk-generator" / "Bundles" |
| 28 | + |
| 29 | + # Build lit command |
| 30 | + lit_cmd = [ |
| 31 | + str(lit_py_path), |
| 32 | + "--param", f"swift-sdk={options.swift_sdk}", |
| 33 | + "--param", f"scheme={options.scheme}", |
| 34 | + "--param", f"base-toolchain-path={base_toolchain_path}", |
| 35 | + "--param", f"swift-sdks-path={swift_sdks_path}", |
| 36 | + ] |
| 37 | + test_dir = repo_path / "test" |
| 38 | + lit_cmd.append(str(test_dir)) |
| 39 | + lit_cmd.extend(extra_lit_args) |
| 40 | + |
| 41 | + print("=====> Running e2e integration tests") |
| 42 | + print(f"Command: {' '.join(lit_cmd)}") |
| 43 | + |
| 44 | + # Run the tests |
| 45 | + try: |
| 46 | + subprocess.check_call(lit_cmd) |
| 47 | + print("=====> e2e tests completed successfully") |
| 48 | + except subprocess.CalledProcessError as e: |
| 49 | + print(f"=====> e2e tests failed with exit code {e.returncode}") |
| 50 | + sys.exit(e.returncode) |
| 51 | + |
| 52 | + |
| 53 | +if __name__ == '__main__': |
| 54 | + main() |
0 commit comments