Something went wrong. Try again.
An auto tiler for macOS
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839#!/bin/bashset -euo pipefailcd "$(dirname "$0")/../.."PARCEL_DEV_BINARY=${PARCEL_DEV_BINARY:-$(Scripts/parcel-dev.sh --path)}export PARCEL_DEV_BINARYwork=$(mktemp -d "${TMPDIR:-/tmp}/swift-safety.XXXXXX")trap 'rm -rf "$work"' EXITmkdir -p "$work/Scripts" "$work/Sources" "$work/Tests"cp Scripts/check-swift-safety.sh Scripts/parcel-dev.sh "$work/Scripts/"check() { bash "$work/Scripts/check-swift-safety.sh" "$@"; }reject() { if check > "$work/output" 2>&1; then printf 'Unsafe Swift unexpectedly passed.\n' >&2 exit 1 fi grep -q 'Sources/Example.swift:1:' "$work/output"}printf 'let geometry: Geometry?\n' > "$work/Sources/Example.swift"checkprintf 'let result = try? read()\n' > "$work/Sources/Example.swift"rejectprintf 'let result = try ? read()\n' > "$work/Sources/Example.swift"rejectprintf 'let result = input as! Value\n' > "$work/Sources/Example.swift"rejectprintf 'let result = input as ! Value\n' > "$work/Sources/Example.swift"rejectprintf 'let result = try? read() // swift-safety: allow-try? -- failure is the tested probe result\n' > "$work/Sources/Example.swift"checkprintf 'let result = try? read() // swift-safety: allow-try? -- \n' > "$work/Sources/Example.swift"rejectprintf 'let result = input as! Value // swift-safety: allow-try? -- not a cast exemption\n' > "$work/Sources/Example.swift"rejectprintf 'let result = try? read()\n' > "$work/Tests/Example.swift"check Tests/Example.swiftprintf '// Do not swallow errors with try?\n' > "$work/Sources/Example.swift"check Sources/Example.swiftprintf 'Swift safety checks passed: 10\n'