@@ -115,6 +115,45 @@ class WireCompilerTest {
115115 assertThat(logs).containsExactly(" artifactHandled(com.squareup.wire.protos.person.Person, Java)" )
116116 }
117117
118+ @Test
119+ fun runMultipleTargets () {
120+ val sources = arrayOf(" person.proto" )
121+
122+ val args = ArrayList <String >()
123+ args.add(TargetLanguage .JAVA .protoPathArg())
124+ args.add(TargetLanguage .JAVA .outArg(" /" .toPath() / testDir))
125+ args.add(TargetLanguage .KOTLIN .protoPathArg())
126+ args.add(TargetLanguage .KOTLIN .outArg(" /" .toPath() / testDir))
127+ args.add(" --no_kotlin_exclusive" )
128+ args.add(" --dry_run" )
129+ args.addAll(sources)
130+
131+ val logs = mutableListOf<String >()
132+ val logger = object : WireLogger {
133+ override fun artifactHandled (outputPath : Path , qualifiedName : String , targetName : String ) {
134+ logs.add(" artifactHandled($qualifiedName , $targetName )" )
135+ }
136+ override fun artifactSkipped (type : ProtoType , targetName : String ) = Unit
137+ override fun unusedRoots (unusedRoots : Set <String >) = Unit
138+ override fun unusedPrunes (unusedPrunes : Set <String >) = Unit
139+ override fun unusedIncludesInTarget (unusedIncludes : Set <String >) = Unit
140+ override fun unusedExcludesInTarget (unusedExcludes : Set <String >) = Unit
141+ }
142+ val fs = fileSystem
143+ val compiler = WireCompiler .forArgs(fs, logger, * args.toTypedArray<String >())
144+ compiler.compile()
145+
146+ // We assert nothing has been generated.
147+ assertJavaOutputs(arrayOf())
148+ assertKotlinOutputs(arrayOf())
149+ assertSwiftOutputs(arrayOf())
150+ // But we logged things because we're dry-running.
151+ assertThat(logs).containsExactly(
152+ " artifactHandled(com.squareup.wire.protos.person.Person, Kotlin)" ,
153+ " artifactHandled(com.squareup.wire.protos.person.Person, Java)" ,
154+ )
155+ }
156+
118157 @Test
119158 fun testPersonAndroid () {
120159 val sources = arrayOf(" person.proto" )
@@ -726,6 +765,9 @@ class WireCompilerTest {
726765 private fun assertKotlinOutputs (outputs : Array <String >, suffix : String = "") =
727766 assertOutputs(TargetLanguage .KOTLIN , outputs, suffix)
728767
768+ private fun assertSwiftOutputs (outputs : Array <String >, suffix : String = "") =
769+ assertOutputs(TargetLanguage .SWIFT , outputs, suffix)
770+
729771 private fun assertOutputs (target : TargetLanguage , outputs : Array <String >, suffix : String = "") {
730772 val filesAfter = paths
731773 assertThat(filesAfter.size)
@@ -770,6 +812,11 @@ class WireCompilerTest {
770812 override fun outArg (testDirPath : Path ) = " --kotlin_out=$testDirPath "
771813 override fun protoFolderSuffix () = " kotlin"
772814 },
815+ SWIFT {
816+ override fun protoPathArg () = " --proto_path=../wire-tests/src/commonTest/proto/kotlin"
817+ override fun outArg (testDirPath : Path ) = " --swift_out=$testDirPath "
818+ override fun protoFolderSuffix () = " swift"
819+ },
773820 ;
774821
775822 abstract fun protoPathArg (): String
0 commit comments