|
| 1 | +#!/usr/bin/env bash |
| 2 | +##===----------------------------------------------------------------------===## |
| 3 | +## |
| 4 | +## This source file is part of the SwiftContainerPlugin open source project |
| 5 | +## |
| 6 | +## Copyright (c) 2024 Apple Inc. and the SwiftContainerPlugin project authors |
| 7 | +## Licensed under Apache License v2.0 |
| 8 | +## |
| 9 | +## See LICENSE.txt for license information |
| 10 | +## See CONTRIBUTORS.txt for the list of SwiftContainerPlugin project authors |
| 11 | +## |
| 12 | +## SPDX-License-Identifier: Apache-2.0 |
| 13 | +## |
| 14 | +##===----------------------------------------------------------------------===## |
| 15 | + |
| 16 | + |
| 17 | +log() { printf -- "** %s\n" "$*" >&2; } |
| 18 | +error() { printf -- "** ERROR: %s\n" "$*" >&2; } |
| 19 | +fatal() { error "$@"; exit 1; } |
| 20 | + |
| 21 | +if [[ -n ${TOOLCHAINS+x} ]] ; then |
| 22 | + fatal "Please unset the TOOLCHAINS environment variable. The OSS Swift toolchain cannot run these tests because it does not include XCTest.framework." |
| 23 | +fi |
| 24 | + |
| 25 | +set -euo pipefail |
| 26 | + |
| 27 | +RUNTIME=${RUNTIME-"docker"} |
| 28 | + |
| 29 | +# Start a registry on an ephemeral port |
| 30 | +REGISTRY_ID=$($RUNTIME run -d --rm -p 127.0.0.1::5000 registry:2) |
| 31 | +export REGISTRY_HOST="localhost" |
| 32 | +REGISTRY_PORT=$($RUNTIME port "$REGISTRY_ID" 5000/tcp | sed -E 's/^.+:([[:digit:]]+)$/\1/') |
| 33 | +export REGISTRY_PORT |
| 34 | +log "Registry $REGISTRY_ID listening on $REGISTRY_HOST:$REGISTRY_PORT" |
| 35 | + |
| 36 | +# Delete the registry after running the tests, regardless of the outcome |
| 37 | +cleanup() { |
| 38 | + log "Deleting registry $REGISTRY_ID" |
| 39 | + $RUNTIME rm -f "$REGISTRY_ID" |
| 40 | +} |
| 41 | +trap cleanup EXIT |
| 42 | + |
| 43 | +log "Running smoke tests" |
| 44 | +swift test --filter 'SmokeTests' |
0 commit comments