test.sh 4.28 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

13 14 15 16 17 18 19 20
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
21 22 23 24 25 26 27
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
28

Drew's avatar
Drew committed
29 30 31 32 33
echo "****************DYNAMIC LIBRARY TEST**************"
cd $DIR/tests/fixtures/dynamic_library
$ATBUILD
.atllbuild/products/dynamic_library_tester

Drew's avatar
Drew committed
34 35 36 37
echo "****************WMO TEST**************"
cd $DIR/tests/fixtures/wmo
$ATBUILD

38 39
echo "****************UMBRELLA TEST**************"
cd $DIR/tests/fixtures/umbrella_header
Drew's avatar
Drew committed
40
$ATBUILD check
41

Drew's avatar
Drew committed
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
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
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81
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

82 83 84 85
echo "****************NONSTANDARD TEST**************"
cd $DIR/tests/fixtures/nonstandard_package_file
$ATBUILD -f nonstandard.atpkg

86 87 88 89 90 91
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
92
if ! grep "No tool for task agressive.default; did you forget to specify it?" /tmp/warnings.txt; then
93 94 95 96
    echo "Got an error other than one prompting for the correct tool"
    exit 1
fi

97 98 99 100 101 102 103
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

104 105 106 107 108 109 110 111
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
112 113 114 115 116
if ! grep "poland" /tmp/warnings.txt; then
    echo "Was not warmed about invalid package key"
    exit 1
fi

117 118
cd $DIR/tests/fixtures/overlay
$ATBUILD --use-overlay got-overlay > /tmp/warnings.txt
Drew's avatar
Drew committed
119
if grep "Warning: Can't apply overlay no-such-overlay to task chained_overlays.child" /tmp/warnings.txt; then
120 121 122 123
    echo "Got a warning when building the overlay fixture"
    exit 1
fi

Drew's avatar
Drew committed
124 125 126 127 128 129
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
130

Drew's avatar
Drew committed
131
echo "****************HELP TEST*********************"
132 133

if $ATBUILD atbuild --help; then
Drew's avatar
Drew committed
134 135 136 137
    echo "Unusual help exit code"
    exit 1
fi

Drew's avatar
Drew committed
138
echo "*****************XCS TEST**********************"
139
cd $DIR/tests/fixtures/xcs && $ATBUILD run-tests
Drew's avatar
Drew committed
140

141 142 143 144 145 146 147 148 149 150 151 152 153
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
154 155 156
echo "*****************OVERLAY CHECKS**********************"

cd $DIR/tests/fixtures/overlay
Drew's avatar
Drew committed
157 158 159 160
if $ATBUILD; then
    echo "Expected a failure in overlay"
    exit 1
fi
Drew's avatar
Drew committed
161

162
$ATBUILD --use-overlay got-overlay
Drew's avatar
Drew committed
163

164
cd $DIR/tests/fixtures/overlay_default
165
if $ATBUILD --use-overlay foo; then
166 167 168 169
    echo "Expected a failure in overlay"
    exit 1
fi

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