This repository has been archived by the owner on Jun 25, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This will test the loader/parser bit. Not in love with the idea of writing real unit tests for the GUI portion - as useful as they can be, it's a time commitment, and I'd rather work on features.
- Loading branch information
Showing
25 changed files
with
285 additions
and
3 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,137 @@ | ||
// _______ __ ______ __ __ | ||
// | | |.-----.--| | | |--.-----.----.| |--.-----.----. | ||
// | || _ | _ | ---| | -__| __|| <| -__| _| | ||
// |__|_|__||_____|_____|______|__|__|_____|____||__|__|_____|__| | ||
|
||
// Test to make sure the mod reader is working as expected | ||
|
||
// (c) 2021 JTSage. MIT License. | ||
require('colors') | ||
const path = require('path') | ||
const c = require('ansi-colors') | ||
const Diff = require('diff') | ||
|
||
const gameFolder = path.join(__dirname, 'testRunnerMods') | ||
const fileFolder = path.join(gameFolder, 'mods') | ||
|
||
const modReader = require('../lib/mod-checker.js') | ||
const translator = require('../lib/translate.js') | ||
const myTranslator = new translator.translator('en') | ||
|
||
const modList = new modReader(gameFolder, fileFolder, myTranslator.deferCurrentLocale) | ||
|
||
const expectedConflictList = ['EXAMPLE_Good_Mod_Folder_and_Zip'] | ||
const expectedBrokenList = [ | ||
['EXAMPLE_Broken_Zip_File', | ||
['FILE_ERROR_UNREADABLE_ZIP'] | ||
], | ||
['EXAMPLE_Garbage_File', | ||
['FILE_ERROR_NAME_INVALID', 'FILE_ERROR_GARBAGE_FILE'] | ||
], | ||
['EXAMPLE_Good_Mod (1)', | ||
['FILE_ERROR_LIKELY_COPY', 'FILE_ERROR_NAME_INVALID'] | ||
], | ||
['EXAMPLE_Good_Mod - Copy', | ||
['FILE_ERROR_LIKELY_COPY', 'FILE_ERROR_NAME_INVALID'] | ||
], | ||
['EXAMPLE_Good_Mod_Folder_and_Zip', | ||
['CONFLICT_ERROR_FOLDER_AND_FILE'] | ||
], | ||
['EXAMPLE_Good_Mod_Folder_Warning', | ||
['INFO_NO_MULTIPLAYER_UNZIPPED'] | ||
], | ||
['EXAMPLE_Good_Mod_No_Original - Copy', | ||
['FILE_ERROR_LIKELY_COPY', 'FILE_ERROR_NAME_INVALID'] | ||
], | ||
['EXAMPLE_Icon_Not_Found', | ||
['MOD_ERROR_NO_MOD_ICON'] | ||
], | ||
['EXAMPLE_Malformed_ModDesc', | ||
['MOD_ERROR_MODDESC_DAMAGED_RECOVERABLE'] | ||
], | ||
['EXAMPLE_Missing_ModDesc', | ||
['NOT_MOD_MODDESC_MISSING'] | ||
], | ||
['EXAMPLE_No_Icon', | ||
['MOD_ERROR_NO_MOD_ICON'] | ||
], | ||
['EXAMPLE_No_Version', | ||
['MOD_ERROR_NO_MOD_VERSION'] | ||
], | ||
['EXAMPLE_Old_ModDesc', | ||
['NOT_MOD_MODDESC_VERSION_OLD_OR_MISSING'] | ||
], | ||
['EXAMPLE_Really_Malformed_ModDesc', | ||
['MOD_ERROR_MODDESC_DAMAGED_RECOVERABLE', 'MOD_ERROR_NO_MOD_ICON'] | ||
] | ||
] | ||
const expectedGoodList = [ | ||
['EXAMPLE_Good_Mod', 'Totally valid FS19 Mod', '1.0.0.0'], | ||
['EXAMPLE_Good_Mod_Folder_and_Zip', 'Totally valid FS19 Mod', '1.0.0.0'], | ||
['EXAMPLE_Good_Mod_Folder_Warning', 'Totally valid FS19 Mod', '1.0.0.0'], | ||
['EXAMPLE_Malformed_ModDesc', 'Mod with malformed XML', '1.0.0.0'] | ||
] | ||
|
||
|
||
modList.readAll().then(() => { | ||
console.log(c.cyan('NOTICE: File Read Done, Testing Proceeding Async - Calling First Search, will return when testing is complete.')) | ||
|
||
/* Check broken list */ | ||
modList.getBrokenList(['shortName', 'failedTestList']).then((results) => { | ||
if (JSON.stringify(expectedBrokenList) === JSON.stringify(results)) { | ||
console.log(c.green('PASS: Broken list is as expected')) | ||
} else { | ||
console.log(c.red('FAIL: Broken list is not as expected')) | ||
const diff = Diff.diffChars(JSON.stringify(expectedBrokenList), JSON.stringify(results)) | ||
|
||
diff.forEach((part) => { | ||
const color = part.added ? 'green' : | ||
part.removed ? 'red' : 'grey' | ||
process.stderr.write(part.value[color]) | ||
}) | ||
console.log() | ||
} | ||
}) | ||
|
||
/* Check conflict list */ | ||
modList.conflictList('').then((results) => { | ||
const simpleResults = results.map((x) => { return x[0] }) | ||
if (JSON.stringify(simpleResults) === JSON.stringify(expectedConflictList)) { | ||
console.log(c.green('PASS: Conflict list is as expected')) | ||
} else { | ||
console.log(c.red('FAIL: Conflict list is not as expected')) | ||
const diff = Diff.diffChars(JSON.stringify(expectedConflictList), JSON.stringify(simpleResults)) | ||
|
||
diff.forEach((part) => { | ||
const color = part.added ? 'green' : | ||
part.removed ? 'red' : 'grey' | ||
process.stderr.write(part.value[color]) | ||
}) | ||
console.log() | ||
} | ||
}) | ||
|
||
/* Check good list */ | ||
modList.search({ | ||
columns : ['shortName', 'title', 'mod_version'], | ||
allTerms : true, | ||
terms : ['isNotMissing', 'didTestingPassEnough'], | ||
}).then((results) => { | ||
if (JSON.stringify(expectedGoodList) === JSON.stringify(results)) { | ||
console.log(c.green('PASS: Good list is as expected')) | ||
} else { | ||
console.log(c.red('FAIL: Good list is not as expected')) | ||
const diff = Diff.diffChars(JSON.stringify(expectedGoodList), JSON.stringify(results)) | ||
|
||
diff.forEach((part) => { | ||
const color = part.added ? 'green' : | ||
part.removed ? 'red' : 'grey' | ||
process.stderr.write(part.value[color]) | ||
}) | ||
console.log() | ||
} | ||
}) | ||
}) | ||
|
||
|
||
console.log(c.cyan('NOTICE: End File Code. There may (should!) still be running async processes')) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<?xml version="1.0" encoding="utf-8" standalone="no" ?> | ||
<gameSettings revision="15"> | ||
<modsDirectoryOverride active="false" directory="C:/Users/PC/Desktop/GitHub Projects/FS19_Mod_Checker/testFolder/modsingle"/> | ||
<defaultMultiplayerPort>10823</defaultMultiplayerPort> | ||
<motorStopTimerDuration>30</motorStopTimerDuration> | ||
<horseAbandonTimerDuration>1800</horseAbandonTimerDuration> | ||
<invertYLook>false</invertYLook> | ||
<isHeadTrackingEnabled>true</isHeadTrackingEnabled> | ||
<isGamepadEnabled>true</isGamepadEnabled> | ||
<cameraSensitivity>1.500000</cameraSensitivity> | ||
<vehicleArmSensitivity>1.000000</vehicleArmSensitivity> | ||
<steeringBackSpeed>6.000000</steeringBackSpeed> | ||
<steeringSensitivity>0.750000</steeringSensitivity> | ||
<inputHelpMode>2</inputHelpMode> | ||
<easyArmControl>true</easyArmControl> | ||
<showAllMods>true</showAllMods> | ||
<player index="2" bodyIndex="1" colorIndex="16" hatIndex="0" hairIndex="1" accessoryIndex="0" jacketIndex="0" name="JTSage"/> | ||
<mpLanguage>0</mpLanguage> | ||
<volume> | ||
<music>0.000000</music> | ||
<vehicle>0.800000</vehicle> | ||
<environment>0.800000</environment> | ||
<radio>0.500000</radio> | ||
<gui>0.500000</gui> | ||
</volume> | ||
<soundPlayer allowStreams="false"/> | ||
<radioIsActive>false</radioIsActive> | ||
<radioVehicleOnly>true</radioVehicleOnly> | ||
<units> | ||
<money>2</money> | ||
<miles>false</miles> | ||
<fahrenheit>true</fahrenheit> | ||
<acre>false</acre> | ||
</units> | ||
<isTrainTabbable>true</isTrainTabbable> | ||
<showTriggerMarker>true</showTriggerMarker> | ||
<showFieldInfo>true</showFieldInfo> | ||
<showHelpIcons>true</showHelpIcons> | ||
<showHelpMenu>false</showHelpMenu> | ||
<resetCamera>false</resetCamera> | ||
<useWorldCamera>true</useWorldCamera> | ||
<ingameMapState>0</ingameMapState> | ||
<ingameMapFilter>0</ingameMapFilter> | ||
<useColorblindMode>false</useColorblindMode> | ||
<maxNumMirrors>3</maxNumMirrors> | ||
<lightsProfile>2</lightsProfile> | ||
<fovY>65.000000</fovY> | ||
<uiScale>0.900000</uiScale> | ||
<realBeaconLights>true</realBeaconLights> | ||
<precisionFarming initialized="true"/> | ||
<joinGame hasNoPassword="false" isNotEmpty="false" onlyWithAllModsAvailable="false" serverName="" mapId="" language="255" capacity="16"/> | ||
</gameSettings> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
r,gkjberkgiher;oigher;oigh |
Empty file.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added
BIN
+12.2 KB
test/testRunnerMods/mods/EXAMPLE_Good_Mod_Folder_Warning/EXAMPLE_Good_Mod.zip
Binary file not shown.
42 changes: 42 additions & 0 deletions
42
test/testRunnerMods/mods/EXAMPLE_Good_Mod_Folder_Warning/modDesc.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?xml version="1.0" encoding="utf-8" standalone="no" ?> | ||
<modDesc descVersion="53"> | ||
<author>FSModCheck Test</author> | ||
|
||
<title> <en>Totally valid FS19 Mod</en></title> | ||
|
||
<description> | ||
<en><![CDATA[Demonstates how FSModCheck handles a good mod file.]]></en> | ||
</description> | ||
|
||
<version>1.0.0.0</version> | ||
|
||
|
||
<iconFilename>modIcon.dds</iconFilename> | ||
<multiplayer supported="true"/> | ||
|
||
<storeItems> | ||
<storeItem xmlFilename="Dolly.xml"/> | ||
</storeItems> | ||
|
||
<l10n> | ||
<text name="config_5WLocking"><en>5th Wheel Locking</en><fr>Verrouillage de la cinquième roue</fr><de>Sattelkupplung Verriegeln</de><it>Quinta ruota di bloccaggio</it><ru>Блокировка пятого колеса</ru><nl>Fifth Wheel vergrendeling</nl><pl>Blokada piątego koła</pl><cz>Uzamčení točnice</cz><es>Bloqueo de quinta rueda</es><pt>Travamento da quinta roda</pt></text> | ||
<text name="config_5WNoLocking"><en>Locking disabled</en><fr>Verrouillage désactivé</fr><de>Sperre deaktiviert</de><it>Blocco disabilitato</it><ru>Блокировка отключена</ru><nl>Vergrendeling uitgeschakeld</nl><pl>Blokowanie wyłączone</pl><cz>Zamykání deaktivováno</cz><es>Bloqueo desactivado</es><pt>Bloqueio desativado</pt></text> | ||
<text name="config_5WGentleLocking"><en>Gentle locking</en><fr>Verrouillage doux</fr><de>Schonendes Verriegeln</de><it>Chiusura delicata</it><ru>Бережная блокировка</ru><nl>Zachte vergrendeling</nl><pl>Delikatne blokowanie</pl><cz>Jemné zamykání</cz><es>Bloqueo suave</es><pt>Travamento suave</pt></text> | ||
<text name="config_5WSemiLocking"><en>Partial locking</en><fr>Verrouillage partiel</fr><de>Teilverriegelung</de><it>Chiusura parziale</it><ru>Частичная блокировка</ru><nl>Gedeeltelijke vergrendeling</nl><pl>Częściowe ryglowanie</pl><cz>Částečné zajištění</cz><es>Bloqueo parcial</es><pt>Bloqueio parcial</pt></text> | ||
<text name="config_5WHardLocking"><en>Hard Locking</en><fr>Verrouillage dur</fr><de>Harte Verriegelung</de><it>Blocco duro</it><ru>Жесткая блокировка</ru><nl>Harde vergrendeling</nl><pl>Twarde blokowanie</pl><cz>Pevné zamykání</cz><es>Bloqueo duro</es><pt>Travamento rígido</pt></text> | ||
</l10n> | ||
|
||
<brandColors> <!-- 2 is for metallic/chrome version to match version 1 better --> | ||
<color name="MANTRID_RED1" value="0.2866 0.0025 0.0025 1" /> | ||
<color name="MANTRID_RED2" value="0.5732 0.0050 0.0050 1" /> | ||
<color name="MANTRID_GREEN1" value="0.0300 0.1569 0.0110 1" /> | ||
<color name="MANTRID_GREEN2" value="0.0600 0.2801 0.0254 1" /> | ||
</brandColors> | ||
|
||
<vehicleSchemaOverlays filename="textures/vehicleSchemaMantrid.dds" imageSize="256 256"> | ||
<overlay name="DOLLY" uvs="28px 0px 64px 64px" size="60px 30px"/> | ||
<overlay name="DOLLY_SELECTED" uvs="28px 65px 64px 64px" size="60px 30px"/> | ||
</vehicleSchemaOverlays> | ||
|
||
|
||
</modDesc> |
Binary file not shown.
Binary file not shown.
Binary file added
BIN
+12.2 KB
test/testRunnerMods/mods/EXAMPLE_Good_Mod_Folder_and_Zip/EXAMPLE_Good_Mod.zip
Binary file not shown.
42 changes: 42 additions & 0 deletions
42
test/testRunnerMods/mods/EXAMPLE_Good_Mod_Folder_and_Zip/modDesc.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?xml version="1.0" encoding="utf-8" standalone="no" ?> | ||
<modDesc descVersion="53"> | ||
<author>FSModCheck Test</author> | ||
|
||
<title> <en>Totally valid FS19 Mod</en></title> | ||
|
||
<description> | ||
<en><![CDATA[Demonstates how FSModCheck handles a good mod file.]]></en> | ||
</description> | ||
|
||
<version>1.0.0.0</version> | ||
|
||
|
||
<iconFilename>modIcon.dds</iconFilename> | ||
<multiplayer supported="true"/> | ||
|
||
<storeItems> | ||
<storeItem xmlFilename="Dolly.xml"/> | ||
</storeItems> | ||
|
||
<l10n> | ||
<text name="config_5WLocking"><en>5th Wheel Locking</en><fr>Verrouillage de la cinquième roue</fr><de>Sattelkupplung Verriegeln</de><it>Quinta ruota di bloccaggio</it><ru>Блокировка пятого колеса</ru><nl>Fifth Wheel vergrendeling</nl><pl>Blokada piątego koła</pl><cz>Uzamčení točnice</cz><es>Bloqueo de quinta rueda</es><pt>Travamento da quinta roda</pt></text> | ||
<text name="config_5WNoLocking"><en>Locking disabled</en><fr>Verrouillage désactivé</fr><de>Sperre deaktiviert</de><it>Blocco disabilitato</it><ru>Блокировка отключена</ru><nl>Vergrendeling uitgeschakeld</nl><pl>Blokowanie wyłączone</pl><cz>Zamykání deaktivováno</cz><es>Bloqueo desactivado</es><pt>Bloqueio desativado</pt></text> | ||
<text name="config_5WGentleLocking"><en>Gentle locking</en><fr>Verrouillage doux</fr><de>Schonendes Verriegeln</de><it>Chiusura delicata</it><ru>Бережная блокировка</ru><nl>Zachte vergrendeling</nl><pl>Delikatne blokowanie</pl><cz>Jemné zamykání</cz><es>Bloqueo suave</es><pt>Travamento suave</pt></text> | ||
<text name="config_5WSemiLocking"><en>Partial locking</en><fr>Verrouillage partiel</fr><de>Teilverriegelung</de><it>Chiusura parziale</it><ru>Частичная блокировка</ru><nl>Gedeeltelijke vergrendeling</nl><pl>Częściowe ryglowanie</pl><cz>Částečné zajištění</cz><es>Bloqueo parcial</es><pt>Bloqueio parcial</pt></text> | ||
<text name="config_5WHardLocking"><en>Hard Locking</en><fr>Verrouillage dur</fr><de>Harte Verriegelung</de><it>Blocco duro</it><ru>Жесткая блокировка</ru><nl>Harde vergrendeling</nl><pl>Twarde blokowanie</pl><cz>Pevné zamykání</cz><es>Bloqueo duro</es><pt>Travamento rígido</pt></text> | ||
</l10n> | ||
|
||
<brandColors> <!-- 2 is for metallic/chrome version to match version 1 better --> | ||
<color name="MANTRID_RED1" value="0.2866 0.0025 0.0025 1" /> | ||
<color name="MANTRID_RED2" value="0.5732 0.0050 0.0050 1" /> | ||
<color name="MANTRID_GREEN1" value="0.0300 0.1569 0.0110 1" /> | ||
<color name="MANTRID_GREEN2" value="0.0600 0.2801 0.0254 1" /> | ||
</brandColors> | ||
|
||
<vehicleSchemaOverlays filename="textures/vehicleSchemaMantrid.dds" imageSize="256 256"> | ||
<overlay name="DOLLY" uvs="28px 0px 64px 64px" size="60px 30px"/> | ||
<overlay name="DOLLY_SELECTED" uvs="28px 65px 64px 64px" size="60px 30px"/> | ||
</vehicleSchemaOverlays> | ||
|
||
|
||
</modDesc> |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.