mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-12 08:49:22 +07:00
Testing how the test errors are displayed in Travis
This commit is contained in:
@ -29,7 +29,7 @@ Hydro Plant = Elektrownia Wodna
|
|||||||
|
|
||||||
# Diplomacy,Trade,Nations
|
# Diplomacy,Trade,Nations
|
||||||
|
|
||||||
Requires [buildingName] to be built in the city = Miasto musi posiadać: [buildingName]
|
Requires [buildingName] to be built in the city = Miasto musi posiadać: [errorInducingChange]
|
||||||
Requires [buildingName] to be built in all cities = Wszystkie twoje miasta muszą posiadać: [buildingName]
|
Requires [buildingName] to be built in all cities = Wszystkie twoje miasta muszą posiadać: [buildingName]
|
||||||
Provides a free [buildingName] in the city = Zapewnia darmowy budynek: [buildingName] w tym mieście
|
Provides a free [buildingName] in the city = Zapewnia darmowy budynek: [buildingName] w tym mieście
|
||||||
Requires worked [resource] near city = Wymaga ulepszonego źródła surowca [resource] w pobliżu miasta
|
Requires worked [resource] near city = Wymaga ulepszonego źródła surowca [resource] w pobliżu miasta
|
||||||
|
@ -78,7 +78,7 @@ class UncivGame(parameters: UncivGameParameters) : Game() {
|
|||||||
Gdx.graphics.isContinuousRendering = settings.continuousRendering
|
Gdx.graphics.isContinuousRendering = settings.continuousRendering
|
||||||
|
|
||||||
thread(name = "LoadJSON") {
|
thread(name = "LoadJSON") {
|
||||||
RulesetCache.loadRulesets()
|
RulesetCache.loadRulesets(printOutput = true)
|
||||||
translations.tryReadTranslationForCurrentLanguage()
|
translations.tryReadTranslationForCurrentLanguage()
|
||||||
translations.loadPercentageCompleteOfLanguages()
|
translations.loadPercentageCompleteOfLanguages()
|
||||||
|
|
||||||
|
@ -98,7 +98,7 @@ class Ruleset {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
fun load(folderHandle: FileHandle) {
|
fun load(folderHandle: FileHandle, printOutput:Boolean) {
|
||||||
val gameBasicsStartTime = System.currentTimeMillis()
|
val gameBasicsStartTime = System.currentTimeMillis()
|
||||||
|
|
||||||
val modOptionsFile = folderHandle.child("ModOptions.json")
|
val modOptionsFile = folderHandle.child("ModOptions.json")
|
||||||
@ -163,7 +163,7 @@ class Ruleset {
|
|||||||
if (difficultiesFile.exists()) difficulties += createHashmap(jsonParser.getFromJson(Array<Difficulty>::class.java, difficultiesFile))
|
if (difficultiesFile.exists()) difficulties += createHashmap(jsonParser.getFromJson(Array<Difficulty>::class.java, difficultiesFile))
|
||||||
|
|
||||||
val gameBasicsLoadTime = System.currentTimeMillis() - gameBasicsStartTime
|
val gameBasicsLoadTime = System.currentTimeMillis() - gameBasicsStartTime
|
||||||
println("Loading game basics - " + gameBasicsLoadTime + "ms")
|
if(printOutput) println("Loading ruleset - " + gameBasicsLoadTime + "ms")
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Building costs are unique in that they are dependant on info in the technology part.
|
/** Building costs are unique in that they are dependant on info in the technology part.
|
||||||
@ -204,13 +204,13 @@ class Ruleset {
|
|||||||
* save all of the loaded rulesets somewhere for later use
|
* save all of the loaded rulesets somewhere for later use
|
||||||
* */
|
* */
|
||||||
object RulesetCache :HashMap<String,Ruleset>() {
|
object RulesetCache :HashMap<String,Ruleset>() {
|
||||||
fun loadRulesets(consoleMode:Boolean=false) {
|
fun loadRulesets(consoleMode:Boolean=false, printOutput: Boolean=false) {
|
||||||
clear()
|
clear()
|
||||||
for (ruleset in BaseRuleset.values()) {
|
for (ruleset in BaseRuleset.values()) {
|
||||||
val fileName = "jsons/${ruleset.fullName}"
|
val fileName = "jsons/${ruleset.fullName}"
|
||||||
val fileHandle = if (consoleMode) FileHandle(fileName)
|
val fileHandle = if (consoleMode) FileHandle(fileName)
|
||||||
else Gdx.files.internal(fileName)
|
else Gdx.files.internal(fileName)
|
||||||
this[ruleset.fullName] = Ruleset().apply { load(fileHandle) }
|
this[ruleset.fullName] = Ruleset().apply { load(fileHandle, printOutput) }
|
||||||
}
|
}
|
||||||
|
|
||||||
val modsHandles = if(consoleMode) FileHandle("mods").list()
|
val modsHandles = if(consoleMode) FileHandle("mods").list()
|
||||||
@ -220,11 +220,11 @@ object RulesetCache :HashMap<String,Ruleset>() {
|
|||||||
if (modFolder.name().startsWith('.')) continue
|
if (modFolder.name().startsWith('.')) continue
|
||||||
try {
|
try {
|
||||||
val modRuleset = Ruleset()
|
val modRuleset = Ruleset()
|
||||||
modRuleset.load(modFolder.child("jsons"))
|
modRuleset.load(modFolder.child("jsons"), printOutput)
|
||||||
modRuleset.name = modFolder.name()
|
modRuleset.name = modFolder.name()
|
||||||
this[modRuleset.name] = modRuleset
|
this[modRuleset.name] = modRuleset
|
||||||
println("Mod loaded successfully: " + modRuleset.name)
|
if(printOutput) println("Mod loaded successfully: " + modRuleset.name)
|
||||||
checkModLinks(modRuleset)
|
if(printOutput) checkModLinks(modRuleset)
|
||||||
} catch (ex: Exception) {
|
} catch (ex: Exception) {
|
||||||
println("Exception loading mod '${modFolder.name()}':")
|
println("Exception loading mod '${modFolder.name()}':")
|
||||||
println(" ${ex.localizedMessage}")
|
println(" ${ex.localizedMessage}")
|
||||||
|
@ -71,7 +71,7 @@ class Translations : LinkedHashMap<String, TranslationEntry>(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private fun tryReadTranslationForLanguage(language: String) {
|
private fun tryReadTranslationForLanguage(language: String, printOutput: Boolean) {
|
||||||
val translationStart = System.currentTimeMillis()
|
val translationStart = System.currentTimeMillis()
|
||||||
|
|
||||||
val translationFileName = "jsons/translations/$language.properties"
|
val translationFileName = "jsons/translations/$language.properties"
|
||||||
@ -99,7 +99,7 @@ class Translations : LinkedHashMap<String, TranslationEntry>(){
|
|||||||
createTranslations(language, languageTranslations)
|
createTranslations(language, languageTranslations)
|
||||||
|
|
||||||
val translationFilesTime = System.currentTimeMillis() - translationStart
|
val translationFilesTime = System.currentTimeMillis() - translationStart
|
||||||
println("Loading translation file for $language - " + translationFilesTime + "ms")
|
if(printOutput) println("Loading translation file for $language - " + translationFilesTime + "ms")
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun createTranslations(language: String,
|
private fun createTranslations(language: String,
|
||||||
@ -120,7 +120,7 @@ class Translations : LinkedHashMap<String, TranslationEntry>(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun tryReadTranslationForCurrentLanguage(){
|
fun tryReadTranslationForCurrentLanguage(){
|
||||||
tryReadTranslationForLanguage(UncivGame.Current.settings.language)
|
tryReadTranslationForLanguage(UncivGame.Current.settings.language, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
// This function is too strange for me, however, let's keep it "as is" for now. - JackRainy
|
// This function is too strange for me, however, let's keep it "as is" for now. - JackRainy
|
||||||
@ -152,7 +152,7 @@ class Translations : LinkedHashMap<String, TranslationEntry>(){
|
|||||||
.filter { Gdx.files.internal("jsons/translations/$it.properties").exists() }
|
.filter { Gdx.files.internal("jsons/translations/$it.properties").exists() }
|
||||||
}
|
}
|
||||||
|
|
||||||
fun readAllLanguagesTranslation() {
|
fun readAllLanguagesTranslation(printOutput:Boolean=false) {
|
||||||
// Apparently you can't iterate over the files in a directory when running out of a .jar...
|
// Apparently you can't iterate over the files in a directory when running out of a .jar...
|
||||||
// https://www.badlogicgames.com/forum/viewtopic.php?f=11&t=27250
|
// https://www.badlogicgames.com/forum/viewtopic.php?f=11&t=27250
|
||||||
// which means we need to list everything manually =/
|
// which means we need to list everything manually =/
|
||||||
@ -160,11 +160,11 @@ class Translations : LinkedHashMap<String, TranslationEntry>(){
|
|||||||
val translationStart = System.currentTimeMillis()
|
val translationStart = System.currentTimeMillis()
|
||||||
|
|
||||||
for (language in getLanguagesWithTranslationFile()) {
|
for (language in getLanguagesWithTranslationFile()) {
|
||||||
tryReadTranslationForLanguage(language)
|
tryReadTranslationForLanguage(language, printOutput)
|
||||||
}
|
}
|
||||||
|
|
||||||
val translationFilesTime = System.currentTimeMillis() - translationStart
|
val translationFilesTime = System.currentTimeMillis() - translationStart
|
||||||
println("Loading translation files - "+translationFilesTime+"ms")
|
if(printOutput) println("Loading translation files - "+translationFilesTime+"ms")
|
||||||
}
|
}
|
||||||
|
|
||||||
fun loadPercentageCompleteOfLanguages(){
|
fun loadPercentageCompleteOfLanguages(){
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import com.unciv.build.BuildConfig
|
import com.unciv.build.BuildConfig
|
||||||
|
import org.gradle.api.tasks.testing.logging.TestLogEvent
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
id("java")
|
id("java")
|
||||||
@ -11,6 +12,19 @@ java {
|
|||||||
tasks {
|
tasks {
|
||||||
test {
|
test {
|
||||||
workingDir = file("../android/assets")
|
workingDir = file("../android/assets")
|
||||||
|
testLogging.debug {
|
||||||
|
events(
|
||||||
|
TestLogEvent.STARTED,
|
||||||
|
TestLogEvent.FAILED,
|
||||||
|
TestLogEvent.PASSED,
|
||||||
|
TestLogEvent.SKIPPED,
|
||||||
|
TestLogEvent.STANDARD_ERROR,
|
||||||
|
TestLogEvent.STANDARD_OUT
|
||||||
|
)
|
||||||
|
|
||||||
|
exceptionFormat = org.gradle.api.tasks.testing.logging.TestExceptionFormat.FULL
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
compileJava {
|
compileJava {
|
||||||
|
@ -7,12 +7,13 @@ import com.unciv.models.ruleset.Ruleset
|
|||||||
import com.unciv.models.ruleset.RulesetCache
|
import com.unciv.models.ruleset.RulesetCache
|
||||||
import com.unciv.models.translations.TranslationFileWriter
|
import com.unciv.models.translations.TranslationFileWriter
|
||||||
import com.unciv.models.translations.Translations
|
import com.unciv.models.translations.Translations
|
||||||
import com.unciv.models.translations.eitherSquareBraceRegex
|
|
||||||
import com.unciv.models.translations.squareBraceRegex
|
import com.unciv.models.translations.squareBraceRegex
|
||||||
import org.junit.Assert
|
import org.junit.Assert
|
||||||
import org.junit.Before
|
import org.junit.Before
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.junit.runner.RunWith
|
import org.junit.runner.RunWith
|
||||||
|
import java.io.OutputStream
|
||||||
|
import java.io.PrintStream
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
@RunWith(GdxTestRunner::class)
|
@RunWith(GdxTestRunner::class)
|
||||||
@ -22,9 +23,19 @@ class TranslationTests {
|
|||||||
|
|
||||||
@Before
|
@Before
|
||||||
fun loadTranslations() {
|
fun loadTranslations() {
|
||||||
|
// Since the ruleset and translation loader have their own output,
|
||||||
|
// We 'disable' the output stream for their outputs, and only enable it for the twst itself.
|
||||||
|
val outputChannel = System.out
|
||||||
|
System.setOut(PrintStream(object : OutputStream() {
|
||||||
|
override fun write(b: Int) {}
|
||||||
|
}))
|
||||||
|
// System.setOut(TextWriter.Null)
|
||||||
|
// Console(). //(TextWriter.Null);
|
||||||
translations.readAllLanguagesTranslation()
|
translations.readAllLanguagesTranslation()
|
||||||
RulesetCache.loadRulesets()
|
RulesetCache.loadRulesets()
|
||||||
ruleset = RulesetCache.getBaseRuleset()
|
ruleset = RulesetCache.getBaseRuleset()
|
||||||
|
System.setOut(outputChannel)
|
||||||
|
// Console.SetOut()
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
Reference in New Issue
Block a user