test.sh 4.51 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 34 35 36 37
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
    echo "Unexpected sources $COLLECT_SOURCES"
    exit 1
fi

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

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

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

Drew's avatar
Drew committed
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
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
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90
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

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

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

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

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

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

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

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

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

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

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

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

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

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

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