kythe.io@v0.0.68-0.20240422202219-7225dbc01741/kythe/go/serving/tools/testdata/kwazthis_test.sh (about) 1 #!/bin/bash 2 # Copyright 2015 The Kythe Authors. All rights reserved. 3 # 4 # Licensed under the Apache License, Version 2.0 (the "License"); 5 # you may not use this file except in compliance with the License. 6 # You may obtain a copy of the License at 7 # 8 # http://www.apache.org/licenses/LICENSE-2.0 9 # 10 # Unless required by applicable law or agreed to in writing, software 11 # distributed under the License is distributed on an "AS IS" BASIS, 12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 # See the License for the specific language governing permissions and 14 # limitations under the License. 15 set -eox pipefail 16 17 BASE_DIR="$PWD/kythe/go/serving/tools/testdata" 18 OUT_DIR="$TEST_TMPDIR" 19 20 TEST_ENTRIES="$PWD/kythe/javatests/com/google/devtools/kythe/analyzers/java/testdata/pkg/generics_tests_entries.entries.gz" 21 source "kythe/cxx/common/testdata/start_http_service.sh" 22 23 jq () { "$JQ" -e "$@" <<<"$JSON"; } 24 kwazthis() { "$KWAZTHIS" --local_repo=NONE --api "http://$LISTEN_AT" "$@" | tee /dev/stderr; } 25 26 FILE_PATH=kythe/javatests/com/google/devtools/kythe/analyzers/java/testdata/pkg/Generics.java 27 28 JSON=$(kwazthis --corpus kythe --path $FILE_PATH --offset 813) 29 jq --slurp 'length == 4' 30 # .[0] is Generics class def 31 # .[1] is f method def 32 # .[2] is gs variable def 33 # .[3] is gs variable defines/binding 34 jq --slurp '.[] | (.kind == "ref" or .kind == "defines" or .kind == "defines/binding")' 35 jq --slurp '.[].node.ticket 36 and .[].node.ticket != ""' 37 jq --slurp '.[].node.kind 38 and .[].node.kind != ""'