Skip to content

Commit

Permalink
Move stuff to e2e-nojava
Browse files Browse the repository at this point in the history
  • Loading branch information
thesamet committed Sep 27, 2020
1 parent 9ca4808 commit 4978be1
Show file tree
Hide file tree
Showing 86 changed files with 682 additions and 544 deletions.
2 changes: 2 additions & 0 deletions TODO
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
comments need to split out service

67 changes: 53 additions & 14 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ lazy val compilerPlugin = (projectMatrix in file("compiler-plugin"))
protocGen.withDottyCompat(scalaVersion.value),
"com.google.protobuf" % "protobuf-java" % protobufCompilerVersion % "protobuf",
(coursier % "test").withDottyCompat(scalaVersion.value),
scalaTest % "test"
scalaTest.value % "test"
),
mimaPreviousArtifacts := Set("com.thesamet.scalapb" %% "compilerplugin" % MimaPreviousVersion),
mimaBinaryIssueFilters := Seq(
Expand Down Expand Up @@ -210,8 +210,8 @@ lazy val proptest = (projectMatrix in file("proptest"))
protobufJava,
grpcNetty % "test",
grpcProtobuf % "test",
scalaTest % "test",
scalaTestPlusScalaCheck % "test"
scalaTest.value % "test",
scalaTestPlusScalaCheck.value % "test"
),
scalacOptions ++= (if (!isDotty.value)
Seq(
Expand Down Expand Up @@ -262,25 +262,24 @@ val e2eCommonSettings = commonSettings ++ Seq(
grpcServices,
grpcServices % "protobuf",
annotationApi,
grpcProtocGen asProtocPlugin,
(scalaTest % "test"),
(scalaTestPlusScalaCheck % "test")
(scalaTest.value % "test"),
(scalaTestPlusScalaCheck.value % "test")
),
Test / fork := true, // For https://github.com/scala/bug/issues/9237
Compile / PB.recompile := true // always regenerate protos, not cache
Compile / PB.recompile := true, // always regenerate protos, not cache
codeGenClasspath := (compilerPluginJVM2_12 / Compile / fullClasspath).value
)

lazy val e2e = (projectMatrix in file("e2e"))
lazy val e2eGrpc = (projectMatrix in file("e2e-grpc"))
.defaultAxes()
.dependsOn(runtime, grpcRuntime)
.enablePlugins(LocalCodeGenPlugin)
.jvmPlatform(Seq(Scala212, Scala213, Dotty))
.settings(e2eCommonSettings)
.settings(
libraryDependencies += (grpcProtocGen asProtocPlugin),
scalacOptions ++= (if (!isDotty.value)
Seq(
"-P:silencer:globalFilters=value deprecatedInt32 in class TestDeprecatedFields is deprecated",
"-P:silencer:pathFilters=custom_options_use;CustomAnnotationProto.scala;changed/scoped;ServerReflectionGrpc.scala;ReflectionProto.scala;TestDeprecatedFields.scala",
"-P:silencer:pathFilters=ServerReflectionGrpc.scala;ReflectionProto.scala",
"-P:silencer:lineContentFilters=import com.thesamet.pb.MisplacedMapper.weatherMapper"
)
else Nil),
Expand All @@ -294,19 +293,59 @@ lazy val e2e = (projectMatrix in file("e2e"))
codeGenClasspath := (compilerPluginJVM2_12 / Compile / fullClasspath).value
)

lazy val e2eNoJava = (projectMatrix in file("e2e-nojava"))
lazy val e2eWithJava = (projectMatrix in file("e2e-withjava"))
.defaultAxes()
.dependsOn(runtime)
.enablePlugins(LocalCodeGenPlugin)
.jvmPlatform(Seq(Scala212, Scala213, Dotty))
.settings(e2eCommonSettings)
.settings(
scalacOptions ++= (if (!isDotty.value)
Seq(
"-P:silencer:lineContentFilters=import com.thesamet.pb.MisplacedMapper.weatherMapper"
)
else Nil),
)
.jvmPlatform(Seq(Scala212, Scala213, Dotty), settings=Seq(
Compile / PB.targets := Seq(
PB.gens.java(versions.protobuf) -> (Compile / sourceManaged).value,
(genModule("scalapb.ScalaPbCodeGenerator$"), Seq("java_conversions")) -> (Compile / sourceManaged).value
)
))
.jsPlatform(Seq(Scala212, Scala213), settings=Seq(
Compile / PB.includePaths += (ThisBuild / baseDirectory).value / "protobuf",
Compile / PB.targets := Seq(
(genModule("scalapb.ScalaPbCodeGenerator$")) -> (Compile / sourceManaged).value
)
))

lazy val e2e = (projectMatrix in file("e2e"))
.defaultAxes()
.dependsOn(runtime, e2eWithJava)
.enablePlugins(LocalCodeGenPlugin)
.jvmPlatform(Seq(Scala212, Scala213, Dotty), settings=Seq(
Test / unmanagedSourceDirectories += (Test / scalaSource).value.getParentFile / (if (isDotty.value)
"scalajvm-3"
else
"scalajvm-2"),
)
)
.jsPlatform(Seq(Scala212, Scala213), settings=Seq(
Compile / PB.includePaths += (ThisBuild / baseDirectory).value / "protobuf"
))
.settings(e2eCommonSettings)
.settings(
scalacOptions ++= (if (!isDotty.value)
Seq(
"-P:silencer:globalFilters=value deprecatedInt32 in class TestDeprecatedFields is deprecated",
"-P:silencer:pathFilters=custom_options_use;CustomAnnotationProto.scala;TestDeprecatedFields.scala",
"-P:silencer:lineContentFilters=import com.thesamet.pb.MisplacedMapper.weatherMapper"
)
else Nil),
PB.protocVersion := versions.protobuf,
Compile / PB.protocOptions += "--experimental_allow_proto3_optional",
Compile / PB.targets := Seq(
genModule("scalapb.ScalaPbCodeGenerator$") -> (Compile / sourceManaged).value
),
codeGenClasspath := (compilerPluginJVM2_12 / Compile / fullClasspath).value
)

lazy val docs = project
Expand Down
15 changes: 15 additions & 0 deletions e2e-grpc/src/main/protobuf/comments.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
syntax = "proto3";

package com.thesamet.proto.e2e;

import "scalapb/scalapb.proto";

option (scalapb.options).retain_source_code_info = true;

message Foo {}

// a commented service
service CommentedService {
// a commented RPC
rpc CommentedRPC (Foo) returns (Foo) {}
}
File renamed without changes.
1 change: 1 addition & 0 deletions e2e-grpc/src/main/protobuf/type_level.proto
1 change: 1 addition & 0 deletions e2e-grpc/src/main/protobuf/well_known.proto
1 change: 1 addition & 0 deletions e2e-grpc/src/main/scala/Point2D.scala
File renamed without changes.
21 changes: 21 additions & 0 deletions e2e-grpc/src/test/scala/ServiceDescriptorSpec.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import org.scalatest._
import org.scalatest.flatspec.AnyFlatSpec
import org.scalatest.matchers.must.Matchers
import com.thesamet.proto.e2e.service.Service1Grpc.Service1
import com.thesamet.proto.e2e.comments.CommentedServiceGrpc.CommentedService

class ScalaDescriptorSpec extends AnyFlatSpec with Matchers with LoneElement with OptionValues {
"scalaDescriptor" must "contain methods" in {
Service1.scalaDescriptor.fullName must be("com.thesamet.proto.e2e.Service1")
val method = Service1.scalaDescriptor.methods.find(_.name == "SealedUnary").get
method.fullName must be("com.thesamet.proto.e2e.Service1.SealedUnary")
}

"commentedService" must "contain descriptor comments" in {
val serviceLocation = CommentedService.scalaDescriptor.location.get
val methodLocation = CommentedService.scalaDescriptor.methods(0).location.get
serviceLocation.getLeadingComments must be(" a commented service\n")

methodLocation.getLeadingComments must be(" a commented RPC\n")
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,10 @@ object Years {

object FullName {
implicit val mapper: TypeMapper[Name, FullName] = TypeMapper[Name, FullName](n => FullName(n.getFirst, n.getLast))(fn =>
Name(first = Some(fn.firstName), last = Some(fn.lastName))
)
Name(
first = if (fn.firstName != "EMPTY") Some(fn.firstName) else None,
last = if (fn.lastName != "EMPTY") Some(fn.lastName) else None,
))

implicit val mapperNoBox: TypeMapper[NameNoBox, FullName] = TypeMapper[NameNoBox, FullName](n => FullName(n.first, n.last))(fn =>
NameNoBox(first = fn.firstName, last = fn.lastName)
Expand Down
5 changes: 0 additions & 5 deletions e2e/project/scalapb.sbt

This file was deleted.

6 changes: 0 additions & 6 deletions e2e/src/main/protobuf/comments.proto
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,3 @@ message Foo {
}
};
// and here

// a commented service
service CommentedService {
// a commented RPC
rpc CommentedRPC (Foo) returns (Foo) {}
}
2 changes: 0 additions & 2 deletions e2e/src/main/protobuf/issue286.proto
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ syntax = "proto2";

import "scalapb/scalapb.proto";

option (scalapb.options).test_only_no_java_conversions = true;

message TopFoo {
optional int32 a = 1;
}
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ syntax = "proto2";

import "scalapb/scalapb.proto";

option (scalapb.options).test_only_no_java_conversions = true;

message TopFoo {
optional int32 a = 1;
}
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
1 change: 0 additions & 1 deletion e2e/src/main/protobuf/scoped/package.proto
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import "scalapb/scalapb.proto";

option (scalapb.options) = {
scope: PACKAGE
import: "scala.concurrent.ExecutionContext"
collection_type: "Set"
preamble: "/* preamble 1*/"
single_file: true
Expand Down
120 changes: 0 additions & 120 deletions e2e/src/test/resources/text_format_unittest_data_oneof_implemented.txt

This file was deleted.

6 changes: 0 additions & 6 deletions e2e/src/test/scala/CollectionTypesSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ class CollectionTypesSpec extends AnyFlatSpec with Matchers {
val c = CustomCollection(repeatedInt32 = MyVector(Vector(11, 24, 19)))
CustomCollection.parseFrom(c.toByteArray) must be(c)
CustomCollection.fromAscii(c.toProtoString) must be(c)
CustomCollection.fromJavaProto(CustomCollection.toJavaProto(c)) must be(c)
}

// See https://github.com/scalapb/ScalaPB/issues/274
Expand All @@ -42,9 +41,4 @@ class CollectionTypesSpec extends AnyFlatSpec with Matchers {
CollectionTypesMap.parseFrom(m.toByteArray) must be(m)
m.mapInt32Bool += (3 -> true)
}

"custom maps" should "convertible to and from Java" in {
val m = CollectionTypesMap(mymapInt32Bool = MyMap(Map(3 -> true, 4 -> false)))
CollectionTypesMap.fromJavaProto(CollectionTypesMap.toJavaProto(m)) must be(m)
}
}
9 changes: 2 additions & 7 deletions e2e/src/test/scala/CommentsSpec.scala
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import com.thesamet.proto.e2e.comments.CommentedServiceGrpc.CommentedService
import com.thesamet.proto.e2e.comments._
import org.scalatest.flatspec.AnyFlatSpec
import org.scalatest.matchers.must.Matchers
Expand All @@ -12,8 +11,6 @@ class CommentsSpec extends AnyFlatSpec with Matchers {
val enumLocation = Foo.Bar.scalaDescriptor.enums(0).location.get
val enumXyzLocation = Foo.Bar.MyBarEnum.XYZ.scalaValueDescriptor.location.get
val enumDefLocation = Foo.Bar.MyBarEnum.DEF.scalaValueDescriptor.location.get
val serviceLocation = CommentedService.scalaDescriptor.location.get
val methodLocation = CommentedService.scalaDescriptor.methods(0).location.get

fooLocation.getLeadingComments must be(" This is the foo comment\n")

Expand All @@ -31,9 +28,7 @@ class CommentsSpec extends AnyFlatSpec with Matchers {

enumDefLocation.getLeadingComments must be(" Def comment\n")

serviceLocation.getLeadingComments must be(" a commented service\n")

methodLocation.getLeadingComments must be(" a commented RPC\n")

// See also ScalaDescriptorSpec in e2e-grpc for service and method
// comments.
}
}
Loading

0 comments on commit 4978be1

Please sign in to comment.