-
Notifications
You must be signed in to change notification settings - Fork 182
Expand file tree
/
Copy pathtest
More file actions
executable file
·60 lines (48 loc) · 2.06 KB
/
Copy pathtest
File metadata and controls
executable file
·60 lines (48 loc) · 2.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/bin/bash
#
# This source file is part of the Swift.org open source project
#
# Copyright (c) 2021 Apple Inc. and the Swift project authors
# Licensed under Apache License v2.0 with Runtime Library Exception
#
# See https://swift.org/LICENSE.txt for license information
# See https://swift.org/CONTRIBUTORS.txt for Swift project authors
#
set -eu
# A `realpath` alternative using the default C implementation.
filepath() {
[[ $1 = /* ]] && echo "$1" || echo "$PWD/${1#./}"
}
# First get the absolute path to this file so we can get the absolute file path to the Swift-DocC root source dir.
DOCC_ROOT="$(dirname $(dirname $(filepath $0)))"
# Build SwiftDocC.
swift test --parallel --package-path "$DOCC_ROOT"
base_ref=""
if git -C "$DOCC_ROOT" rev-parse --verify --quiet origin/main >/dev/null 2>&1; then
base_ref="origin/main"
fi
# Build and test auxiliary Swift packages under `bin/`.
# These are separate packages that aren't covered by `swift test` above.
# To avoid rebuilding them on every run, only build an auxiliary package if
# the package source changes or a package it depends on changes.
should_build() {
[ -z "$base_ref" ] && return 0
git -C "$DOCC_ROOT" diff --name-only "$base_ref"...HEAD | grep -qE "$1"
}
# `bin/make-test-bundle` has no dependencies, only check its source.
if should_build '^bin/make-test-bundle/'; then
printf "=> Building make-test-bundle…\n"
swift build --package-path "$DOCC_ROOT/bin/make-test-bundle"
fi
# `bin/benchmark` depends on the benchmark schema in `Sources/SwiftDocC/Benchmark/`.
# Build and test it if its source or this dependency changes.
if should_build '^(bin/benchmark/|Sources/SwiftDocC/Benchmark/|Package\.(swift|resolved)$)'; then
printf "=> Building and testing benchmark…\n"
swift test --parallel --package-path "$DOCC_ROOT/bin/benchmark"
fi
# Run source code checks for the codebase.
LC_ALL=C "$DOCC_ROOT"/bin/check-source
# Test utility scripts validity.
printf "=> Validating scripts in bin subdirectory… "
swift "$DOCC_ROOT/bin/output-diff.swift" > /dev/null
printf "\033[0;32mokay.\033[0m\n"