<commit_before>#!/bin/bash
set -e
UNAME=`uname`


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

DIR=`pwd`
ATBUILD="`pwd`/.atllbuild/products/atbuild"
pwd

echo "****************SELF-HOSTING TEST**************"
export ATBUILD_PACKAGE_VERSION="1.2"
echo "Remove this line after releasing 1.2"

if [ "$UNAME" == "Darwin" ]; then
    PLATFORM_SPECIFIC_PACKAGE="package-osx"
else
    PLATFORM_SPECIFIC_PACKAGE="package-linux"
fi

if ! $ATBUILD $PLATFORM_SPECIFIC_PACKAGE --use-overlay static; then
    echo "Self-host failed; maybe you're not running CaffeinatedSwift?"
    echo "Retrying with non-static build"
    $ATBUILD $PLATFORM_SPECIFIC_PACKAGE
fi

echo "****************ONLY-PLATFORMS TEST**************"
cd $DIR/tests/fixtures/only_platforms
$ATBUILD > /tmp/only.txt

if [ "$UNAME" == "Darwin" ]; then
    EXPECT="hello from osx"
    DONTEXPECT="hello from linux"
else
    EXPECT="hello from linux"
    DONTEXPECT="hello from osx"
fi
if ! grep "$EXPECT" /tmp/only.txt; then
    echo "Didn't find $EXPECT in /tmp/only.txt"
    exit 1
fi

if grep "$DONTEXPECT" /tmp/only.txt; then
    echo "Found $DONTEXPECT in /tmp/only.txt"
    exit 1
fi


echo "****************EXECUTABLE-NAME TEST**************"
cd $DIR/tests/fixtures/executable_name
$ATBUILD check

echo "****************ATBIN TEST**************"
cd $DIR/tests/fixtures/atbin

$ATBUILD
#did we build all the things we were supposed to?

if [ "$UNAME" == "Darwin" ]; then
    if [ ! -f "bin/dynamicatbin.atbin/osx.swiftmodule" ]; then
        echo "Missing swiftmodule"
        exit 1
    fi
    if [ ! -f "bin/dynamicatbin.atbin/osx.swiftdoc" ]; then
        echo "Missing swiftdoc"
        exit 1
    fi

    if [ ! -f "bin/dynamicatbin.atbin/dlib.dylib" ]; then
        echo "Missing dylib"
        exit 1
    fi

    if [ ! -f "bin/staticatbin.atbin/osx.swiftmodule" ]; then
        echo "Missing swiftmodule"
        exit 1
    fi
    if [ ! -f "bin/staticatbin.atbin/osx.swiftdoc" ]; then
        echo "Missing swiftdoc"
        exit 1
    fi

    if [ ! -f "bin/dynamicatbin-1.0-osx.atbin.tar.xz" ]; then
        echo "Missing compressed atbin"
        exit 1
    fi
    tar xf bin/dynamicatbin-1.0-osx.atbin.tar.xz

fi

else
    if [ ! -f "bin/dynamicatbin.atbin/linux.swiftmodule" ]; then
        echo "Missing swiftmodule"
        exit 1
    fi
    if [ ! -f "bin/dynamicatbin.atbin/linux.swiftdoc" ]; then
        echo "Missing swiftdoc"
        exit 1
    fi

    if [ ! -f "bin/dynamicatbin.atbin/dlib.so" ]; then
        echo "Missing dylib"
        exit 1
    fi

    if [ ! -f "bin/staticatbin.atbin/linux.swiftmodule" ]; then
        echo "Missing swiftmodule"
        exit 1
    fi
    if [ ! -f "bin/staticatbin.atbin/linux.swiftdoc" ]; then
        echo "Missing swiftdoc"
        exit 1
    fi

    if [ ! -f "bin/dynamicatbin-1.0-linux.atbin.tar.xz" ]; then<commit_msg>Remove errant fi<commit_after>#!/bin/bash
set -e
UNAME=`uname`


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

