Change location where EE3 looks for test files

This commit is contained in:
Pahimar 2016-05-25 11:10:21 -04:00
parent ba6841db98
commit 7cace9895a
6 changed files with 29 additions and 22 deletions

View file

@ -3,6 +3,7 @@ package com.pahimar.ee3.command;
import com.pahimar.ee3.reference.Messages;
import com.pahimar.ee3.reference.Names;
import com.pahimar.ee3.reference.Reference;
import com.pahimar.ee3.reference.Tests;
import com.pahimar.ee3.test.EnergyValueTestSuite;
import com.pahimar.ee3.util.LogHelper;
import cpw.mods.fml.common.FMLCommonHandler;
@ -39,26 +40,28 @@ public class CommandRunTest extends CommandEE
{
if (args.length == 2) {
// TODO Change location of where it looks for test cases
File testCaseDirectory = new File(FMLCommonHandler.instance().getMinecraftServerInstance().getEntityWorld().getSaveHandler().getWorldDirectory(), "data" + File.separator + Reference.LOWERCASE_MOD_ID + File.separator + "energyvalues" + File.separator + "testcases");
testCaseDirectory.mkdirs();
boolean testFound = false;
for (File testCaseFile : testCaseDirectory.listFiles()) {
if (testCaseFile.isFile() && testCaseFile.getName().equalsIgnoreCase(args[1])) {
testFound = true;
EnergyValueTestSuite energyValueTestSuite = new EnergyValueTestSuite(testCaseFile);
LogHelper.info(EnergyValueTestSuite.TEST_MARKER, "BEGIN TEST ({})", testCaseFile.getName());
energyValueTestSuite.run();
LogHelper.info(EnergyValueTestSuite.TEST_MARKER, "END TEST ({})", testCaseFile.getName());
if (Tests.globalTestDirectory != null) {
for (File testCaseFile : Tests.globalTestDirectory.listFiles()) {
if (testCaseFile.isFile() && testCaseFile.getName().equalsIgnoreCase(args[1])) {
testFound = true;
EnergyValueTestSuite energyValueTestSuite = new EnergyValueTestSuite(testCaseFile);
LogHelper.info(EnergyValueTestSuite.TEST_MARKER, "BEGIN TEST ({})", testCaseFile.getName());
energyValueTestSuite.run();
LogHelper.info(EnergyValueTestSuite.TEST_MARKER, "END TEST ({})", testCaseFile.getName());
}
}
if (testFound) {
commandSender.addChatMessage(new ChatComponentTranslation(Messages.Commands.RUN_TESTS_SUCCESS, args[1]));
}
else {
commandSender.addChatMessage(new ChatComponentTranslation(Messages.Commands.RUN_TESTS_NOT_FOUND, args[1]));
}
}
if (testFound) {
commandSender.addChatMessage(new ChatComponentTranslation(Messages.Commands.RUN_TESTS_SUCCESS, args[1]));
}
else {
commandSender.addChatMessage(new ChatComponentTranslation(Messages.Commands.RUN_TESTS_NOT_FOUND, args[1]));
throw new WrongUsageException(Messages.Commands.RUN_TEST_USAGE);
}
}
else

View file

@ -28,6 +28,8 @@ public class Files {
public static void init(FMLPreInitializationEvent event) {
globalDataDirectory = new File(event.getModConfigurationDirectory().getParentFile(), "data" + File.separator + Reference.LOWERCASE_MOD_ID);
Tests.globalTestDirectory = new File(globalDataDirectory, "tests");
Tests.globalTestDirectory.mkdirs();
EnergyValueRegistry.energyValuesDirectory = new File(globalDataDirectory, "energy-values");
EnergyValueRegistry.energyValuesDirectory.mkdirs();

View file

@ -103,6 +103,7 @@ public final class Messages {
public static final String RUN_TEST_USAGE = COMMAND_PREFIX + Names.Commands.RUN_TEST + ".usage";
public static final String RUN_TESTS_SUCCESS = COMMAND_PREFIX + Names.Commands.RUN_TEST + ".success";
public static final String RUN_TESTS_NOT_FOUND = COMMAND_PREFIX + Names.Commands.RUN_TEST + ".notfound";
public static final String RUN_TESTS_DIR_NOT_FOUND = COMMAND_PREFIX + Names.Commands.RUN_TEST + ".dir-notfound";
public static final String ADMIN_USAGE = COMMAND_PREFIX + Names.Commands.ADMIN_PANEL + ".usage";
}

View file

@ -3,6 +3,10 @@ package com.pahimar.ee3.reference;
import com.pahimar.ee3.test.EnergyValueTestSuite;
import com.pahimar.ee3.test.VanillaTestSuite;
import java.io.File;
public class Tests {
public static final EnergyValueTestSuite vanillaTestSuite = new VanillaTestSuite();
public static File globalTestDirectory;
public static final EnergyValueTestSuite VANILLA_TEST_SUITE = new VanillaTestSuite();
}

View file

@ -1,7 +1,6 @@
package com.pahimar.ee3.test;
import com.pahimar.ee3.reference.Reference;
import cpw.mods.fml.common.FMLCommonHandler;
import com.pahimar.ee3.reference.Tests;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
@ -600,9 +599,6 @@ public class VanillaTestSuite extends EnergyValueTestSuite {
}
public void save() {
// TODO Change the test directory location
File energyValuesDataDirectory = new File(FMLCommonHandler.instance().getMinecraftServerInstance().getEntityWorld().getSaveHandler().getWorldDirectory(), "data" + File.separator + Reference.LOWERCASE_MOD_ID + File.separator + "energyvalues" + File.separator + "testcases");
energyValuesDataDirectory.mkdirs();
this.save(new File(energyValuesDataDirectory, "minecraft-v1710-vanilla-test-suite.json"));
this.save(new File(Tests.globalTestDirectory, "minecraft-v1710-vanilla-test-suite.json"));
}
}

View file

@ -178,6 +178,7 @@ commands.ee3.set-current-item-not-recoverable.no-effect=%s is already not exchan
commands.ee3.run-tests.usage=/ee3 run-tests <file-name>
commands.ee3.run-tests.success=Executed test file '%s', check server log for results
commands.ee3.run-tests.notfound=Test file '%s' was not found!
commands.ee3.run-tests.dir-notfound=Test directory was not found!
# Tooltips
tooltip.ee3:belongsTo=Belongs to %s