github.com/stackb/rules_proto@v0.0.0-20240221195024-5428336c51f1/example/golden/testdata/proto_repository/proto_gazelle_data_test.bzl (about) 1 """proto_gazelle_data_test is a regression test. 2 3 See https://github.com/stackb/rules_proto/issues/342. 4 5 """ 6 7 # This test script asserts that all expected files are present in runfiles. 8 # Specifically, as a regression test that items listed in gazelle.data are 9 # present (./genfile_should_be_present_in_gazelle_data_runfiles.txt). 10 SCRIPT = """ 11 set -x 12 13 read -r -d '' WANT <<'EOF' 14 . 15 ./config.yaml 16 ./external 17 ./external/bazel_tools 18 ./external/bazel_tools/tools 19 ./external/bazel_tools/tools/bash 20 ./external/bazel_tools/tools/bash/runfiles 21 ./external/bazel_tools/tools/bash/runfiles/runfiles.bash 22 ./external/go_sdk 23 ./external/go_sdk/bin 24 ./external/go_sdk/bin/go 25 ./external/googleapis 26 ./external/googleapis/imports.csv 27 ./gazelle 28 ./gazelle-protobuf_ 29 ./gazelle-protobuf_/gazelle-protobuf 30 ./gazelle-runner.bash 31 ./genfile_should_be_present_in_gazelle_data_runfiles.txt 32 ./proto_repository_data_test 33 EOF 34 35 GOT=$(find . | sort) 36 37 if [ "$WANT" == "$GOT" ]; then 38 echo 'PASS' 39 else 40 echo "WANT:\n$WANT" 41 echo "GOT:\n$GOT" 42 exit 1 43 fi 44 """ 45 46 def _proto_gazelle_data_test_impl(ctx): 47 ctx.actions.write(ctx.outputs.executable, SCRIPT) 48 49 runfiles = ctx.runfiles().merge(ctx.attr.gazelle[DefaultInfo].default_runfiles) 50 51 return [DefaultInfo( 52 files = depset([ctx.outputs.executable]), 53 runfiles = runfiles, 54 )] 55 56 proto_gazelle_data_test = rule( 57 implementation = _proto_gazelle_data_test_impl, 58 attrs = { 59 "gazelle": attr.label( 60 providers = [DefaultInfo], 61 mandatory = True, 62 ), 63 "data": attr.label_list( 64 allow_files = True, 65 ), 66 }, 67 test = True, 68 )