DIR=`pwd`
ATBUILD="`pwd`/.atllbuild/products/atbuild"
pwd

echo "****************SELF-HOSTING TEST**************"
export ATBUILD_PACKAGE_VERSION="1.2"
echo "Remove this line after releasing 1.2"

if [ "$UNAME" == "Darwin" ]; then
    PLATFORM_SPECIFIC_PACKAGE="package-osx"
else
    PLATFORM_SPECIFIC_PACKAGE="package-linux"
fi

if ! $ATBUILD $PLATFORM_SPECIFIC_PACKAGE --use-overlay static; then
    echo "Self-host failed; maybe you're not running CaffeinatedSwift?"
    echo "Retrying with non-static build"
    $ATBUILD $PLATFORM_SPECIFIC_PACKAGE
fi

echo "****************ONLY-PLATFORMS TEST**************"
cd $DIR/tests/fixtures/only_platforms
$ATBUILD > /tmp/only.txt

if [ "$UNAME" == "Darwin" ]; then
    EXPECT="hello from osx"
    DONTEXPECT="hello from linux"
else
    EXPECT="hello from linux"
    DONTEXPECT="hello from osx"
fi
if ! grep "$EXPECT" /tmp/only.txt; then
    echo "Didn't find $EXPECT in /tmp/only.txt"
    exit 1
fi

if grep "$DONTEXPECT" /tmp/only.txt; then
    echo "Found $DONTEXPECT in /tmp/only.txt"
    exit 1
fi


echo "****************EXECUTABLE-NAME TEST**************"
cd $DIR/tests/fixtures/executable_name
$ATBUILD check

echo "****************ATBIN TEST**************"
cd $DIR/tests/fixtures/atbin

$ATBUILD
#did we build all the things we were supposed to?

if [ "$UNAME" == "Darwin" ]; then
    if [ ! -f "bin/dynamicatbin.atbin/osx.swiftmodule" ]; then
        echo "Missing swiftmodule"
        exit 1
    fi
    if [ ! -f "bin/dynamicatbin.atbin/osx.swiftdoc" ]; then
        echo "Missing swiftdoc"
        exit 1
    fi

    if [ ! -f "bin/dynamicatbin.atbin/dlib.dylib" ]; then
        echo "Missing dylib"
        exit 1
    fi

    if [ ! -f "bin/staticatbin.atbin/osx.swiftmodule" ]; then
        echo "Missing swiftmodule"
        exit 1
    fi
    if [ ! -f "bin/staticatbin.atbin/osx.swiftdoc" ]; then
        echo "Missing swiftdoc"
        exit 1
    fi

    if [ ! -f "bin/dynamicatbin-1.0-osx.atbin.tar.xz" ]; then
        echo "Missing compressed atbin"
        exit 1
    fi
    tar xf bin/dynamicatbin-1.0-osx.atbin.tar.xz
else
    if [ ! -f "bin/dynamicatbin.atbin/linux.swiftmodule" ]; then
        echo "Missing swiftmodule"
        exit 1
    fi
    if [ ! -f "bin/dynamicatbin.atbin/linux.swiftdoc" ]; then
        echo "Missing swiftdoc"
        exit 1
    fi

    if [ ! -f "bin/dynamicatbin.atbin/dlib.so" ]; then
        echo "Missing dylib"
        exit 1
    fi

    if [ ! -f "bin/staticatbin.atbin/linux.swiftmodule" ]; then
        echo "Missing swiftmodule"
        exit 1
    fi
    if [ ! -f "bin/staticatbin.atbin/linux.swiftdoc" ]; then
        echo "Missing swiftdoc"
        exit 1
    fi

    if [ ! -f "bin/dynamicatbin-1.0-linux.atbin.tar.xz" ]; then
{'fraction_non_alphanumeric': 0.16450822541127055, 'fraction_numerical': 0.008050402520126006, 'mean_word_length': 2.75, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2586596', 'n_tokens_mistral': 2104, 'n_tokens_neox': 2013, 'n_words': 506}