<commit_before>#!/bin/bash
# Copyright 2018 The Kythe Authors. All rights reserved.
#
# 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.
set -e

. ./kythe/cxx/extractor/proto/testdata/skip_functions.sh

KINDEX_TOOL=$1; shift
KZIP=$1; shift
GOLDEN=$1; shift

# Extract textproto version of compilation unit from kzip.
"${KINDEX_TOOL}" -canonicalize_hashes -suppress_details -explode "${KZIP}"

# Remove lines that will change depending on the machine the test is run on.
skip_inplace "-target" 1 "${KZIP}_UNIT"
skip_inplace "signature" 0 "${KZIP}_UNIT"
skip_inplace "working_directory" 0 "${KZIP}_UNIT"

echo
echo "Diffing generated unit against golden"
echo "-------------------------------------"
diff -u $GOLDEN ${KZIP}_UNIT
echo "No diffs found!"<commit_msg>fix: extract test files in TEST_TMPDIR instead of runfiles dir (#29)<commit_after>#!/bin/bash
# Copyright 2018 The Kythe Authors. All rights reserved.
#
# 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.
set -e

. ./kythe/cxx/extractor/proto/testdata/skip_functions.sh

KINDEX_TOOL=$1; shift
KZIP=$1; shift
GOLDEN=$1; shift

# Work in tmpdir because the runfiles dir is not writable
cp $KZIP "${TEST_TMPDIR}/file.kzip"
# Extract textproto version of compilation unit from kzip.
"${KINDEX_TOOL}" -canonicalize_hashes -suppress_details -explode "${TEST_TMPDIR}/file.kzip"
UNIT="${TEST_TMPDIR}/file.kzip_UNIT"

# Remove lines that will change depending on the machine the test is run on.
skip_inplace "-target" 1 $UNIT
skip_inplace "signature" 0 $UNIT
skip_inplace "working_directory" 0 $UNIT

echo
echo "Diffing generated unit against golden"
echo "-------------------------------------"
diff -u $GOLDEN $UNIT
echo "No diffs found!"
{'fraction_non_alphanumeric': 0.11784511784511785, 'fraction_numerical': 0.01122334455667789, 'mean_word_length': 4.142307692307693, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '4737383', 'n_tokens_mistral': 798, 'n_tokens_neox': 770, 'n_words': 325}