1515@_spi ( Testing) import SwiftJava
1616import SwiftJavaToolLib
1717import JavaUtilJar
18+ import SwiftJavaShared
1819import _Subprocess
1920import XCTest // NOTE: Workaround for https://github.com/swiftlang/swift-java/issues/43
2021
@@ -69,16 +70,19 @@ class WrapJavaTests: XCTestCase {
6970 package com.example;
7071
7172 class ByteArray {}
72- // class CompressingStore extends AbstractStore<ByteArray, byte[], byte[]> {}
73- abstract class AbstractStore<K, V, T> implements Store<K, V, T> {}
74- interface Store<K, V, T> {}
73+ class CompressingStore extends AbstractStore<ByteArray, byte[], byte[]> {}
74+ abstract class AbstractStore<K, V, T> {} // implements Store<K, V, T> {}
75+ // interface Store<K, V, T> {}
7576
7677 """ )
7778
7879 try assertWrapJavaOutput (
7980 javaClassNames: [
8081 " com.example.ByteArray " ,
81- " com.example.Store " ,
82+ // TODO: what if we visit in other order, does the wrap-java handle it
83+ // "com.example.Store",
84+ " com.example.AbstractStore " ,
85+ " com.example.CompressingStore " ,
8286 ] ,
8387 classpath: [ classpathURL] ,
8488 expectedChunks: [
@@ -93,6 +97,10 @@ class WrapJavaTests: XCTestCase {
9397 """
9498 @JavaInterface( " com.example.Store " )
9599 public struct Store<K: AnyJavaObject, V: AnyJavaObject, T: AnyJavaObject> {
100+ """ ,
101+ """
102+ @JavaClass( " com.example.CompressingStore " )
103+ open class CompressingStore: AbstractStore {
96104 """
97105 ]
98106 )
@@ -133,6 +141,7 @@ func compileJava(_ sourceText: String) async throws -> URL {
133141 " ERROR: \( errString) " )
134142 }
135143
144+ print ( " Compiled java sources to: \( classesDirectory) " )
136145 return classesDirectory
137146}
138147
@@ -189,10 +198,11 @@ func assertWrapJavaOutput(
189198
190199 let swiftFileText =
191200 """
201+ // ---------------------------------------------------------------------------
192202 // Auto-generated by Java-to-Swift wrapper generator.
193203 \( importDecls. map { $0. description } . joined ( ) )
194204 \( swiftClassDecls. map { $0. description } . joined ( separator: " \n " ) )
195-
205+ \n
196206 """
197207 swiftCompleteOutputText += swiftFileText
198208 }
@@ -202,10 +212,13 @@ func assertWrapJavaOutput(
202212 continue
203213 }
204214
205- XCTFail ( " Expected chunk ' \( expectedChunk) ' not found in ' \( swiftCompleteOutputText) ' " ,
215+ XCTFail ( " Expected chunk: \n " +
216+ " \( expectedChunk. yellow) " +
217+ " \n " +
218+ " not found in: \n " +
219+ " \( swiftCompleteOutputText) " ,
206220 file: file, line: line)
207221 }
208222
209- print ( " ============================================= " )
210223 print ( swiftCompleteOutputText)
211224}
0 commit comments