test.sh 5.78 KB
Newer Older
Drew's avatar
Drew committed
1 2 3 4 5
#!/bin/bash
set -e

echo "**********THE ATBUILD TEST SCRIPT*************"

6
DIR=`pwd`
Drew's avatar
Drew committed
7 8 9 10
ATBUILD="`pwd`/.atllbuild/products/atbuild"
pwd

echo "****************SELF-HOSTING TEST**************"
Drew's avatar
Drew committed
11 12 13 14 15
if ! $ATBUILD atbuild --use-overlay static; then
    echo "Self-host failed; maybe you're not running CaffeinatedSwift?"
    echo "Retrying with non-static build"
    $ATBUILD atbuild
fi
Drew's avatar
Drew committed
16

Drew's avatar
Drew committed
17
echo "****************PLUGIN TEST**************"
Drew's avatar
Drew committed
18
cd $DIR/tests/fixtures/attool
Drew's avatar
Drew committed
19
$ATBUILD > /tmp/plugin.txt
Drew's avatar
Drew committed
20
if ! grep "\-key value --test test_substitution --userpath .*tests/fixtures/attool/user" /tmp/plugin.txt; then
Drew's avatar
Drew committed
21 22 23 24 25
    cat /tmp/plugin.txt
    echo "Did not find key print in plugin test"
    exit 1
fi

Drew's avatar
Drew committed
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
echo "****************PLATFORMS TEST**************"
cd $DIR/tests/fixtures/platforms
UNAME=`uname`
$ATBUILD check 2&> /tmp/platforms.txt
if [ "$UNAME" == "Darwin" ]; then
    STR="Hello from OSX!"
else
    STR="Hello from LINUX!"
fi
if ! grep "$STR" /tmp/platforms.txt; then
    cat /tmp/platforms.txt
    echo "Did not find platform print in platform test"
    exit 1
fi

#check bootstrapping case
$ATBUILD build --use-overlay bootstrap-only --platform linux
if ! cmp --silent bin/bootstrap-platform.yaml known-linux-bootstrap.yaml; then
    echo "Linux bootstrap was unexpected"
    exit 1
fi

$ATBUILD build --use-overlay bootstrap-only --platform osx
if ! cmp --silent bin/bootstrap-platform.yaml known-osx-bootstrap.yaml; then
    echo "OSX bootstrap was unexpected"
    exit 1
fi



Drew's avatar
Drew committed
56 57 58 59
echo "****************XCODE TOOLCHAIN TEST**************"

if [ -e "/Applications/Xcode.app" ]; then
    cd $DIR/tests/fixtures/xcode_toolchain
60
    $ATBUILD --toolchain xcode
Drew's avatar
Drew committed
61 62 63 64
else
    echo "Xcode is not installed; skipping test"
fi

65 66 67 68 69 70 71 72
echo "****************PACKAGE FRAMEWORK TESTS**************"
UNAME=`uname`
if [ "$UNAME" == "Darwin" ]; then
    cd $DIR/tests/fixtures/package_framework
    $ATBUILD check
else
    echo "Skipping framework tests on this platform"
fi
73 74 75 76
echo "****************COLLECT SOURCES TEST**************"
cd $DIR/tests/fixtures/collect_sources
$ATBUILD collect-sources 2&> /tmp/sources.txt
if ! grep "sources src/a.swift src/b.swift" /tmp/sources.txt; then
77 78 79
    if ! grep "sources src/b.swift src/a.swift" /tmp/sources.txt; then
        exit 1
    fi
80 81
fi

Drew's avatar
Drew committed
82 83 84 85 86
echo "****************DYNAMIC LIBRARY TEST**************"
cd $DIR/tests/fixtures/dynamic_library
$ATBUILD
.atllbuild/products/dynamic_library_tester

Drew's avatar
Drew committed
87 88 89 90
echo "****************WMO TEST**************"
cd $DIR/tests/fixtures/wmo
$ATBUILD

91 92
echo "****************UMBRELLA TEST**************"
cd $DIR/tests/fixtures/umbrella_header
Drew's avatar
Drew committed
93
$ATBUILD check
94

Drew's avatar
Drew committed
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110
echo "****************USER PATH TEST**************"
cd $DIR/tests/fixtures/user_paths

$ATBUILD third
RESULT=`cat user/test`
RESULT2="FIRST
SECOND
THIRD"
if [ "$RESULT" != "$RESULT2" ]; then
    echo "Unusual user path concoction $RESULT $RESULT2"
    exit 1
