-
Notifications
You must be signed in to change notification settings - Fork 55
/
Copy pathtest
executable file
·72 lines (57 loc) · 2.83 KB
/
test
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
60
61
62
63
64
65
66
67
68
69
70
71
72
#!/bin/bash
#
# This source file is part of the Swift.org open source project
#
# Copyright (c) 2022 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-Plugin root source dir.
SWIFT_DOCC_PLUGIN_ROOT="$(dirname $(dirname $(filepath $0)))"
SWIFT_SKIP_BUILDING_UPSTREAM_DOCC=${SWIFT_SKIP_BUILDING_UPSTREAM_DOCC:=false}
if [[ $SWIFT_SKIP_BUILDING_UPSTREAM_DOCC != true ]]
then
SWIFT_DOCC_ROOT="$SWIFT_DOCC_PLUGIN_ROOT/swift-docc"
SWIFT_DOCC_RENDER_ARTIFACT_ROOT="$SWIFT_DOCC_PLUGIN_ROOT/swift-docc-render-artifact"
export DOCC_HTML_DIR="$SWIFT_DOCC_RENDER_ARTIFACT_ROOT/dist"
SWIFT_DOCC_REPO=${SWIFT_DOCC_REPO:="https://github.com/swiftlang/swift-docc.git"}
SWIFT_DOCC_RENDER_ARTIFACT_REPO=${SWIFT_DOCC_RENDER_ARTIFACT_REPO:="https://github.com/swiftlang/swift-docc-render-artifact.git"}
SWIFT_DOCC_BRANCH=${SWIFT_DOCC_BRANCH:="main"}
SWIFT_DOCC_RENDER_ARTIFACT_BRANCH=${SWIFT_DOCC_RENDER_ARTIFACT_BRANCH:="main"}
# The script will clone swift-docc and swift-docc-render-artifact at the
# branches pulled from the environment above. The tests will then run using
# that built DocC. This can be useful for testing interdependent changes that
# need to land together and make it possible to test multiple pull requests
# together.
echo "Cloning docc..."
rm -rf "$SWIFT_DOCC_ROOT"
git clone -b "$SWIFT_DOCC_BRANCH" "${SWIFT_DOCC_REPO}" "$SWIFT_DOCC_ROOT" || exit 1
echo "Cloning docc-render-artifact..."
rm -rf "$SWIFT_DOCC_RENDER_ARTIFACT_ROOT"
git clone -b "${SWIFT_DOCC_RENDER_ARTIFACT_BRANCH}" "${SWIFT_DOCC_RENDER_ARTIFACT_REPO}" "$SWIFT_DOCC_RENDER_ARTIFACT_ROOT" || exit 1
echo "Building docc..."
swift build --package-path "$SWIFT_DOCC_ROOT" --product docc --configuration release || exit 1
export DOCC_EXEC="$(swift build --package-path "$SWIFT_DOCC_ROOT" --show-bin-path --configuration release)/docc"
if [[ ! -f "$DOCC_EXEC" ]]; then
echo "docc executable not found, expected at $DOCC_EXEC"
exit 1
else
echo "Using docc executable: $DOCC_EXEC"
fi
fi
# Build and test Swift-DocC Plugin
swift test --parallel --package-path "$SWIFT_DOCC_PLUGIN_ROOT"
# Build and test Swift-DocC Plugin integration tests
# We use a shared cache when building the plugin so these tests shouldn't be run in parallel.
swift test --package-path "$SWIFT_DOCC_PLUGIN_ROOT/IntegrationTests"
# Run source code checks for the codebase.
LC_ALL=C "$SWIFT_DOCC_PLUGIN_ROOT"/bin/check-source
printf "\033[0;32mokay.\033[0m\n"