mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-18 03:44:54 -04:00
integration test: reduce test time, minor performance optimizations
This commit is contained in:
parent
2d197237f8
commit
d7beac6eae
@ -21,6 +21,7 @@ import de.bixilon.minosoft.protocol.packets.factory.PacketTypeRegistry
|
|||||||
import de.bixilon.minosoft.protocol.versions.Versions
|
import de.bixilon.minosoft.protocol.versions.Versions
|
||||||
import de.bixilon.minosoft.test.IT
|
import de.bixilon.minosoft.test.IT
|
||||||
import de.bixilon.minosoft.test.ITUtil
|
import de.bixilon.minosoft.test.ITUtil
|
||||||
|
import de.bixilon.minosoft.util.KUtil
|
||||||
import de.bixilon.minosoft.util.logging.Log
|
import de.bixilon.minosoft.util.logging.Log
|
||||||
import de.bixilon.minosoft.util.logging.LogLevels
|
import de.bixilon.minosoft.util.logging.LogLevels
|
||||||
import de.bixilon.minosoft.util.logging.LogMessageType
|
import de.bixilon.minosoft.util.logging.LogMessageType
|
||||||
@ -32,6 +33,7 @@ internal object MinosoftSIT {
|
|||||||
@BeforeSuite
|
@BeforeSuite
|
||||||
fun setup() {
|
fun setup() {
|
||||||
Log.ASYNC_LOGGING = false
|
Log.ASYNC_LOGGING = false
|
||||||
|
KUtil.initUtilClasses()
|
||||||
disableGC()
|
disableGC()
|
||||||
Log.log(LogMessageType.OTHER, LogLevels.INFO) { "Setting up integration tests...." }
|
Log.log(LogMessageType.OTHER, LogLevels.INFO) { "Setting up integration tests...." }
|
||||||
initAssetsManager()
|
initAssetsManager()
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Minosoft
|
* Minosoft
|
||||||
* Copyright (C) 2020-2022 Moritz Zwerger
|
* Copyright (C) 2020-2023 Moritz Zwerger
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||||
*
|
*
|
||||||
@ -13,6 +13,7 @@
|
|||||||
|
|
||||||
package de.bixilon.minosoft.config.profile
|
package de.bixilon.minosoft.config.profile
|
||||||
|
|
||||||
|
import de.bixilon.minosoft.assets.minecraft.index.IndexAssetsType
|
||||||
import de.bixilon.minosoft.config.profile.profiles.audio.AudioProfile
|
import de.bixilon.minosoft.config.profile.profiles.audio.AudioProfile
|
||||||
import de.bixilon.minosoft.config.profile.profiles.block.BlockProfile
|
import de.bixilon.minosoft.config.profile.profiles.block.BlockProfile
|
||||||
import de.bixilon.minosoft.config.profile.profiles.connection.ConnectionProfile
|
import de.bixilon.minosoft.config.profile.profiles.connection.ConnectionProfile
|
||||||
@ -27,13 +28,20 @@ import de.bixilon.minosoft.config.profile.profiles.resources.ResourcesProfile
|
|||||||
|
|
||||||
object ProfileTestUtil {
|
object ProfileTestUtil {
|
||||||
|
|
||||||
|
private fun createResources(): ResourcesProfile {
|
||||||
|
val profile = ResourcesProfile()
|
||||||
|
profile.assets.indexAssetsTypes -= IndexAssetsType.SOUNDS // we can't play them anyways
|
||||||
|
profile.verify = false // this just slows down the process, the pipeline will fail no matter what if anything is corrupted
|
||||||
|
return profile
|
||||||
|
}
|
||||||
|
|
||||||
fun createProfiles(): ConnectionProfiles {
|
fun createProfiles(): ConnectionProfiles {
|
||||||
return ConnectionProfiles(
|
return ConnectionProfiles(
|
||||||
eros = ErosProfile(),
|
eros = ErosProfile(),
|
||||||
particle = ParticleProfile(),
|
particle = ParticleProfile(),
|
||||||
audio = AudioProfile(),
|
audio = AudioProfile(),
|
||||||
entity = EntityProfile(),
|
entity = EntityProfile(),
|
||||||
resources = ResourcesProfile(),
|
resources = createResources(),
|
||||||
rendering = RenderingProfile(),
|
rendering = RenderingProfile(),
|
||||||
block = BlockProfile(),
|
block = BlockProfile(),
|
||||||
connection = ConnectionProfile(),
|
connection = ConnectionProfile(),
|
||||||
|
@ -25,7 +25,7 @@ import java.util.*
|
|||||||
object TestAccount : Account("Bixilon") {
|
object TestAccount : Account("Bixilon") {
|
||||||
override val id: String = "id"
|
override val id: String = "id"
|
||||||
override val type: ResourceLocation = minosoft("test_account")
|
override val type: ResourceLocation = minosoft("test_account")
|
||||||
override val properties: PlayerProperties? = null
|
override val properties: PlayerProperties = PlayerProperties()
|
||||||
override val uuid: UUID = "9e6ce7c5-40d3-483e-8e5a-b6350987d65f".toUUID()
|
override val uuid: UUID = "9e6ce7c5-40d3-483e-8e5a-b6350987d65f".toUUID()
|
||||||
override var state: AccountStates
|
override var state: AccountStates
|
||||||
get() = AccountStates.WORKING
|
get() = AccountStates.WORKING
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Minosoft
|
* Minosoft
|
||||||
* Copyright (C) 2020-2022 Moritz Zwerger
|
* Copyright (C) 2020-2023 Moritz Zwerger
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||||
*
|
*
|
||||||
@ -30,14 +30,13 @@ class StairsTest : BlockTest<Block>() {
|
|||||||
super.retrieveBlock(MinecraftBlocks.OAK_STAIRS)
|
super.retrieveBlock(MinecraftBlocks.OAK_STAIRS)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(enabled = false)
|
@Test(enabled = false) // ToDo: This test is correct, but failing
|
||||||
fun testLightPropertiesNorth() {
|
fun testLightPropertiesNorth() {
|
||||||
// ToDo: This test is correct, but failing
|
|
||||||
block.withProperties(BlockProperties.FACING to Directions.NORTH).testLightProperties(0, true, true, false, booleanArrayOf(false, true, false, true, true, true))
|
block.withProperties(BlockProperties.FACING to Directions.NORTH).testLightProperties(0, true, true, false, booleanArrayOf(false, true, false, true, true, true))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test(enabled = false) // ToDo: This test is correct, but failing
|
||||||
fun testLightPropertiesSouth() {
|
fun testLightPropertiesSouth() {
|
||||||
// ToDo: This test is correct, but failing
|
|
||||||
block.withProperties(BlockProperties.FACING to Directions.SOUTH).testLightProperties(0, true, true, false, booleanArrayOf(false, true, true, false, true, true))
|
block.withProperties(BlockProperties.FACING to Directions.SOUTH).testLightProperties(0, true, true, false, booleanArrayOf(false, true, true, false, true, true))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -143,20 +143,21 @@ object VerifyIntegratedBlockRegistry {
|
|||||||
if (value["class"] == "AirBlock") {
|
if (value["class"] == "AirBlock") {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
val parsed = PixLyzerBlock.deserialize(registries, id.toResourceLocation(), value).unsafeCast<PixLyzerBlock>()
|
val identifier = id.toResourceLocation()
|
||||||
registries.block.updateStates(parsed, value, registries)
|
val integrated = registries.block[identifier] ?: Broken("Block $id does not exist in the registry?")
|
||||||
parsed.postInit(registries)
|
|
||||||
parsed.inject(registries)
|
|
||||||
val integrated = registries.block[parsed.identifier] ?: Broken("Block $id does not exist in the registry?")
|
|
||||||
if (integrated is PixLyzerBlock) {
|
if (integrated is PixLyzerBlock) {
|
||||||
// useless to compare
|
// useless to compare
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
if (integrated is FluidBlock || integrated is BubbleColumnBlock) {
|
if (integrated is FluidBlock || integrated is BubbleColumnBlock) {
|
||||||
// they work different in minosoft
|
// they work different in minosoft
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
val parsed = PixLyzerBlock.deserialize(registries, identifier, value).unsafeCast<PixLyzerBlock>()
|
||||||
|
registries.block.updateStates(parsed, value, registries)
|
||||||
|
parsed.postInit(registries)
|
||||||
|
parsed.inject(registries)
|
||||||
|
|
||||||
|
|
||||||
compare(parsed, integrated, error)
|
compare(parsed, integrated, error)
|
||||||
}
|
}
|
||||||
|
@ -34,7 +34,7 @@ class OfflineAccount(username: String) : Account(username) {
|
|||||||
override val supportsSkins: Boolean get() = false
|
override val supportsSkins: Boolean get() = false
|
||||||
|
|
||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
override val properties: PlayerProperties? = null
|
override val properties: PlayerProperties = PlayerProperties()
|
||||||
|
|
||||||
override fun join(serverId: String) = Unit
|
override fun join(serverId: String) = Unit
|
||||||
|
|
||||||
|
@ -18,6 +18,7 @@ import de.bixilon.minosoft.data.direction.Directions
|
|||||||
import de.bixilon.minosoft.data.registries.shapes.side.VoxelSide
|
import de.bixilon.minosoft.data.registries.shapes.side.VoxelSide
|
||||||
import de.bixilon.minosoft.data.registries.shapes.side.VoxelSideSet
|
import de.bixilon.minosoft.data.registries.shapes.side.VoxelSideSet
|
||||||
import de.bixilon.minosoft.data.registries.shapes.voxel.AbstractVoxelShape
|
import de.bixilon.minosoft.data.registries.shapes.voxel.AbstractVoxelShape
|
||||||
|
import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet
|
||||||
|
|
||||||
class DirectedProperty(
|
class DirectedProperty(
|
||||||
private val directions: BooleanArray,
|
private val directions: BooleanArray,
|
||||||
@ -72,7 +73,7 @@ class DirectedProperty(
|
|||||||
// ToDo: This whole calculation is technically wrong, it could be that 2 different sides of 2 blocks are "free". That means that light can still not pass the blocks, but
|
// ToDo: This whole calculation is technically wrong, it could be that 2 different sides of 2 blocks are "free". That means that light can still not pass the blocks, but
|
||||||
// this algorithm does not cover it. Let's see it as performance hack
|
// this algorithm does not cover it. Let's see it as performance hack
|
||||||
|
|
||||||
val sides: MutableSet<VoxelSide> = mutableSetOf()
|
val sides: MutableSet<VoxelSide> = ObjectOpenHashSet()
|
||||||
|
|
||||||
for (aabb in this) {
|
for (aabb in this) {
|
||||||
when (side.axis) {
|
when (side.axis) {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Minosoft
|
* Minosoft
|
||||||
* Copyright (C) 2020-2022 Moritz Zwerger
|
* Copyright (C) 2020-2023 Moritz Zwerger
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||||
*
|
*
|
||||||
@ -13,12 +13,16 @@
|
|||||||
|
|
||||||
package de.bixilon.minosoft.data.registries.shapes.side
|
package de.bixilon.minosoft.data.registries.shapes.side
|
||||||
|
|
||||||
|
import com.google.common.base.Objects
|
||||||
import de.bixilon.kotlinglm.vec2.Vec2
|
import de.bixilon.kotlinglm.vec2.Vec2
|
||||||
|
import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet
|
||||||
|
|
||||||
data class VoxelSide(
|
data class VoxelSide(
|
||||||
val min: Vec2,
|
val min: Vec2,
|
||||||
val max: Vec2,
|
val max: Vec2,
|
||||||
) {
|
) {
|
||||||
|
private val hashCode = Objects.hashCode(min.hashCode(), max.hashCode())
|
||||||
|
|
||||||
constructor(minX: Float, minZ: Float, maxX: Float, maxZ: Float) : this(Vec2(minOf(minX, maxX), minOf(minZ, maxZ)), Vec2(maxOf(minX, maxX), maxOf(minZ, maxZ)))
|
constructor(minX: Float, minZ: Float, maxX: Float, maxZ: Float) : this(Vec2(minOf(minX, maxX), minOf(minZ, maxZ)), Vec2(maxOf(minX, maxX), maxOf(minZ, maxZ)))
|
||||||
constructor(minX: Double, minZ: Double, maxX: Double, maxZ: Double) : this(Vec2(minOf(minX, maxX), minOf(minZ, maxZ)), Vec2(maxOf(minX, maxX), maxOf(minZ, maxZ)))
|
constructor(minX: Double, minZ: Double, maxX: Double, maxZ: Double) : this(Vec2(minOf(minX, maxX), minOf(minZ, maxZ)), Vec2(maxOf(minX, maxX), maxOf(minZ, maxZ)))
|
||||||
|
|
||||||
@ -37,7 +41,7 @@ data class VoxelSide(
|
|||||||
}
|
}
|
||||||
|
|
||||||
infix operator fun minus(set: VoxelSideSet): VoxelSideSet {
|
infix operator fun minus(set: VoxelSideSet): VoxelSideSet {
|
||||||
val result: MutableSet<VoxelSide> = mutableSetOf()
|
val result: MutableSet<VoxelSide> = ObjectOpenHashSet()
|
||||||
|
|
||||||
for (side in set.sides) {
|
for (side in set.sides) {
|
||||||
result += (this minus side).sides
|
result += (this minus side).sides
|
||||||
@ -47,7 +51,7 @@ data class VoxelSide(
|
|||||||
}
|
}
|
||||||
|
|
||||||
infix operator fun minus(other: VoxelSide): VoxelSideSet {
|
infix operator fun minus(other: VoxelSide): VoxelSideSet {
|
||||||
val result: MutableSet<VoxelSide> = mutableSetOf()
|
val result: MutableSet<VoxelSide> = ObjectOpenHashSet()
|
||||||
|
|
||||||
|
|
||||||
if (other.min.x > min.x && other.min.x < max.x) {
|
if (other.min.x > min.x && other.min.x < max.x) {
|
||||||
@ -97,4 +101,8 @@ data class VoxelSide(
|
|||||||
|
|
||||||
return VoxelSideSet(setOf(VoxelSide(minX, minY, maxX, maxY)))
|
return VoxelSideSet(setOf(VoxelSide(minX, minY, maxX, maxY)))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun hashCode(): Int {
|
||||||
|
return hashCode
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Minosoft
|
* Minosoft
|
||||||
* Copyright (C) 2020-2022 Moritz Zwerger
|
* Copyright (C) 2020-2023 Moritz Zwerger
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||||
*
|
*
|
||||||
@ -13,6 +13,8 @@
|
|||||||
|
|
||||||
package de.bixilon.minosoft.data.registries.shapes.side
|
package de.bixilon.minosoft.data.registries.shapes.side
|
||||||
|
|
||||||
|
import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet
|
||||||
|
|
||||||
class VoxelSideSet(
|
class VoxelSideSet(
|
||||||
val sides: Set<VoxelSide>,
|
val sides: Set<VoxelSide>,
|
||||||
) : Iterable<VoxelSide> {
|
) : Iterable<VoxelSide> {
|
||||||
@ -28,7 +30,7 @@ class VoxelSideSet(
|
|||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
|
||||||
val next: MutableSet<VoxelSide> = mutableSetOf()
|
val next: MutableSet<VoxelSide> = ObjectOpenHashSet()
|
||||||
|
|
||||||
val array = this.sides.toTypedArray()
|
val array = this.sides.toTypedArray()
|
||||||
for (i in 1 until sides.size) {
|
for (i in 1 until sides.size) {
|
||||||
|
@ -366,6 +366,8 @@ class ChunkLight(private val chunk: Chunk) {
|
|||||||
val maxHeightSection = maxHeight.sectionHeight
|
val maxHeightSection = maxHeight.sectionHeight
|
||||||
val skylightStart = getNeighbourMaxHeight(neighbours, x, z, heightmapIndex)
|
val skylightStart = getNeighbourMaxHeight(neighbours, x, z, heightmapIndex)
|
||||||
|
|
||||||
|
if (maxHeight == Int.MIN_VALUE && skylightStart == Int.MIN_VALUE) return
|
||||||
|
|
||||||
val skylightStartSectionHeight = skylightStart.sectionHeight
|
val skylightStartSectionHeight = skylightStart.sectionHeight
|
||||||
if (skylightStart.inSectionHeight == 1) {
|
if (skylightStart.inSectionHeight == 1) {
|
||||||
// Create section below max section
|
// Create section below max section
|
||||||
@ -416,10 +418,7 @@ class ChunkLight(private val chunk: Chunk) {
|
|||||||
if (this == null) {
|
if (this == null) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
if (!this.skyLight || !this.effects.skylight) {
|
return !(!this.skyLight || !this.effects.skylight)
|
||||||
return false
|
|
||||||
}
|
|
||||||
return true
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -91,7 +91,22 @@ internal class DirectedPropertyTest {
|
|||||||
assertFalse(shape.isSideCovered(Directions.UP))
|
assertFalse(shape.isSideCovered(Directions.UP))
|
||||||
assertTrue(shape.isSideCovered(Directions.NORTH))
|
assertTrue(shape.isSideCovered(Directions.NORTH))
|
||||||
assertFalse(shape.isSideCovered(Directions.SOUTH))
|
assertFalse(shape.isSideCovered(Directions.SOUTH))
|
||||||
assertTrue(shape.isSideCovered(Directions.WEST))
|
assertFalse(shape.isSideCovered(Directions.WEST))
|
||||||
assertTrue(shape.isSideCovered(Directions.EAST))
|
assertFalse(shape.isSideCovered(Directions.EAST))
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun testSideCovered7() {
|
||||||
|
val shape = VoxelShape(
|
||||||
|
AABB(0.0f, 0.0f, 0.0f, 1.0f, 0.5f, 1.0f),
|
||||||
|
AABB(0.0f, 0.5f, 0.5f, 1.0f, 1.0f, 1.0f),
|
||||||
|
)
|
||||||
|
|
||||||
|
assertTrue(shape.isSideCovered(Directions.DOWN))
|
||||||
|
assertFalse(shape.isSideCovered(Directions.UP))
|
||||||
|
assertFalse(shape.isSideCovered(Directions.NORTH))
|
||||||
|
assertTrue(shape.isSideCovered(Directions.SOUTH))
|
||||||
|
assertFalse(shape.isSideCovered(Directions.WEST))
|
||||||
|
assertFalse(shape.isSideCovered(Directions.EAST))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user