<commit_before>#!/bin/sh
#
# Copyright © 2010 Cisco Systems, Inc.  All rights reserved.
#
# Simple script to help test embedding:
#
#     ./run-embedded-tests.sh <tarball_name>
#

tarball=$1
if test "$tarball" = ""; then
    echo "Usage: $0 <tarball_name>"
    exit 1
elif test ! -r $tarball; then
    echo cannot read tarball: $tarball
    exit 1
fi

#---------------------------------------------------------------------

i=1
last_print=
print() {
    last_print="=== $i: $*"
    echo $last_print
    i=`expr $i + 1`
}

#---------------------------------------------------------------------

try() {
    cmd=$*
    eval $cmd
    status=$?
    if test "$status" != "0"; then
        echo "Command failed (status $status): $cmd"
        echo "Last print was: $last_print"
        exit 1
    fi
}

#---------------------------------------------------------------------

do_build() {
    print Running $1 configure...
    try $2/configure 2>&1 | tee config.out

    print Running make
    try make 2>&1 | tee make.out

    print Running make check
    try make check 2>&1 | tee check.out

    print Running make clean
    try make clean 2>&1 | tee clean.out

    print Running make distclean
    try make distclean 2>&1 | tee distclean.out
}

#---------------------------------------------------------------------

# Get tarball name
print Got tarball: $tarball

# Get the version
ver=`echo $tarball | sed -e 's/^.*hwloc-//' -e 's/.tar.*$//'`
print Got version: $ver

# Extract<commit_msg>Force the use of bash so that we can detect faults that ocurred two subroutines deep.<commit_after>#!/bin/bash -o pipefail
#
# Copyright © 2010 Cisco Systems, Inc.  All rights reserved.
#
# Simple script to help test embedding:
#
#     ./run-embedded-tests.sh <tarball_name>
#

tarball=$1
if test "$tarball" = ""; then
    echo "Usage: $0 <tarball_name>"
    exit 1
elif test ! -r $tarball; then
    echo cannot read tarball: $tarball
    exit 1
fi

#---------------------------------------------------------------------

i=1
last_print=
print() {
    last_print="=== $i: $*"
    echo $last_print
    i=`expr $i + 1`
}

#---------------------------------------------------------------------

try() {
    cmd=$*
    eval $cmd
    status=$?
    if test "$status" != "0"; then
        echo "Command failed (status $status): $cmd"
        echo "Last print was: $last_print"
        exit 1
    fi
}

#---------------------------------------------------------------------

do_build() {
    print Running $1 configure...
    try $2/configure 2>&1 | tee config.out
    if test "$?" != 0; then exit $?; fi

    print Running make
    try make 2>&1 | tee make.out
    if test "$?" != 0; then exit $?; fi

    print Running make check
    try make check 2>&1 | tee check.out
    if test "$?" != 0; then exit $?; fi

    print Running make clean
    try make clean 2>&1 | tee clean.out
    if test "$?" != 0; then exit $?; fi

    print Running make distclean
    try make distclean 2>&1 | tee distclean.out
    if test "$?" != 0; then exit $?; fi
}

#---------------------------------------------------------------------

# Get tarball name
print Got tarball: $tarball

# Get the version
ver=`echo $tarball | sed -e 's/^.*hwloc-//' -e 's/.tar.*$//'`
print Got version: $ver

# Extract
{'fraction_non_alphanumeric': 0.2865030674846626, 'fraction_numerical': 0.01625766871165644, 'mean_word_length': 1.4760820045558087, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 17, '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': '2254735', 'n_tokens_mistral': 1013, 'n_tokens_neox': 952, 'n_words': 340}