test.sh 4.54 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 11 12
ATBUILD="`pwd`/.atllbuild/products/atbuild"
pwd

echo "****************SELF-HOSTING TEST**************"
$ATBUILD atbuild

Drew's avatar
Drew committed
13 14 15 16 17 18 19 20 21
echo "****************XCODE TOOLCHAIN TEST**************"

if [ -e "/Applications/Xcode.app" ]; then
    cd $DIR/tests/fixtures/xcode_toolchain
    $ATBUILD --toolchain xcode 
else
    echo "Xcode is not installed; skipping test"
fi

22 23 24 25 26 27 28 29
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
30 31 32 33
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
34 35 36
    if ! grep "sources src/b.swift src/a.swift" /tmp/sources.txt; then
        exit 1
    fi
37 38
fi

Drew's avatar
Drew committed
39 40 41 42 43
echo "****************DYNAMIC LIBRARY TEST**************"
cd $DIR/tests/fixtures/dynamic_library
$ATBUILD
.atllbuild/products/dynamic_library_tester

Drew's avatar
Drew committed
44 45 46 47
echo "****************WMO TEST**************"
cd $DIR/tests/fixtures/wmo
$ATBUILD

48 49
echo "****************UMBRELLA TEST**************"
cd $DIR/tests/fixtures/umbrella_header
Drew's avatar
Drew committed
50
$ATBUILD check
51

Drew's avatar
Drew committed
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
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


Drew's avatar
Drew committed
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91
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

92 93 94 95
echo "****************NONSTANDARD TEST**************"
cd $DIR/tests/fixtures/nonstandard_package_file
$ATBUILD -f nonstandard.atpkg

96 97 98 99 100 101
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
102
if ! grep "No tool for task agressive.default; did you forget to specify it?" /tmp/warnings.txt; then
103 104 105 106
    echo "Got an error other than one prompting for the correct tool"
    exit 1
fi

107 108 109 110 111 112 113
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

114 115 116 117 118 119 120 121
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
122 123 124 125 126
if ! grep "poland" /tmp/warnings.txt; then
    echo "Was not warmed about invalid package key"
    exit 1
fi

127 128
cd $DIR/tests/fixtures/overlay
$ATBUILD --use-overlay got-overlay > /tmp/warnings.txt
Drew's avatar
Drew committed
129
if grep "Warning: Can't apply overlay no-such-overlay to task chained_overlays.child" /tmp/warnings.txt; then
130 131 132 133
    echo "Got a warning when building the overlay fixture"
    exit 1
fi

Drew's avatar
Drew committed
134 135 136 137 138 139
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
140

Drew's avatar
Drew committed
141
echo "****************HELP TEST*********************"
142 143

if $ATBUILD atbuild --help; then
Drew's avatar
Drew committed
144 145 146 147
    echo "Unusual help exit code"
    exit 1
fi

Drew's avatar
Drew committed
148
echo "*****************XCS TEST**********************"
149
cd $DIR/tests/fixtures/xcs && $ATBUILD run-tests
Drew's avatar
Drew committed
150

151 152 153 154 155 156 157 158 159 160 161 162 163
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
164 165 166
echo "*****************OVERLAY CHECKS**********************"

cd $DIR/tests/fixtures/overlay
Drew's avatar
Drew committed
167 168 169 170
if $ATBUILD; then
    echo "Expected a failure in overlay"
    exit 1
fi
Drew's avatar
Drew committed
171

172
$ATBUILD --use-overlay got-overlay
Drew's avatar
Drew committed
173

174
cd $DIR/tests/fixtures/overlay_default
175
if $ATBUILD --use-overlay foo; then
176 177 178 179
    echo "Expected a failure in overlay"
    exit 1
fi

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