Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add test codifying behavior when two modules reuse the same extension number #171

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
buildscript { repositories { gradlePluginPortal() } }

plugins {
id("net.vivin.gradle-semantic-build-versioning") version "4.0.0"
id("io.alcide.gradle-semantic-build-versioning") version "4.2.2"
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was having trouble running Gradle locally. This fixed the issue and is the spiritual successor to the unmaintained original plugin we use currently.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't have experience with this plugin, but since it is now a fork of a fork we may encounter future ownership issues again at some point.

}

rootProject.name = "buf-gradle-plugin"
11 changes: 11 additions & 0 deletions src/test/kotlin/build/buf/gradle/AbstractBuildTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ package build.buf.gradle
import com.google.common.truth.Truth.assertThat
import org.gradle.testkit.runner.TaskOutcome.SUCCESS
import org.junit.jupiter.api.Test
import java.io.File
import java.nio.file.Paths

abstract class AbstractBuildTest : AbstractBufIntegrationTest() {
Expand Down Expand Up @@ -49,6 +50,16 @@ abstract class AbstractBuildTest : AbstractBufIntegrationTest() {
assertImageGeneration()
}

@Test
fun `build an image reusing an extension number`() {
val result = buildRunner().buildAndFail()
val source = listOf("buf", "test", "v1", "test.proto").joinToString(File.separator)
assertThat(result.output).contains(
"$source:23:14:extension with tag 1072 for message google.protobuf.MessageOptions already defined at " +
"validate/validate.proto:17:29",
)
}

private fun assertImageGeneration() {
assertThat(buildRunner().build().task(":$BUF_BUILD_TASK_NAME")?.outcome).isEqualTo(SUCCESS)
val image = Paths.get(projectDir.path, "build", "bufbuild", "image.json").toFile().readText()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
version: v1
deps:
- remote: buf.build
owner: envoyproxy
repository: protoc-gen-validate
commit: 71881f09a0c5420a9545a07987a86728
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
version: v1
deps:
- buf.build/envoyproxy/protoc-gen-validate
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// Copyright 2023 Buf Technologies, Inc.
//
// 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.

syntax = "proto3";

package buf.test.v1;

import "google/protobuf/descriptor.proto";
import "validate/validate.proto";

extend google.protobuf.MessageOptions {
bool foo = 1072;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
plugins {
id 'java'
id 'build.buf'
}

repositories {
mavenCentral()
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
plugins {
id 'java'
id 'com.google.protobuf' version "$protobufGradleVersion"
id 'build.buf'
}

repositories {
mavenCentral()
}

protobuf {
protoc {
artifact = "com.google.protobuf:protoc:$protobufVersion"
}
}

dependencies {
protobuf 'io.envoyproxy.controlplane:api:1.0.41'
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// Copyright 2023 Buf Technologies, Inc.
//
// 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.

syntax = "proto3";

package buf.test.v1;

import "google/protobuf/descriptor.proto";
import "validate/validate.proto";

extend google.protobuf.MessageOptions {
bool foo = 1072;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
version: v1
directories:
- workspace
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
plugins {
id 'java'
id 'build.buf'
}

repositories {
mavenCentral()
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
version: v1
deps:
- remote: buf.build
owner: envoyproxy
repository: protoc-gen-validate
commit: 71881f09a0c5420a9545a07987a86728
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
version: v1
deps:
- buf.build/envoyproxy/protoc-gen-validate
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// Copyright 2023 Buf Technologies, Inc.
//
// 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.

syntax = "proto3";

package buf.test.v1;

import "google/protobuf/descriptor.proto";
import "validate/validate.proto";

extend google.protobuf.MessageOptions {
bool foo = 1072;
}