From cd74b73df40c4998f26ac1051962ba205aacd91a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D0=BB=D0=B5=D0=BA=D1=81=D0=B0=D0=BD=D0=B4=D1=8A?= =?UTF-8?q?=D1=80=20=D0=9A=D1=83=D1=80=D1=82=D0=B0=D0=BA=D0=BE=D0=B2?= Date: Fri, 20 Sep 2024 15:52:35 +0300 Subject: [PATCH] Reduce split packages in o.e.tests Split packages cause a lot of troubles and this is test harness code so it's better to live without them. --- .../org.eclipse.test.performance/.classpath | 6 +- .../META-INF/MANIFEST.MF | 8 +- .../eclipse/test/internal/AwtScreenshot.java | 133 ------------------ .../org.eclipse.test/META-INF/MANIFEST.MF | 3 +- .../src/org/eclipse/test/AwtScreenshot.java | 119 ++++++++++++++-- .../org/eclipse/test/OrderedTestSuite.java | 0 .../src/org/eclipse/test/Screenshots.java | 1 - .../src/org/eclipse/test/TracingSuite.java | 0 8 files changed, 115 insertions(+), 155 deletions(-) delete mode 100644 eclipse.platform.releng/bundles/org.eclipse.test.performance/src/org/eclipse/test/internal/AwtScreenshot.java rename eclipse.platform.releng/bundles/{org.eclipse.test.performance => org.eclipse.test}/src/org/eclipse/test/OrderedTestSuite.java (100%) rename eclipse.platform.releng/bundles/{org.eclipse.test.performance => org.eclipse.test}/src/org/eclipse/test/Screenshots.java (98%) rename eclipse.platform.releng/bundles/{org.eclipse.test.performance => org.eclipse.test}/src/org/eclipse/test/TracingSuite.java (100%) diff --git a/eclipse.platform.releng/bundles/org.eclipse.test.performance/.classpath b/eclipse.platform.releng/bundles/org.eclipse.test.performance/.classpath index d27357c0fa2..a29b56b56e2 100644 --- a/eclipse.platform.releng/bundles/org.eclipse.test.performance/.classpath +++ b/eclipse.platform.releng/bundles/org.eclipse.test.performance/.classpath @@ -1,7 +1,11 @@ - + + + + + diff --git a/eclipse.platform.releng/bundles/org.eclipse.test.performance/META-INF/MANIFEST.MF b/eclipse.platform.releng/bundles/org.eclipse.test.performance/META-INF/MANIFEST.MF index ece19e7ddd8..1097a3d99ed 100644 --- a/eclipse.platform.releng/bundles/org.eclipse.test.performance/META-INF/MANIFEST.MF +++ b/eclipse.platform.releng/bundles/org.eclipse.test.performance/META-INF/MANIFEST.MF @@ -6,18 +6,18 @@ Bundle-Version: 3.20.300.qualifier Bundle-Activator: org.eclipse.test.internal.performance.PerformanceTestPlugin Bundle-Vendor: %Plugin.providerName Bundle-Localization: plugin +Import-Package: org.junit.jupiter.api, + org.junit.platform.suite.api, + org.eclipse.test Export-Package: org.eclipse.perfmsr.core, - org.eclipse.test, - org.eclipse.test.internal;x-internal:=true, org.eclipse.test.internal.performance, org.eclipse.test.internal.performance.data, org.eclipse.test.internal.performance.db, org.eclipse.test.internal.performance.eval, org.eclipse.test.internal.performance.tests, org.eclipse.test.performance -Import-Package: org.junit.jupiter.api, - org.junit.platform.suite.api Require-Bundle: org.eclipse.core.runtime, + org.eclipse.test;visibility:=reexport, org.junit Bundle-ActivationPolicy: lazy Bundle-ClassPath: . diff --git a/eclipse.platform.releng/bundles/org.eclipse.test.performance/src/org/eclipse/test/internal/AwtScreenshot.java b/eclipse.platform.releng/bundles/org.eclipse.test.performance/src/org/eclipse/test/internal/AwtScreenshot.java deleted file mode 100644 index b9c4628465b..00000000000 --- a/eclipse.platform.releng/bundles/org.eclipse.test.performance/src/org/eclipse/test/internal/AwtScreenshot.java +++ /dev/null @@ -1,133 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2015, 2016 IBM Corporation and others. - * - * This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ - -package org.eclipse.test.internal; - -import java.awt.AWTException; -import java.awt.HeadlessException; -import java.awt.Rectangle; -import java.awt.Robot; -import java.awt.Toolkit; -import java.awt.image.BufferedImage; -import java.io.BufferedReader; -import java.io.File; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.io.PrintStream; -import java.net.URISyntaxException; -import java.net.URL; - -import javax.imageio.ImageIO; - -public class AwtScreenshot { - - private static final int TIMEOUT_SECONDS = 15; - - public static void main(String[] args) { - try { - System.setProperty("java.awt.headless", "false"); - Robot robot = new Robot(); - Rectangle rect = new Rectangle(Toolkit.getDefaultToolkit().getScreenSize()); - BufferedImage image = robot.createScreenCapture(rect); - File file = new File(args[0]); - ImageIO.write(image, "png", file); - - System.out.println("AWT screenshot saved to: " + file.getAbsolutePath()); - } catch (HeadlessException | AWTException | IOException e) { - e.printStackTrace(); - } - } - - static class StreamForwarder extends Thread { - - private InputStream fProcessOutput; - - private PrintStream fStream; - - public StreamForwarder(InputStream processOutput, PrintStream stream) { - fProcessOutput = processOutput; - fStream = stream; - } - - @Override - public void run() { - try (BufferedReader reader = new BufferedReader(new InputStreamReader(fProcessOutput))) { - String line = null; - while ((line = reader.readLine()) != null) { - fStream.println(line); - } - } catch (IOException e) { - e.printStackTrace(); - } - } - } - - public static void dumpAwtScreenshot(String screenshotFile) { - try { - URL location = AwtScreenshot.class.getProtectionDomain().getCodeSource().getLocation(); - String cp = location.toURI().getPath(); - if (new File(cp).isDirectory() && !cp.endsWith(File.separatorChar + "bin" + File.separatorChar)) { - cp += "bin" + File.separatorChar; - } - String javaHome = System.getProperty("java.home"); - String javaExe = javaHome + File.separatorChar + "bin" + File.separatorChar + "java"; - if (File.separatorChar == '\\') { - javaExe += ".exe"; // assume it's Windows - } - String[] args = new String[] { javaExe, "-cp", cp, AwtScreenshot.class.getName(), screenshotFile }; - // System.out.println("Start process: " + Arrays.asList(args)); - ProcessBuilder processBuilder = new ProcessBuilder(args); - if ("Mac OS X".equals(System.getProperty("os.name"))) { - processBuilder.environment().put("AWT_TOOLKIT", "CToolkit"); - } - Process process = processBuilder.start(); - - @SuppressWarnings("resource") // never close process streams - InputStream errorStream = process.getErrorStream(); - - @SuppressWarnings("resource") // never close process streams - InputStream inputStream = process.getInputStream(); - - new StreamForwarder(errorStream, System.out).start(); - new StreamForwarder(inputStream, System.out).start(); - long end = System.currentTimeMillis() + TIMEOUT_SECONDS * 1000; - boolean done = false; - do { - try { - process.exitValue(); - done = true; - } catch (IllegalThreadStateException e) { - try { - Thread.sleep(100); - } catch (InterruptedException e1) { - // continue - } - } - } while (!done && System.currentTimeMillis() < end); - - if (done) { - int exitCode = process.exitValue(); - if (exitCode != 0) { - System.out.println("AwtScreenshot VM finished with exit code " + exitCode + "."); - } - } else { - process.destroy(); - System.out.println("Killed AwtScreenshot VM after " + TIMEOUT_SECONDS + " seconds."); - } - } catch (URISyntaxException | IOException e) { - e.printStackTrace(); - } - } -} diff --git a/eclipse.platform.releng/bundles/org.eclipse.test/META-INF/MANIFEST.MF b/eclipse.platform.releng/bundles/org.eclipse.test/META-INF/MANIFEST.MF index 023bf7a2f30..f2ab114d6cf 100644 --- a/eclipse.platform.releng/bundles/org.eclipse.test/META-INF/MANIFEST.MF +++ b/eclipse.platform.releng/bundles/org.eclipse.test/META-INF/MANIFEST.MF @@ -10,7 +10,8 @@ Require-Bundle: org.apache.ant, org.eclipse.ui;bundle-version="[3.112.0,4.0.0)", org.eclipse.core.runtime, org.eclipse.ui.ide.application, - org.eclipse.equinox.app + org.eclipse.equinox.app, + org.junit Import-Package: org.junit.jupiter.api, org.junit.platform.engine, org.junit.platform.engine.discovery, diff --git a/eclipse.platform.releng/bundles/org.eclipse.test/src/org/eclipse/test/AwtScreenshot.java b/eclipse.platform.releng/bundles/org.eclipse.test/src/org/eclipse/test/AwtScreenshot.java index 3145589ff51..7f0558beb57 100644 --- a/eclipse.platform.releng/bundles/org.eclipse.test/src/org/eclipse/test/AwtScreenshot.java +++ b/eclipse.platform.releng/bundles/org.eclipse.test/src/org/eclipse/test/AwtScreenshot.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2015, 2017 IBM Corporation and others. + * Copyright (c) 2015, 2016 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -11,6 +11,7 @@ * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ + package org.eclipse.test; import java.awt.AWTException; @@ -19,26 +20,114 @@ import java.awt.Robot; import java.awt.Toolkit; import java.awt.image.BufferedImage; +import java.io.BufferedReader; import java.io.File; import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.PrintStream; +import java.net.URISyntaxException; +import java.net.URL; import javax.imageio.ImageIO; public class AwtScreenshot { - public static void main(String[] args) { - try { - System.setProperty("java.awt.headless", "false"); - Robot robot = new Robot(); - Rectangle rect = new Rectangle(Toolkit.getDefaultToolkit().getScreenSize()); - BufferedImage image = robot.createScreenCapture(rect); - File file = new File(args[0]); - ImageIO.write(image, "png", file); - - System.out.println("AWT screenshot saved to: " + file.getAbsolutePath()); - } catch (HeadlessException | AWTException | IOException e) { - e.printStackTrace(); - } - } + private static final int TIMEOUT_SECONDS = 15; + + public static void main(String[] args) { + try { + System.setProperty("java.awt.headless", "false"); + Robot robot = new Robot(); + Rectangle rect = new Rectangle(Toolkit.getDefaultToolkit().getScreenSize()); + BufferedImage image = robot.createScreenCapture(rect); + File file = new File(args[0]); + ImageIO.write(image, "png", file); + + System.out.println("AWT screenshot saved to: " + file.getAbsolutePath()); + } catch (HeadlessException | AWTException | IOException e) { + e.printStackTrace(); + } + } + + static class StreamForwarder extends Thread { + + private InputStream fProcessOutput; + + private PrintStream fStream; + + public StreamForwarder(InputStream processOutput, PrintStream stream) { + fProcessOutput = processOutput; + fStream = stream; + } + + @Override + public void run() { + try (BufferedReader reader = new BufferedReader(new InputStreamReader(fProcessOutput))) { + String line = null; + while ((line = reader.readLine()) != null) { + fStream.println(line); + } + } catch (IOException e) { + e.printStackTrace(); + } + } + } + + public static void dumpAwtScreenshot(String screenshotFile) { + try { + URL location = AwtScreenshot.class.getProtectionDomain().getCodeSource().getLocation(); + String cp = location.toURI().getPath(); + if (new File(cp).isDirectory() && !cp.endsWith(File.separatorChar + "bin" + File.separatorChar)) { + cp += "bin" + File.separatorChar; + } + String javaHome = System.getProperty("java.home"); + String javaExe = javaHome + File.separatorChar + "bin" + File.separatorChar + "java"; + if (File.separatorChar == '\\') { + javaExe += ".exe"; // assume it's Windows + } + String[] args = new String[] { javaExe, "-cp", cp, AwtScreenshot.class.getName(), screenshotFile }; + // System.out.println("Start process: " + Arrays.asList(args)); + ProcessBuilder processBuilder = new ProcessBuilder(args); + if ("Mac OS X".equals(System.getProperty("os.name"))) { + processBuilder.environment().put("AWT_TOOLKIT", "CToolkit"); + } + Process process = processBuilder.start(); + + @SuppressWarnings("resource") // never close process streams + InputStream errorStream = process.getErrorStream(); + + @SuppressWarnings("resource") // never close process streams + InputStream inputStream = process.getInputStream(); + + new StreamForwarder(errorStream, System.out).start(); + new StreamForwarder(inputStream, System.out).start(); + long end = System.currentTimeMillis() + TIMEOUT_SECONDS * 1000; + boolean done = false; + do { + try { + process.exitValue(); + done = true; + } catch (IllegalThreadStateException e) { + try { + Thread.sleep(100); + } catch (InterruptedException e1) { + // continue + } + } + } while (!done && System.currentTimeMillis() < end); + if (done) { + int exitCode = process.exitValue(); + if (exitCode != 0) { + System.out.println("AwtScreenshot VM finished with exit code " + exitCode + "."); + } + } else { + process.destroy(); + System.out.println("Killed AwtScreenshot VM after " + TIMEOUT_SECONDS + " seconds."); + } + } catch (URISyntaxException | IOException e) { + e.printStackTrace(); + } + } } diff --git a/eclipse.platform.releng/bundles/org.eclipse.test.performance/src/org/eclipse/test/OrderedTestSuite.java b/eclipse.platform.releng/bundles/org.eclipse.test/src/org/eclipse/test/OrderedTestSuite.java similarity index 100% rename from eclipse.platform.releng/bundles/org.eclipse.test.performance/src/org/eclipse/test/OrderedTestSuite.java rename to eclipse.platform.releng/bundles/org.eclipse.test/src/org/eclipse/test/OrderedTestSuite.java diff --git a/eclipse.platform.releng/bundles/org.eclipse.test.performance/src/org/eclipse/test/Screenshots.java b/eclipse.platform.releng/bundles/org.eclipse.test/src/org/eclipse/test/Screenshots.java similarity index 98% rename from eclipse.platform.releng/bundles/org.eclipse.test.performance/src/org/eclipse/test/Screenshots.java rename to eclipse.platform.releng/bundles/org.eclipse.test/src/org/eclipse/test/Screenshots.java index a385da8b90a..f834f03f69d 100644 --- a/eclipse.platform.releng/bundles/org.eclipse.test.performance/src/org/eclipse/test/Screenshots.java +++ b/eclipse.platform.releng/bundles/org.eclipse.test/src/org/eclipse/test/Screenshots.java @@ -16,7 +16,6 @@ import java.io.File; import org.eclipse.core.runtime.Platform; -import org.eclipse.test.internal.AwtScreenshot; /** * Helper class to take screenshots from running tests. diff --git a/eclipse.platform.releng/bundles/org.eclipse.test.performance/src/org/eclipse/test/TracingSuite.java b/eclipse.platform.releng/bundles/org.eclipse.test/src/org/eclipse/test/TracingSuite.java similarity index 100% rename from eclipse.platform.releng/bundles/org.eclipse.test.performance/src/org/eclipse/test/TracingSuite.java rename to eclipse.platform.releng/bundles/org.eclipse.test/src/org/eclipse/test/TracingSuite.java