From 6b2cf2a429cf8a7fd6301c09ae5220f20de15d0b Mon Sep 17 00:00:00 2001 From: Mihaela Mihaljevic Date: Fri, 26 Jun 2026 08:59:07 +0200 Subject: [PATCH] chore(test): add scripts/fetch-xsts.sh to obtain the XSTS corpus (#321) The W3C XML Schema Test Suite (2006-11-06) drives the opt-in conformance runner but is never vendored: the W3C Document License permits redistribution only as the complete unmodified archive, and the corpus is about 200 MB. This script downloads the official archive on demand, verifies its SHA-256, and extracts it to the path XSTS_ROOT expects. Idempotent and portable (shasum or sha256sum). Points the onboarding doc at it. --- docs/onboarding-antigravity.md | 4 ++- scripts/fetch-xsts.sh | 62 ++++++++++++++++++++++++++++++++++ 2 files changed, 65 insertions(+), 1 deletion(-) create mode 100755 scripts/fetch-xsts.sh diff --git a/docs/onboarding-antigravity.md b/docs/onboarding-antigravity.md index 92210e8..9ae7660 100644 --- a/docs/onboarding-antigravity.md +++ b/docs/onboarding-antigravity.md @@ -88,7 +88,9 @@ environment): This path is the value of the `XSTS_ROOT` environment variable used by the conformance runner. If it is missing, the conformance runner silently does nothing (it is opt-in), so confirm the directory exists before relying on it: - `ls /private/tmp/xsts/xmlschema2006-11-06/suite.xml`. + `ls /private/tmp/xsts/xmlschema2006-11-06/suite.xml`. To obtain it, run + `bash scripts/fetch-xsts.sh`, which downloads and SHA-256-verifies the official + W3C archive into that path (the suite is never vendored). --- diff --git a/scripts/fetch-xsts.sh b/scripts/fetch-xsts.sh new file mode 100755 index 0000000..6d6c0a3 --- /dev/null +++ b/scripts/fetch-xsts.sh @@ -0,0 +1,62 @@ +#!/usr/bin/env bash +# Fetch the W3C XML Schema Test Suite (XSTS, 2006-11-06 release) to the path the +# conformance runner (Tests/XSTSSuiteTests.swift) expects. +# +# The suite is never vendored: the W3C Document License permits redistribution +# only as the complete unmodified archive, and the corpus is about 200 MB across +# 39,399 files. This script downloads the official archive on demand and verifies +# its SHA-256 before extracting. +# +# Usage: +# bash scripts/fetch-xsts.sh +# XSTS_ROOT=/private/tmp/xsts/xmlschema2006-11-06 swift test -c release --filter XSTSSuiteTests +# +# Override the destination directory with XSTS_DEST (default /private/tmp/xsts). + +set -euo pipefail + +dest="${XSTS_DEST:-/private/tmp/xsts}" +root="$dest/xmlschema2006-11-06" +url="https://www.w3.org/XML/2004/xml-schema-test-suite/xmlschema2006-11-06/xsts-2007-06-20.tar.gz" +sha256="902176b25e4111cf96b08663107521a4992e8ea67aad6b815592a6a5b4b9ea06" + +if [ -f "$root/suite.xml" ]; then + echo "xsts: already present at $root" + echo "xsts: export XSTS_ROOT=$root" + exit 0 +fi + +mkdir -p "$dest" +archive="$dest/xsts-2007-06-20.tar.gz" +echo "xsts: downloading the 2006-11-06 archive (about 4.4 MB)" +curl -fsSL -o "$archive" "$url" + +# Verify integrity before extracting (portable across macOS and Linux). +if command -v shasum >/dev/null 2>&1; then + actual="$(shasum -a 256 "$archive" | awk '{print $1}')" +elif command -v sha256sum >/dev/null 2>&1; then + actual="$(sha256sum "$archive" | awk '{print $1}')" +else + echo "xsts: no sha256 tool (shasum or sha256sum) found" >&2 + rm -f "$archive" + exit 1 +fi + +if [ "$actual" != "$sha256" ]; then + echo "xsts: checksum mismatch, refusing to extract" >&2 + echo " expected $sha256" >&2 + echo " actual $actual" >&2 + rm -f "$archive" + exit 1 +fi + +tar xzf "$archive" -C "$dest" +rm -f "$archive" + +if [ ! -f "$root/suite.xml" ]; then + echo "xsts: suite.xml not found after extraction at $root" >&2 + exit 1 +fi + +echo "xsts: ready at $root" +echo "xsts: export XSTS_ROOT=$root"