<commit_before>#!/bin/bash

# Copyright 2018 The Kubernetes Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

base_dir="$( cd "$(dirname "$0")/../../.." && pwd )"
cd "$base_dir" || {
  echo "Cannot cd to '$base_dir'. Aborting." >&2
  exit 1
}

# Install kinflate to $GOPATH/bin and export PATH
go install ./cmd/kinflate
export PATH=$GOPATH/bin:$PATH

home=`pwd`
example_dir="some/default/dir/for/examples"
if [ $# -eq 1 ]; then
    example_dir=$1
fi
test_targets=$(ls ${example_dir})

for t in ${test_targets}; do
    cd ${example_dir}/${t}
    if [ -x "tests/test.sh" ]; then
        tests/test.sh .
    fi
    if [ $? -eq 0 ]; then
        echo "testing ${t} passed."
    else
        echo "testing ${t} failed."
    fi
    cd ${home}
done<commit_msg>Update main.sh to exit 1 when there is a failure<commit_after>#!/bin/bash

# Copyright 2018 The Kubernetes Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

function exit_with {
  local msg=$1
  echo >&2 ${msg}
  exit 1
}

base_dir="$( cd "$(dirname "$0")/../../.." && pwd )"
cd "$base_dir" || {
  echo "Cannot cd to '$base_dir'. Aborting." >&2
  exit 1
}

# Install kinflate to $GOPATH/bin and export PATH
go install ./cmd/kinflate || { exit_with "Failed to install kinflate"; }
export PATH=$GOPATH/bin:$PATH

home=`pwd`
example_dir="some/default/dir/for/examples"
if [ $# -eq 1 ]; then
    example_dir=$1
fi
if [ ! -d ${example_dir} ]; then
    exit_with "directory ${example_dir} doesn't exist"
fi

test_targets=$(ls ${example_dir})

for t in ${test_targets}; do
    cd ${example_dir}/${t}
    if [ -x "tests/test.sh" ]; then
        tests/test.sh .
        if [ $? -eq 0 ]; then
            echo "testing ${t} passed."
        else
            exit_with "testing ${t} failed."
        fi
    fi
    cd ${home}
done
{'fraction_non_alphanumeric': 0.12971613366870283, 'fraction_numerical': 0.011498383039885016, 'mean_word_length': 3.1927710843373496, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '5597543', 'n_tokens_mistral': 911, 'n_tokens_neox': 861, 'n_words': 338}