<commit_before>#!/bin/bash -eu
#
# Copyright 2016 Google Inc.
#
# 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.
#
################################################################################
#
# Run tests to verify that in-place file modification works as intended.
# TODO(mbrukman): run over the entire test suite's set of file types / licenses.
#
################################################################################

set -eu

declare -r TEST_SRCDIR="$(dirname $0)/.."
declare -r TEST_TMPDIR="$(mktemp -d "/tmp/$(basename $0).XXXXXX")"

function cleanup() {
  rm -rf "${TEST_TMPDIR}"
}

trap cleanup EXIT INT TERM

declare -r RANDOM_DATA="$(date | md5)"

declare -i num_passed=0
declare -i num_failed=0

for ext in sh py rb hs; do
  actual_file="${TEST_TMPDIR}/actual.${ext}"
  expected_file="${TEST_TMPDIR}/expected.${ext}"

  # Generate the actual file and update it in-place.
  echo "${RANDOM_DATA}" > "${actual_file}"
  "${TEST_SRCDIR}/autogen.sh" -i "${actual_file}"

  # Generate the expected file using the usual means.
  "${TEST_SRCDIR}/autogen.sh" "${expected_file}" > "${expected_file}"
  echo "${RANDOM_DATA}" >> "${expected_file}"

  # Compare the two files.
  diff -u "${expected_file}" "${actual_file}"
  if [[ $? -eq 0 ]]; then
    num_passed=$((num_passed+1))
  else
    num_failed=$((num_failed+1))<commit_msg>Remove unneeded dependency on `md5`.<commit_after>#!/bin/bash -eu
#
# Copyright 2016 Google Inc.
#
# 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.
#
################################################################################
#
# Run tests to verify that in-place file modification works as intended.
# TODO(mbrukman): run over the entire test suite's set of file types / licenses.
#
################################################################################

set -eu

declare -r TEST_SRCDIR="$(dirname $0)/.."
declare -r TEST_TMPDIR="$(mktemp -d "/tmp/$(basename $0).XXXXXX")"

function cleanup() {
  rm -rf "${TEST_TMPDIR}"
}

trap cleanup EXIT INT TERM

declare -r RANDOM_DATA="$(date)"

declare -i num_passed=0
declare -i num_failed=0

for ext in sh py rb hs; do
  actual_file="${TEST_TMPDIR}/actual.${ext}"
  expected_file="${TEST_TMPDIR}/expected.${ext}"

  # Generate the actual file and update it in-place.
  echo "${RANDOM_DATA}" > "${actual_file}"
  "${TEST_SRCDIR}/autogen.sh" -i "${actual_file}"

  # Generate the expected file using the usual means.
  "${TEST_SRCDIR}/autogen.sh" "${expected_file}" > "${expected_file}"
  echo "${RANDOM_DATA}" >> "${expected_file}"

  # Compare the two files.
  diff -u "${expected_file}" "${actual_file}"
  if [[ $? -eq 0 ]]; then
    num_passed=$((num_passed+1))
  else
    num_failed=$((num_failed+1))
{'fraction_non_alphanumeric': 0.21032711543660448, 'fraction_numerical': 0.008650986753176534, 'mean_word_length': 4.6923076923076925, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, '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': '4702600', 'n_tokens_mistral': 1121, 'n_tokens_neox': 1077, 'n_words': 386}