diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 0140486f..8d66b63c 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -48,7 +48,6 @@ jobs: with: languages: ${{ matrix.language }} - - name: Autobuild uses: github/codeql-action/autobuild@4355270be187e1b672a7a1c7c7bae5afdc1ab94a # v3.24.10 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml deleted file mode 100644 index 927d5c56..00000000 --- a/.github/workflows/test.yml +++ /dev/null @@ -1,33 +0,0 @@ -on: [push] -name: Test -jobs: - test: - strategy: - matrix: - # This is just a version to compile the integration_test.go; see - # golangVersions in that file for the list of actual Go versions used. - go-version: [1.x] - os: [ubuntu-latest] # TODO: Add [macos-latest, windows-latest] - runs-on: ${{ matrix.os }} - steps: - - name: Install Linux dependencies - if: runner.os == 'Linux' - run: sudo apt-get -y install autoconf automake libtool curl make g++ unzip - - name: Checkout code - uses: actions/checkout@v3 - - name: Install Go - uses: actions/setup-go@v4 - with: - go-version: ${{ matrix.go-version }} - - name: Cache dependencies - uses: actions/cache@v3 - with: - path: | - .cache - ~/.cache/bazel - key: ${{ runner.os }}-${{ hashFiles('integration_test.go') }} - - name: Test - env: - # Protobuf 25 does not yet support Bazel 7 - USE_BAZEL_VERSION: latest-1 - run: go test -run='^TestIntegration$' -v -timeout=60m -count=1 -failfast "$@" diff --git a/cmd/protoc-gen-go/annotation_test.go b/cmd/protoc-gen-go/annotation_test.go deleted file mode 100644 index 0e880aa0..00000000 --- a/cmd/protoc-gen-go/annotation_test.go +++ /dev/null @@ -1,100 +0,0 @@ -// Copyright 2018 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package main - -import ( - "bytes" - "os" - "testing" - - "github.com/aperturerobotics/protobuf-go-lite/internal/genid" - "github.com/google/go-cmp/cmp" - "google.golang.org/protobuf/encoding/prototext" - "google.golang.org/protobuf/proto" - "google.golang.org/protobuf/testing/protocmp" - - "google.golang.org/protobuf/types/descriptorpb" -) - -func TestAnnotations(t *testing.T) { - sourceFile, err := os.ReadFile("testdata/annotations/annotations.pb.go") - if err != nil { - t.Fatal(err) - } - metaFile, err := os.ReadFile("testdata/annotations/annotations.pb.go.meta") - if err != nil { - t.Fatal(err) - } - gotInfo := &descriptorpb.GeneratedCodeInfo{} - if err := prototext.Unmarshal(metaFile, gotInfo); err != nil { - t.Fatalf("can't parse meta file: %v", err) - } - - wantInfo := &descriptorpb.GeneratedCodeInfo{} - for _, want := range []struct { - prefix, text, suffix string - annotation *descriptorpb.GeneratedCodeInfo_Annotation - }{{ - "type ", "AnnotationsTestEnum", " int32", - &descriptorpb.GeneratedCodeInfo_Annotation{ - Path: []int32{int32(genid.FileDescriptorProto_EnumType_field_number), 0}, - }, - }, { - "\t", "AnnotationsTestEnum_ANNOTATIONS_TEST_ENUM_VALUE", " AnnotationsTestEnum = 0", - &descriptorpb.GeneratedCodeInfo_Annotation{ - Path: []int32{int32(genid.FileDescriptorProto_EnumType_field_number), 0, int32(genid.EnumDescriptorProto_Value_field_number), 0}, - }, - }, { - "type ", "AnnotationsTestMessage", " struct {", - &descriptorpb.GeneratedCodeInfo_Annotation{ - Path: []int32{int32(genid.FileDescriptorProto_MessageType_field_number), 0}, - }, - }, { - "\t", "AnnotationsTestField", " ", - &descriptorpb.GeneratedCodeInfo_Annotation{ - Path: []int32{int32(genid.FileDescriptorProto_MessageType_field_number), 0, int32(genid.DescriptorProto_Field_field_number), 0}, - }, - }, { - "\t", "XXX_weak_M", " ", - &descriptorpb.GeneratedCodeInfo_Annotation{ - Path: []int32{int32(genid.FileDescriptorProto_MessageType_field_number), 0, int32(genid.DescriptorProto_Field_field_number), 1}, - }, - }, { - "func (x *AnnotationsTestMessage) ", "GetAnnotationsTestField", "() string {", - &descriptorpb.GeneratedCodeInfo_Annotation{ - Path: []int32{int32(genid.FileDescriptorProto_MessageType_field_number), 0, int32(genid.DescriptorProto_Field_field_number), 0}, - }, - }, { - "func (x *AnnotationsTestMessage) ", "GetM", "() proto.Message {", - &descriptorpb.GeneratedCodeInfo_Annotation{ - Path: []int32{int32(genid.FileDescriptorProto_MessageType_field_number), 0, int32(genid.DescriptorProto_Field_field_number), 1}, - }, - }, { - "func (x *AnnotationsTestMessage) ", "SetM", "(v proto.Message) {", - &descriptorpb.GeneratedCodeInfo_Annotation{ - Path: []int32{int32(genid.FileDescriptorProto_MessageType_field_number), 0, int32(genid.DescriptorProto_Field_field_number), 1}, - Semantic: descriptorpb.GeneratedCodeInfo_Annotation_SET.Enum(), - }, - }} { - s := want.prefix + want.text + want.suffix - pos := bytes.Index(sourceFile, []byte(s)) - if pos < 0 { - t.Errorf("source file does not contain: %v", s) - continue - } - begin := pos + len(want.prefix) - end := begin + len(want.text) - a := &descriptorpb.GeneratedCodeInfo_Annotation{ - Begin: proto.Int32(int32(begin)), - End: proto.Int32(int32(end)), - SourceFile: proto.String("cmd/protoc-gen-go/testdata/annotations/annotations.proto"), - } - proto.Merge(a, want.annotation) - wantInfo.Annotation = append(wantInfo.Annotation, a) - } - if diff := cmp.Diff(wantInfo, gotInfo, protocmp.Transform()); diff != "" { - t.Fatalf("unexpected annotations for annotations.proto (-want +got):\n%s", diff) - } -} diff --git a/compiler/protogen/protogen_test.go b/compiler/protogen/protogen_test.go index 2efbfc46..2f11c2b2 100644 --- a/compiler/protogen/protogen_test.go +++ b/compiler/protogen/protogen_test.go @@ -315,7 +315,7 @@ var _ = string1.X // "golang.org/z/string" if err != nil { t.Fatalf("g.Content() = %v", err) } - if diff := cmp.Diff(want, got); diff != "" { + if diff := cmp.Diff(want, string(got)); diff != "" { t.Fatalf("content mismatch (-want +got):\n%s", diff) } } @@ -344,7 +344,7 @@ var _ = bar.X if err != nil { t.Fatalf("g.Content() = %v", err) } - if diff := cmp.Diff(want, got); diff != "" { + if diff := cmp.Diff(want, string(got)); diff != "" { t.Fatalf("content mismatch (-want +got):\n%s", diff) } }