Two-tier conformance system: Tier 1 (550 vendored tests, PR gate) stays unchanged; Tier 2 clones tc39/test262 upstream and runs 4,745 qualifying tests via auto-generated manifest. Dynamic harness include loading supports 30+ harness files beyond sta.js/assert.js. ES5.1 subset tracked via es5id frontmatter tagging (969/2853 pass, 33%). Status overrides in checked-in js262_full_status.toml default to known_fail. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
89 lines
2.8 KiB
Python
89 lines
2.8 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
Clone or update the tc39/test262 repository for full-suite conformance testing.
|
|
|
|
Shallow-clones to tests/external/js262/upstream/. If already cloned, pulls updates.
|
|
Supports --rev flag for pinning to a specific commit.
|
|
|
|
Usage:
|
|
python3 scripts/clone_test262.py [--rev REV]
|
|
"""
|
|
|
|
import argparse
|
|
import subprocess
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
REPO_URL = "https://github.com/tc39/test262.git"
|
|
PROJECT_ROOT = Path(__file__).resolve().parent.parent
|
|
UPSTREAM_DIR = PROJECT_ROOT / "tests" / "external" / "js262" / "upstream"
|
|
|
|
|
|
def get_commit_hash(repo_dir):
|
|
"""Return the current HEAD commit hash."""
|
|
result = subprocess.run(
|
|
["git", "-C", str(repo_dir), "rev-parse", "HEAD"],
|
|
capture_output=True, text=True,
|
|
)
|
|
return result.stdout.strip() if result.returncode == 0 else "unknown"
|
|
|
|
|
|
def count_tests(repo_dir):
|
|
"""Count .js test files under test/language/."""
|
|
language_dir = repo_dir / "test" / "language"
|
|
if not language_dir.exists():
|
|
return 0
|
|
return sum(1 for _ in language_dir.rglob("*.js"))
|
|
|
|
|
|
def main():
|
|
parser = argparse.ArgumentParser(description="Clone or update tc39/test262")
|
|
parser.add_argument("--rev", default="",
|
|
help="Git revision to pin to (default: latest main)")
|
|
args = parser.parse_args()
|
|
|
|
if UPSTREAM_DIR.exists() and (UPSTREAM_DIR / ".git").exists():
|
|
print(f"Updating existing clone at {UPSTREAM_DIR}...")
|
|
if args.rev:
|
|
subprocess.run(
|
|
["git", "-C", str(UPSTREAM_DIR), "fetch", "--depth", "1",
|
|
"origin", args.rev],
|
|
check=True,
|
|
)
|
|
subprocess.run(
|
|
["git", "-C", str(UPSTREAM_DIR), "checkout", args.rev],
|
|
check=True,
|
|
)
|
|
else:
|
|
subprocess.run(
|
|
["git", "-C", str(UPSTREAM_DIR), "pull", "--ff-only"],
|
|
check=True,
|
|
)
|
|
else:
|
|
print(f"Cloning tc39/test262 (shallow) to {UPSTREAM_DIR}...")
|
|
UPSTREAM_DIR.parent.mkdir(parents=True, exist_ok=True)
|
|
cmd = ["git", "clone", "--depth", "1", REPO_URL, str(UPSTREAM_DIR)]
|
|
subprocess.run(cmd, check=True)
|
|
|
|
if args.rev:
|
|
print(f"Checking out revision: {args.rev}")
|
|
subprocess.run(
|
|
["git", "-C", str(UPSTREAM_DIR), "fetch", "--depth", "1",
|
|
"origin", args.rev],
|
|
check=True,
|
|
)
|
|
subprocess.run(
|
|
["git", "-C", str(UPSTREAM_DIR), "checkout", args.rev],
|
|
check=True,
|
|
)
|
|
|
|
commit = get_commit_hash(UPSTREAM_DIR)
|
|
test_count = count_tests(UPSTREAM_DIR)
|
|
print(f"\nCommit: {commit}")
|
|
print(f"Tests in test/language/: {test_count}")
|
|
print("Done.")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|