Skip to content

Commit

Permalink
Added unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Anuken committed Oct 4, 2018
1 parent 34715b1 commit c82fd9e
Show file tree
Hide file tree
Showing 11 changed files with 233 additions and 88 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@
/core/assets-raw/sprites/generated/
/annotations/build/
/kryonet/build/
/packer/build/
/tools/build/
/tests/build/
/server/build/
/test_files/
/annotations/build/
/android/assets/mindustry-maps/
/android/assets/mindustry-saves/
Expand Down
33 changes: 18 additions & 15 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ allprojects {
appName = 'Mindustry'
gdxVersion = '1.9.8'
roboVMVersion = '2.3.0'
uCoreVersion = '00d05bd7d3e943c8a454ccf2cb69cdffb23afbb7'
uCoreVersion = '220916714cbe63664c34f95a9dc50a362feca732'

getVersionString = {
String buildVersion = getBuildVersion()
Expand Down Expand Up @@ -119,20 +119,6 @@ project(":html") {
}
}

project(":tests"){
apply plugin: "java"

dependencies {
compile project(":core")
testImplementation('org.junit.jupiter:junit-jupiter-api:5.1.0')
testRuntimeOnly('org.junit.jupiter:junit-jupiter-engine:5.1.0')
}

test {
useJUnitPlatform()
}
}

project(":ios") {
apply plugin: "java"
apply plugin: "robovm"
Expand Down Expand Up @@ -218,6 +204,23 @@ project(":server") {
}
}

project(":tests"){
apply plugin: "java"

dependencies {
testImplementation project(":core")
testImplementation('org.junit.jupiter:junit-jupiter-api:5.1.0')
testRuntimeOnly('org.junit.jupiter:junit-jupiter-engine:5.1.0')
testImplementation "com.badlogicgames.gdx:gdx-backend-headless:$gdxVersion"
testImplementation "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop"
}

test {
useJUnitPlatform()
workingDir = new File("../core/assets")
}
}

project(":tools") {
apply plugin: "java"

Expand Down
Binary file modified core/assets-raw/sprites/blocks/units/revenant-factory.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified core/assets/sprites/sprites.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 3 additions & 2 deletions core/src/io/anuke/mindustry/maps/Sector.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import io.anuke.ucore.util.Bits;

import static io.anuke.mindustry.Vars.control;
import static io.anuke.mindustry.Vars.headless;

@Serialize
public class Sector{
Expand Down Expand Up @@ -46,11 +47,11 @@ public int getSeed(){
}

public SaveSlot getSave(){
return control.getSaves().getByID(saveID);
return !hasSave() ? null : control.getSaves().getByID(saveID);
}

public boolean hasSave(){
return control.getSaves().getByID(saveID) != null;
return !headless && control.getSaves().getByID(saveID) != null;
}

public int packedPosition(){
Expand Down
4 changes: 3 additions & 1 deletion core/src/io/anuke/mindustry/maps/Sectors.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ public void playSector(Sector sector){
}
world.loadSector(sector);
logic.play();
sector.saveID = control.getSaves().addSave("sector-" + sector.packedPosition()).index;
if(!headless){
sector.saveID = control.getSaves().addSave("sector-" + sector.packedPosition()).index;
}
world.sectors().save();
world.setSector(sector);
sector.currentMission().onBegin();
Expand Down
13 changes: 0 additions & 13 deletions core/src/io/anuke/mindustry/net/Administration.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package io.anuke.mindustry.net;

import com.badlogic.gdx.utils.Array;
import com.badlogic.gdx.utils.IntMap;
import com.badlogic.gdx.utils.ObjectMap;
import io.anuke.annotations.Annotations.Serialize;
import io.anuke.ucore.core.Settings;
Expand All @@ -16,8 +15,6 @@ public class Administration{
private ObjectMap<String, PlayerInfo> playerInfo = new ObjectMap<>();
/**Maps UUIDs to trace infos. This is wiped when a player logs off.*/
private ObjectMap<String, TraceInfo> traceInfo = new ObjectMap<>();
/** Maps packed coordinates to logs for that coordinate*/
private IntMap<Array<EditLog>> editLogs = new IntMap<>();
private Array<String> bannedIPs = new Array<>();

public Administration(){
Expand Down Expand Up @@ -46,16 +43,6 @@ public void setCustomClients(boolean allowed){
Settings.save();
}

public void setAntiGriefParams(int maxBreak, int cooldown){
Settings.putInt("antigrief-max", maxBreak);
Settings.putInt("antigrief-cooldown", cooldown);
Settings.save();
}

public IntMap<Array<EditLog>> getEditLogs(){
return editLogs;
}

/**
* Call when a player joins to update their information here.
*/
Expand Down
21 changes: 0 additions & 21 deletions core/src/io/anuke/mindustry/net/EditLog.java

This file was deleted.

28 changes: 2 additions & 26 deletions server/src/io/anuke/mindustry/server/ServerLauncher.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package io.anuke.mindustry.server;

import com.badlogic.gdx.ApplicationListener;
import com.badlogic.gdx.ApplicationLogger;
import com.badlogic.gdx.Files.FileType;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Preferences;
Expand All @@ -13,6 +12,7 @@
import io.anuke.kryonet.KryoServer;
import io.anuke.mindustry.net.Net;
import io.anuke.ucore.io.BinaryPreferences;
import io.anuke.ucore.util.EmptyLogger;
import io.anuke.ucore.util.OS;

import java.io.File;
Expand All @@ -24,31 +24,7 @@ public ServerLauncher(ApplicationListener listener, HeadlessApplicationConfigura
super(listener, config);

//don't do anything at all for GDX logging: don't want controller info and such
Gdx.app.setApplicationLogger(new ApplicationLogger(){
@Override
public void log(String tag, String message){
}

@Override
public void log(String tag, String message, Throwable exception){
}

@Override
public void error(String tag, String message){
}

@Override
public void error(String tag, String message, Throwable exception){
}

@Override
public void debug(String tag, String message){
}

@Override
public void debug(String tag, String message, Throwable exception){
}
});
Gdx.app.setApplicationLogger(new EmptyLogger());
}

public static void main(String[] args){
Expand Down
Loading

0 comments on commit c82fd9e

Please sign in to comment.