kythe.io@v0.0.68-0.20240422202219-7225dbc01741/kythe/cxx/tools/testdata/def_decl_test.sh (about)

     1  #!/bin/bash
     2  set -o pipefail
     3  set -o errexit
     4  readonly WRITE_ENTRIES=kythe/go/storage/tools/write_entries/write_entries
     5  readonly WRITE_TABLES=kythe/go/serving/tools/write_tables/write_tables
     6  readonly KYTHE=kythe/go/serving/tools/kythe/kythe
     7  readonly INDEXER=kythe/cxx/indexer/cxx/indexer
     8  readonly INPUT_PATH="kythe/cxx/tools/testdata/def_decl_test.cc"
     9  readonly INPUT_FILE="${TEST_SRCDIR}/io_kythe/${INPUT_PATH}"
    10  readonly FILE_URI="kythe:?path=${INPUT_PATH}"
    11  readonly OUTDIR="${TEST_TMPDIR:?Must be run via bazel test}"
    12  
    13  "$INDEXER" -i "$INPUT_FILE" | "$WRITE_ENTRIES" --graphstore "${OUTDIR}/graph" > /dev/null 2>&1
    14  "$WRITE_TABLES" --graphstore "${OUTDIR}/graph" --out "${OUTDIR}/serving" > /dev/null 2>&1
    15  
    16  kythe() {
    17    "$KYTHE" -api "${OUTDIR}/serving" "$@"
    18  }
    19  
    20  for ticket in $(kythe decor "${FILE_URI}" | grep /kythe/edge/defines/binding | awk '{print $4}'); do
    21    XREFS=$(kythe xrefs -declarations all -definitions all "$ticket")
    22    if [ "$(echo "$XREFS" | grep "${INPUT_PATH}" | wc -l)" -lt 3 ]; then
    23      echo -e "Definitions and declarations not completely linked:\n$XREFS" 1>&2
    24      exit 1
    25    fi
    26  done
    27  echo "PASS"