fi

$ATBUILD compile


111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134
echo "****************PUBLISHPRODUCT TEST**************"
cd $DIR/tests/fixtures/publish_product
$ATBUILD

if [ ! -f "bin/executable" ]; then
    echo "No executable"
    exit 1
fi

if [ ! -f "bin/executable.swiftmodule" ]; then
    echo "No module (executable)"
    exit 1
fi

if [ ! -f "bin/library.swiftmodule" ]; then
    echo "No module (library)"
    exit 1
fi

if [ ! -f "bin/library.a" ]; then
    echo "No library"
    exit 1
fi

135 136 137 138
echo "****************NONSTANDARD TEST**************"
cd $DIR/tests/fixtures/nonstandard_package_file
$ATBUILD -f nonstandard.atpkg

139 140 141 142 143 144
echo "****************AGRESSIVE TEST**************"
cd $DIR/tests/fixtures/agressive
if $ATBUILD 2&> /tmp/warnings.txt; then
    echo "No tool specified but passed anyway?"
    exit 1
fi
Drew's avatar
Drew committed
145
if ! grep "No tool for task agressive.default; did you forget to specify it?" /tmp/warnings.txt; then
146 147 148 149
    echo "Got an error other than one prompting for the correct tool"
    exit 1
fi

150 151 152 153 154 155 156
echo "****************SHADOW TEST*********************"
cd $DIR/tests/fixtures/depend_default
if $ATBUILD build-tests; then
    echo "default task was shadowed; expected a failure but got a pass"
    exit 1
fi

157 158 159 160 161 162 163 164
echo "****************WARNING TEST*********************"
cd $DIR/tests/fixtures/warnings
$ATBUILD > /tmp/warnings.txt
if ! grep "germany" /tmp/warnings.txt; then
    echo "Was not warned about invalid task key"
    exit 1
fi

Drew's avatar
Drew committed
165 166 167 168 169
if ! grep "poland" /tmp/warnings.txt; then
    echo "Was not warmed about invalid package key"
    exit 1
fi

170 171
cd $DIR/tests/fixtures/overlay
$ATBUILD --use-overlay got-overlay > /tmp/warnings.txt
Drew's avatar
Drew committed
172
if grep "Warning: Can't apply overlay no-such-overlay to task chained_overlays.child" /tmp/warnings.txt; then
173 174 175 176
    echo "Got a warning when building the overlay fixture"
    exit 1
fi

Drew's avatar
Drew committed
177 178 179 180 181 182
cd $DIR/tests/fixtures/chained_overlays
$ATBUILD --use-overlay no-such-overlay > /tmp/warnings.txt
if grep "Warning: Can't apply overlay no-such-overlay to task chained_overlays.child" /tmp/warnings.txt; then
    echo "Got a warning when building the chained_overlays fixture"
    exit 1
fi
183

Drew's avatar
Drew committed
184
echo "****************HELP TEST*********************"
185 186

if $ATBUILD atbuild --help; then
Drew's avatar
Drew committed
187 188 189 190
    echo "Unusual help exit code"
    exit 1
fi

Drew's avatar
Drew committed
191
echo "*****************XCS TEST**********************"
192
cd $DIR/tests/fixtures/xcs && $ATBUILD run-tests
Drew's avatar
Drew committed
193

194 195 196 197 198 199 200 201 202 203 204 205 206
echo "*****************STRICT CHECKS**********************"
if [ `uname` != "Darwin" ]; then
    echo "Not checking STRICT for non-Darwin platform"
else
    cd $DIR/tests/fixtures/xcs_strict
    if $ATBUILD run-tests; then
        echo "Expected a failure in xcs_strict"
        exit 1
    else
        echo "Strict failed as expected"
    fi
fi

Drew's avatar
Drew committed
207 208 209
echo "*****************OVERLAY CHECKS**********************"

cd $DIR/tests/fixtures/overlay
Drew's avatar
Drew committed
210 211 212 213
if $ATBUILD; then
    echo "Expected a failure in overlay"
    exit 1
fi
Drew's avatar
Drew committed
214

215
$ATBUILD --use-overlay got-overlay
Drew's avatar
Drew committed
216

217
cd $DIR/tests/fixtures/overlay_default
218
if $ATBUILD --use-overlay foo; then
219 220 221 222
    echo "Expected a failure in overlay"
    exit 1
fi

223
printf "\e[1m\e[32m***ATBUILD TEST SCRIPT PASSED SUCCESSFULLY*****\e[0m"