testing rearchitecting
Some checks failed
studiorailgun/Renderer/pipeline/head There was a failure building this commit
Some checks failed
studiorailgun/Renderer/pipeline/head There was a failure building this commit
This commit is contained in:
parent
25346978e6
commit
415e20d02d
@ -1,3 +1,3 @@
|
|||||||
#maven.buildNumber.plugin properties file
|
#maven.buildNumber.plugin properties file
|
||||||
#Mon Aug 19 09:32:22 EDT 2024
|
#Mon Aug 19 12:41:14 EDT 2024
|
||||||
buildNumber=260
|
buildNumber=276
|
||||||
|
|||||||
@ -612,6 +612,8 @@ Small oit shader work
|
|||||||
|
|
||||||
(08/19/2024)
|
(08/19/2024)
|
||||||
Disable cloud ring
|
Disable cloud ring
|
||||||
|
Undo oit shader work to fix build pipeline
|
||||||
|
Testing rearchitecting
|
||||||
|
|
||||||
|
|
||||||
# TODO
|
# TODO
|
||||||
|
|||||||
29
pom.xml
29
pom.xml
@ -290,6 +290,9 @@
|
|||||||
</activation>
|
</activation>
|
||||||
<properties>
|
<properties>
|
||||||
<lwjgl.natives>natives-linux</lwjgl.natives>
|
<lwjgl.natives>natives-linux</lwjgl.natives>
|
||||||
|
|
||||||
|
<!--The tests to run-->
|
||||||
|
<groups>fast</groups>
|
||||||
</properties>
|
</properties>
|
||||||
<build>
|
<build>
|
||||||
<plugins>
|
<plugins>
|
||||||
@ -377,6 +380,9 @@
|
|||||||
</activation>
|
</activation>
|
||||||
<properties>
|
<properties>
|
||||||
<lwjgl.natives>natives-windows</lwjgl.natives>
|
<lwjgl.natives>natives-windows</lwjgl.natives>
|
||||||
|
|
||||||
|
<!--The tests to run-->
|
||||||
|
<groups>fast</groups>
|
||||||
</properties>
|
</properties>
|
||||||
<build>
|
<build>
|
||||||
<plugins>
|
<plugins>
|
||||||
@ -406,6 +412,21 @@
|
|||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
</profile>
|
</profile>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<!-- INTEGRATION TESTING -->
|
||||||
|
<!-- To execute this profile, run a command like "mvn test -P lwjgl-natives-windows,integration" -->
|
||||||
|
<profile>
|
||||||
|
<id>integration</id>
|
||||||
|
<properties>
|
||||||
|
<!--The tests to run-->
|
||||||
|
<groups>fast,integration</groups>
|
||||||
|
</properties>
|
||||||
|
</profile>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</profiles>
|
</profiles>
|
||||||
|
|
||||||
|
|
||||||
@ -417,6 +438,8 @@
|
|||||||
<!-- MAIN BUILD -->
|
<!-- MAIN BUILD -->
|
||||||
<build>
|
<build>
|
||||||
<plugins>
|
<plugins>
|
||||||
|
|
||||||
|
<!--Shade the jar (pack all dependencies)-->
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-shade-plugin</artifactId>
|
<artifactId>maven-shade-plugin</artifactId>
|
||||||
@ -439,6 +462,9 @@
|
|||||||
</execution>
|
</execution>
|
||||||
</executions>
|
</executions>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
|
||||||
|
|
||||||
|
<!--Exec build tools-->
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.codehaus.mojo</groupId>
|
<groupId>org.codehaus.mojo</groupId>
|
||||||
<artifactId>exec-maven-plugin</artifactId>
|
<artifactId>exec-maven-plugin</artifactId>
|
||||||
@ -488,6 +514,9 @@
|
|||||||
</execution> -->
|
</execution> -->
|
||||||
</executions>
|
</executions>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
|
||||||
|
|
||||||
|
<!--Incrementing (local) build numbers-->
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.codehaus.mojo</groupId>
|
<groupId>org.codehaus.mojo</groupId>
|
||||||
<artifactId>buildnumber-maven-plugin</artifactId>
|
<artifactId>buildnumber-maven-plugin</artifactId>
|
||||||
|
|||||||
26
src/test/java/annotations/FastTest.java
Normal file
26
src/test/java/annotations/FastTest.java
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
package annotations;
|
||||||
|
|
||||||
|
import java.lang.annotation.Retention;
|
||||||
|
import java.lang.annotation.Target;
|
||||||
|
import java.lang.annotation.RetentionPolicy;
|
||||||
|
import java.lang.annotation.ElementType;
|
||||||
|
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.Tag;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.junit.jupiter.api.Timeout;
|
||||||
|
import org.junit.jupiter.api.Timeout.ThreadMode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A fast test that does not depend on setup/shutdown -- A unit test
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Target({ ElementType.TYPE, ElementType.METHOD })
|
||||||
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
|
@Tag("fast")
|
||||||
|
@Test
|
||||||
|
@Timeout( value = 20, unit = TimeUnit.MILLISECONDS, threadMode = ThreadMode.SAME_THREAD )
|
||||||
|
public @interface FastTest {
|
||||||
|
|
||||||
|
}
|
||||||
21
src/test/java/annotations/IntegrationSetup.java
Normal file
21
src/test/java/annotations/IntegrationSetup.java
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
package annotations;
|
||||||
|
|
||||||
|
import java.lang.annotation.ElementType;
|
||||||
|
import java.lang.annotation.Retention;
|
||||||
|
import java.lang.annotation.RetentionPolicy;
|
||||||
|
import java.lang.annotation.Target;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
|
import org.junit.jupiter.api.Tag;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used to flag work that should be done before each integration test
|
||||||
|
*/
|
||||||
|
@Target({ ElementType.TYPE, ElementType.METHOD })
|
||||||
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
|
@BeforeEach
|
||||||
|
@Tag("integration")
|
||||||
|
public @interface IntegrationSetup {
|
||||||
|
|
||||||
|
}
|
||||||
20
src/test/java/annotations/IntegrationTeardown.java
Normal file
20
src/test/java/annotations/IntegrationTeardown.java
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
package annotations;
|
||||||
|
|
||||||
|
import java.lang.annotation.ElementType;
|
||||||
|
import java.lang.annotation.Retention;
|
||||||
|
import java.lang.annotation.RetentionPolicy;
|
||||||
|
import java.lang.annotation.Target;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.AfterEach;
|
||||||
|
import org.junit.jupiter.api.Tag;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Flags for work to be done tearing down after running an integration test
|
||||||
|
*/
|
||||||
|
@Target({ ElementType.TYPE, ElementType.METHOD })
|
||||||
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
|
@AfterEach
|
||||||
|
@Tag("integration")
|
||||||
|
public @interface IntegrationTeardown {
|
||||||
|
|
||||||
|
}
|
||||||
26
src/test/java/annotations/IntegrationTest.java
Normal file
26
src/test/java/annotations/IntegrationTest.java
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
package annotations;
|
||||||
|
|
||||||
|
import java.lang.annotation.Retention;
|
||||||
|
import java.lang.annotation.Target;
|
||||||
|
import java.lang.annotation.RetentionPolicy;
|
||||||
|
import java.lang.annotation.ElementType;
|
||||||
|
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.Tag;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.junit.jupiter.api.Timeout;
|
||||||
|
import org.junit.jupiter.api.Timeout.ThreadMode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An integration test. Has defaults for timeout on the test
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Target({ ElementType.TYPE, ElementType.METHOD })
|
||||||
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
|
@Tag("integration")
|
||||||
|
@Test
|
||||||
|
@Timeout( value = 2, unit = TimeUnit.MINUTES, threadMode = ThreadMode.SAME_THREAD )
|
||||||
|
public @interface IntegrationTest {
|
||||||
|
|
||||||
|
}
|
||||||
@ -1,5 +0,0 @@
|
|||||||
package db;
|
|
||||||
|
|
||||||
public class DBTest {
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,4 +1,4 @@
|
|||||||
package entity;
|
package electrosphere.entity;
|
||||||
|
|
||||||
public class InventoryStateTest {
|
public class InventoryStateTest {
|
||||||
|
|
||||||
@ -1,4 +1,4 @@
|
|||||||
package entity;
|
package electrosphere.entity;
|
||||||
|
|
||||||
public class LifeStateTest {
|
public class LifeStateTest {
|
||||||
|
|
||||||
@ -1,4 +1,4 @@
|
|||||||
package entity;
|
package electrosphere.entity;
|
||||||
|
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
@ -13,6 +13,7 @@ public class SpawningCreaturesTest {
|
|||||||
|
|
||||||
@BeforeEach
|
@BeforeEach
|
||||||
public void initEngine(){
|
public void initEngine(){
|
||||||
|
LoggerInterface.initLoggers();
|
||||||
LoggerInterface.loggerEngine.INFO("[Test] Spawn many creatures");
|
LoggerInterface.loggerEngine.INFO("[Test] Spawn many creatures");
|
||||||
Globals.RUN_CLIENT = true;
|
Globals.RUN_CLIENT = true;
|
||||||
Globals.RUN_SERVER = true;
|
Globals.RUN_SERVER = true;
|
||||||
@ -1,56 +0,0 @@
|
|||||||
package electrosphere.renderer.ui.elements;
|
|
||||||
|
|
||||||
import java.awt.image.BufferedImage;
|
|
||||||
|
|
||||||
import org.junit.jupiter.api.AfterEach;
|
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
|
||||||
import org.junit.jupiter.api.Tag;
|
|
||||||
import org.junit.jupiter.api.Test;
|
|
||||||
|
|
||||||
import electrosphere.engine.Globals;
|
|
||||||
import electrosphere.engine.Main;
|
|
||||||
import electrosphere.menu.WindowUtils;
|
|
||||||
import electrosphere.menu.mainmenu.MenuGeneratorsUITesting;
|
|
||||||
import electrosphere.renderer.RenderingEngine;
|
|
||||||
import testutils.TestEngineUtils;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Integration tests for the window class
|
|
||||||
*/
|
|
||||||
public class WindowIntegrationTest {
|
|
||||||
|
|
||||||
@BeforeEach
|
|
||||||
@Tag("integration")
|
|
||||||
/**
|
|
||||||
* Initializes the engine
|
|
||||||
*/
|
|
||||||
public void initEngine(){
|
|
||||||
TestEngineUtils.initGraphicalEngine();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@Tag("integration")
|
|
||||||
/**
|
|
||||||
* Tests creating a window
|
|
||||||
*/
|
|
||||||
public void testCreateWindow(){
|
|
||||||
//create ui testing window
|
|
||||||
TestEngineUtils.simulateFrames(1);
|
|
||||||
WindowUtils.replaceMainMenuContents(MenuGeneratorsUITesting.createUITestMenu());
|
|
||||||
TestEngineUtils.simulateFrames(1);
|
|
||||||
BufferedImage screenshot = RenderingEngine.defaultFramebuffer.getPixels(Globals.renderingEngine.getOpenGLState());
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@AfterEach
|
|
||||||
@Tag("integration")
|
|
||||||
/**
|
|
||||||
* Shuts down the engine
|
|
||||||
*/
|
|
||||||
public void closeEngine(){
|
|
||||||
Main.shutdown();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -0,0 +1,27 @@
|
|||||||
|
package electrosphere.renderer.ui.elements;
|
||||||
|
|
||||||
|
import annotations.IntegrationTest;
|
||||||
|
import electrosphere.menu.WindowUtils;
|
||||||
|
import electrosphere.menu.mainmenu.MenuGeneratorsUITesting;
|
||||||
|
import template.RenderingTestTemplate;
|
||||||
|
import testutils.TestEngineUtils;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests for the window class
|
||||||
|
*/
|
||||||
|
public class WindowTest extends RenderingTestTemplate {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests creating a window
|
||||||
|
*/
|
||||||
|
@IntegrationTest
|
||||||
|
public void testCreateWindow(){
|
||||||
|
//create ui testing window
|
||||||
|
TestEngineUtils.simulateFrames(1);
|
||||||
|
WindowUtils.replaceMainMenuContents(MenuGeneratorsUITesting.createUITestMenu());
|
||||||
|
TestEngineUtils.simulateFrames(1);
|
||||||
|
// TestRenderingUtils.saveTestRender("./test/java/electrosphere/renderer/ui/elements/window.png");
|
||||||
|
this.checkRender("Basic", "./test/java/electrosphere/renderer/ui/elements/window.png");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -1,10 +0,0 @@
|
|||||||
package electrosphere.renderer.ui.elements;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Unit testing the window class
|
|
||||||
*/
|
|
||||||
public class WindowUnitTest {
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,16 +1,15 @@
|
|||||||
package startup;
|
package integration;
|
||||||
|
|
||||||
import org.junit.jupiter.api.Test;
|
|
||||||
|
|
||||||
|
import annotations.IntegrationSetup;
|
||||||
|
import annotations.IntegrationTest;
|
||||||
import electrosphere.engine.Globals;
|
import electrosphere.engine.Globals;
|
||||||
import electrosphere.engine.Main;
|
|
||||||
import electrosphere.engine.profiler.Profiler;
|
import electrosphere.engine.profiler.Profiler;
|
||||||
import electrosphere.logger.LoggerInterface;
|
import electrosphere.logger.LoggerInterface;
|
||||||
import electrosphere.net.NetUtils;
|
import electrosphere.net.NetUtils;
|
||||||
|
|
||||||
public class StartupTest {
|
public class StartupTest {
|
||||||
|
|
||||||
@Test
|
@IntegrationSetup
|
||||||
public void testStartupHeadless(){
|
public void testStartupHeadless(){
|
||||||
LoggerInterface.loggerEngine.INFO("[Test] Startup Headless");
|
LoggerInterface.loggerEngine.INFO("[Test] Startup Headless");
|
||||||
Globals.RUN_CLIENT = false;
|
Globals.RUN_CLIENT = false;
|
||||||
@ -22,7 +21,7 @@ public class StartupTest {
|
|||||||
// Main.mainLoop(1);
|
// Main.mainLoop(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@IntegrationTest
|
||||||
public void testEmpty() {
|
public void testEmpty() {
|
||||||
LoggerInterface.loggerEngine.INFO("[Test] Empty test");
|
LoggerInterface.loggerEngine.INFO("[Test] Empty test");
|
||||||
}
|
}
|
||||||
@ -1,5 +0,0 @@
|
|||||||
package networking;
|
|
||||||
|
|
||||||
public class NetworkingTest {
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,5 +0,0 @@
|
|||||||
package physics;
|
|
||||||
|
|
||||||
public class PhysicsTest {
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,5 +0,0 @@
|
|||||||
package script;
|
|
||||||
|
|
||||||
public class ScriptTest {
|
|
||||||
|
|
||||||
}
|
|
||||||
52
src/test/java/template/RenderingTestTemplate.java
Normal file
52
src/test/java/template/RenderingTestTemplate.java
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
package template;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
|
||||||
|
import annotations.IntegrationSetup;
|
||||||
|
import annotations.IntegrationTeardown;
|
||||||
|
import electrosphere.engine.Main;
|
||||||
|
import testutils.TestEngineUtils;
|
||||||
|
import testutils.TestRenderingUtils;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A test class that involves testing renders
|
||||||
|
*/
|
||||||
|
public abstract class RenderingTestTemplate {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializes the engine
|
||||||
|
*/
|
||||||
|
@IntegrationSetup
|
||||||
|
public void initEngine(){
|
||||||
|
TestEngineUtils.initGraphicalEngine();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Shuts down the engine
|
||||||
|
*/
|
||||||
|
@IntegrationTeardown
|
||||||
|
public void closeEngine(){
|
||||||
|
Main.shutdown();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks the most recent render versus an existing image
|
||||||
|
* @param renderName The name associated with the render
|
||||||
|
* @param existingRenderPath The path to the existing image
|
||||||
|
*/
|
||||||
|
public void checkRender(String renderName, String existingRenderPath){
|
||||||
|
//of the format "electrosphere.renderer.ui.elements.WindowTest"
|
||||||
|
String canonicalName = this.getClass().getCanonicalName();
|
||||||
|
|
||||||
|
//check the render
|
||||||
|
TestRenderingUtils.assertEqualsRender(existingRenderPath, () -> {
|
||||||
|
|
||||||
|
//on failure, save the failed render
|
||||||
|
String failureSavePath = "./.testcache/" + canonicalName + "-" + renderName + ".png";
|
||||||
|
File saveFile = new File(failureSavePath);
|
||||||
|
System.err.println("[[ATTACHMENT|" + saveFile.getAbsolutePath() + "]]");
|
||||||
|
TestRenderingUtils.saveTestRender(failureSavePath);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
66
src/test/java/testutils/TestRenderingUtils.java
Normal file
66
src/test/java/testutils/TestRenderingUtils.java
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
package testutils;
|
||||||
|
|
||||||
|
import java.awt.image.BufferedImage;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import javax.imageio.ImageIO;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
|
|
||||||
|
import electrosphere.engine.Globals;
|
||||||
|
import electrosphere.renderer.RenderingEngine;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Utilities for comparing renders
|
||||||
|
*/
|
||||||
|
public class TestRenderingUtils {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Asserts that the most recent render matches the image stored at the provided filepath
|
||||||
|
* @param existingRenderPath The filepath of the existing render
|
||||||
|
*/
|
||||||
|
public static void assertEqualsRender(String existingRenderPath, Runnable onFailure){
|
||||||
|
BufferedImage testData = null;
|
||||||
|
try {
|
||||||
|
testData = ImageIO.read(new File(existingRenderPath));
|
||||||
|
} catch (IOException e){
|
||||||
|
fail("Failed to read existing image path " + existingRenderPath);
|
||||||
|
}
|
||||||
|
BufferedImage screenshot = RenderingEngine.defaultFramebuffer.getPixels(Globals.renderingEngine.getOpenGLState());
|
||||||
|
//check basic data
|
||||||
|
if(testData.getWidth() != screenshot.getWidth()){
|
||||||
|
onFailure.run();
|
||||||
|
}
|
||||||
|
assertEquals(testData.getHeight(), screenshot.getHeight());
|
||||||
|
if(testData.getWidth() != screenshot.getWidth()){
|
||||||
|
onFailure.run();
|
||||||
|
}
|
||||||
|
assertEquals(testData.getHeight(), screenshot.getHeight());
|
||||||
|
|
||||||
|
//pixel-by-pixel check
|
||||||
|
for(int x = 0; x < testData.getWidth(); x++){
|
||||||
|
for(int y = 0; y < testData.getHeight(); y++){
|
||||||
|
if(testData.getRGB(x, y) != screenshot.getRGB(x, y)){
|
||||||
|
onFailure.run();
|
||||||
|
}
|
||||||
|
assertEquals(testData.getRGB(x, y),screenshot.getRGB(x, y));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used for saving a copy of the current render (ie for generating test data)
|
||||||
|
* @param existingRenderPath The filepath of the existing render
|
||||||
|
*/
|
||||||
|
public static void saveTestRender(String existingRenderPath){
|
||||||
|
BufferedImage screenshot = RenderingEngine.defaultFramebuffer.getPixels(Globals.renderingEngine.getOpenGLState());
|
||||||
|
try {
|
||||||
|
ImageIO.write(screenshot, "png", new File(existingRenderPath));
|
||||||
|
} catch (IOException e) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
BIN
test/java/electrosphere/renderer/ui/elements/window.png
Normal file
BIN
test/java/electrosphere/renderer/ui/elements/window.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 12 KiB |
Loading…
Reference in New Issue
Block a user