From c7a9b52e71a68fef9445e0520fec3dfdfcae840a Mon Sep 17 00:00:00 2001 From: Alexey Andreev Date: Fri, 18 Oct 2024 12:52:02 +0200 Subject: [PATCH] wasm gc: copy auxiliary files when running tests --- .../junit/WebAssemblyGCPlatformSupport.java | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/tools/junit/src/main/java/org/teavm/junit/WebAssemblyGCPlatformSupport.java b/tools/junit/src/main/java/org/teavm/junit/WebAssemblyGCPlatformSupport.java index 568e27133..57d8b8ab5 100644 --- a/tools/junit/src/main/java/org/teavm/junit/WebAssemblyGCPlatformSupport.java +++ b/tools/junit/src/main/java/org/teavm/junit/WebAssemblyGCPlatformSupport.java @@ -26,6 +26,7 @@ import java.io.IOException; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.lang.reflect.AnnotatedElement; +import java.lang.reflect.Method; import java.nio.file.Files; import java.util.ArrayList; import java.util.List; @@ -208,4 +209,27 @@ class WebAssemblyGCPlatformSupport extends TestPlatformSupport { throw new RuntimeException(e); } } + + @Override + void additionalOutputForAllConfigurations(File outputPath, Method method) { + var annotations = new ArrayList(); + var list = method.getAnnotation(ServeJSList.class); + if (list != null) { + annotations.addAll(List.of(list.value())); + } + var single = method.getAnnotation(ServeJS.class); + if (single != null) { + annotations.add(single); + } + var loader = WebAssemblyGCPlatformSupport.class.getClassLoader(); + for (var item : annotations) { + var outputFile = new File(outputPath, item.as()); + try (var input = loader.getResourceAsStream(item.from()); + var output = new FileOutputStream(outputFile)) { + input.transferTo(output); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + } }