Common func to run config tests (#5170)

* Common func to run config tests

* Add map config testing, malden data and reverse map config's latitude

* Headers

* Simplify config levels

* Header

* fix example
This commit is contained in:
PabstMirror 2017-08-22 16:21:41 -05:00 committed by GitHub
parent 74fd0f507f
commit 52915e1104
17 changed files with 213 additions and 34 deletions

View File

@ -135,6 +135,7 @@ PREP(requestCallback);
PREP(resetAllDefaults);
PREP(restoreVariablesJIP);
PREP(runAfterSettingsInit);
PREP(runTests);
PREP(sanitizeString);
PREP(sendRequest);
PREP(serverLog);

View File

@ -89,3 +89,8 @@ class CfgUIGrids {
class ACE_Extensions {
extensions[] = {};
};
class ACE_Tests {
vehicleTransportInventory = QPATHTOF(dev\test_vehicleInventory.sqf);
mapConfigs = QPATHTOF(dev\test_mapConfigs.sqf);
};

View File

@ -0,0 +1,49 @@
// PabstMirror
// ["mapConfigs"] call ace_common_fnc_runTests;
// execVM "z\ace\addons\common\dev\test_mapConfigs.sqf";
#include "\z\ace\addons\common\script_component.hpp"
diag_log text format ["--- Checking Map Configs ---"];
private _testPass = true;
private _maps = configProperties [configFile >> "CfgWorldList", "(isClass _x)", true];
{
private _mapConfigName = configName _x;
private _worldConfig = configFile >> "CfgWorlds" >> _mapConfigName;
private _mapDescription = getText (_worldConfig >> "description");
// Check if custom latitude/elevation in lookup table (ace_common_fnc_getMapData)
private _getMapData = [_mapConfigName] call FUNC(getMapData);
if (_getMapData isEqualTo []) then {
diag_log text format ["%1 [%2] - Not in getMapData",_mapDescription,_mapConfigName];
diag_log text format [" - Using map's config [latitude: %1] [elevationOffset: %2]", getNumber (_worldConfig >> "latitude"), getNumber (_worldConfig >> "elevationOffset")];
};
// Test MGRS grid step size (from ace_common_fnc_getMapGridData)
private _zoomMax = 1e99;
private _formatX = "";
private _formatY = "";
private _stepX = 1e10;
private _stepY = 1e10;
{
private _zoom = getnumber (_x >> "zoomMax");
if (_zoom < _zoomMax) then {
_zoomMax = _zoom;
_formatX = getText (_x >> "formatX");
_formatY = getText (_x >> "formatY");
_stepX = getNumber (_x >> "stepX");
_stepY = getNumber (_x >> "stepY");
};
} forEach configProperties [(_worldConfig >> "Grid"), "isClass _x", false];
private _stepXat5 = _stepX * 10 ^ ((count _formatX) - 5);
private _stepYat5 = -1 * _stepY * 10 ^ ((count _formatY) - 5);
if (_stepYat5 < 0) then {diag_log text format ["%1 [%2] - Northing is reversed.",_mapDescription,_mapConfigName];};
if (_stepXat5 != 1) then {diag_log text format ["%1 [%2] - MGRS 10 digit grid does not equal 1 meter: (%3) for x.",_mapDescription,_mapConfigName,_stepXat5];};
if (_stepYat5 != 1 && {_stepYat5 != -1}) then {diag_log text format ["%1 [%2] - MGRS 10 digit grid does not equal 1 meter: (%3) for y.",_mapDescription,_mapConfigName,_stepXat5];};
} forEach _maps;
// Always return true, these are just warnings
_testPass

View File

@ -0,0 +1,47 @@
// PabstMirror
// ["vehicleTransportInventory"] call ace_common_fnc_runTests;
// execVM "z\ace\addons\common\dev\test_vehicleInventory.sqf";
private _testPass = true;
private _vehicles = configProperties [configFile >> "CfgVehicles", "(isClass _x)", true];
{
private _vehType = configName _x;
{
private _name = getText (_x >> "name");
if (_name != "MineDetector") then { // Vanilla mixes up mineDetector alot?
private _weaponConfig = configFile >> "CfgWeapons" >> _name;
private _glassesConfig = configFile >> "CfgGlasses" >> _name;
if (((!isClass _weaponConfig) || {(getNumber (_weaponConfig >> "type")) in [1,2,4]}) && {!isClass _glassesConfig}) then {
diag_log text format ["%1 -> TransportItems -> %2 = Bad", _vehType, _name];
_testPass = false;
};
};
} forEach (configProperties [_x >> "TransportItems", "isClass _x", true]);
{
private _name = getText (_x >> "weapon");
private _weaponConfig = configFile >> "CfgWeapons" >> _name;
if ((!isClass _weaponConfig) || {!((getNumber (_weaponConfig >> "type")) in [1,2,4])}) then {
diag_log text format ["%1 -> TransportWeapons -> %2 = Bad", _vehType, _name];
_testPass = false;
};
} forEach (configProperties [_x >> "TransportWeapons", "isClass _x", true]);
{
private _name = getText (_x >> "magazine");
private _magConfig = configFile >> "CfgMagazines" >> _name;
if ((!isClass _magConfig)) then {
diag_log text format ["%1 -> TransportMagazines -> %2 = Bad", _vehType, _name];
_testPass = false;
};
} forEach (configProperties [_x >> "TransportMagazines", "isClass _x", true]);
{
private _name = getText (_x >> "backpack");
private _vehConfig = configFile >> "CfgVehicles" >> _name;
if ((!isClass _vehConfig)) then {
diag_log text format ["%1 -> TransportBackpacks -> %2 = Bad", _vehType, _name];
_testPass = false;
};
} forEach (configProperties [_x >> "TransportBackpacks", "isClass _x", true]);
} forEach _vehicles;
_testPass

View File

@ -22,7 +22,7 @@
params [["_map", worldName]];
private _long = getNumber (configFile >> "CfgWorlds" >> _map >> "longitude");
private _lat = getNumber (configFile >> "CfgWorlds" >> _map >> "latitude");
private _lat = -1 * getNumber (configFile >> "CfgWorlds" >> _map >> "latitude"); // latitude is reversed in arma (negative config values in north)
private _altitude = getNumber (configFile >> "CfgWorlds" >> _map >> "elevationOffset");
private _mapData = _map call FUNC(getMapData);

View File

@ -31,6 +31,7 @@ if (_map in ["abramia"]) exitWith { [60, 0] };
if (_map in ["af_kandahar_province"]) exitWith { [42, 0] };
if (_map in ["angel"]) exitWith { [38, 0] };
if (_map in ["anim_helvantis_v2"]) exitWith { [50, 0] };
if (_map in ["anim_starokovka"]) exitWith { [50, 0] };
if (_map in ["australia"]) exitWith { [-25, 0] };
if (_map in ["baranow", "ivachev", "panavo", "staszow"]) exitWith { [50, 148.1] }; // IFA3LITE - default elevationOffset
if (_map in ["beketov"]) exitWith { [55, 0] };

View File

@ -68,15 +68,13 @@ private _stepXat5 = _stepX * 10 ^ ((count _formatX) - 5);
private _stepYat5 = -1 * _stepY * 10 ^ ((count _formatY) - 5);
if (_stepYat5 < 0) then {
WARNING_1("Map Grid Warning (%1) - Northing is reversed.",worldName);
TRACE_1("Northing is reversed",worldName);
};
if (_stepXat5 != 1) then {
WARNING_2("Map Grid Warning (%1) - MGRS 10 digit grid does not equal 1 meter: (%2) for x.",worldName,_stepXat5);
TRACE_2("MGRS 10 digit grid does not equal 1 meter",_stepXat5,worldName);
};
if (_stepYat5 != 1 && {_stepYat5 != -1}) then {
WARNING_2("Map Grid Warning (%1) - MGRS 10 digit grid does not equal 1 meter: (%2) for y.",worldName,_stepXat5);
TRACE_2("MGRS 10 digit grid does not equal 1 meter",_stepYat5,worldName);
};
GVAR(mapGridData) = [_offsetX, _realOffsetY, _stepXat5, _stepYat5];

View File

@ -0,0 +1,48 @@
/*
* Author: PabstMirror
* Run test functions.
*
* Arguments:
* 0: Specific test to run (default is to run all) <STRING> (default: #all)
*
* Return Value:
* None
*
* Example:
* [] call ace_common_fnc_runTests
* ["fcs"] call ace_common_fnc_runTests
*
* Public: Yes
*/
#include "script_component.hpp"
params [["_specificTest", "#all", [""]]];
private _startTime = diag_tickTime;
private _fails = [];
private _total = 0;
INFO_1("ace_common_fnc_runTests starting for [%1]", _specificTest);
{
private _testName = configName _x;
if ((_specificTest == "#all") || {_specificTest == _testName}) then {
_total = _total + 1;
private _testFile = getText _x;
diag_log text format ["----- Starting Testing %1 [%2] -----", _testName, _testFile];
private _return = ([nil] apply (compile preProcessFileLineNumbers _testFile)) select 0;
if ((isNil "_return") || {!(_return isEqualTo true)}) then {
systemChat format ["Test [%1] Failed", _testName];
diag_log text format ["----- Finished Testing %1 [Failed] -----", _testName];
_fails pushBack _testName;
} else {
diag_log text format ["----- Finished Testing %1 [Passed] -----", _testName];
};
};
} forEach (configProperties [configFile >> "ACE_Tests"]);
INFO_1("ace_common_fnc_runTests finished in %1 ms", (1000 * (diag_tickTime - _startTime)) toFixed 1);
INFO_2("[%1 / %2] Tests Passed", (_total - (count _fails)), _total);
if (!(_fails isEqualTo [])) then {
INFO_1("Failed: %1", _fails);
};

View File

@ -30,3 +30,7 @@ class CfgPatches {
class ACE_Extensions {
extensions[] += {"ace_fcs"};
};
class ACE_Tests {
fcs = QPATHTOF(dev\test_debugConfigs.sqf);
};

View File

@ -1,5 +1,8 @@
// PabstMirror
#include "script_component.hpp"
// ["fcs"] call ace_common_fnc_runTests;
// execVM "z\ace\addons\fcs\dev\test_debugConfigs.sqf;
private _testPass = true;
diag_log text format ["[ACE_FCS] ---------------"];
private _vehicles = configProperties [configFile >> "CfgVehicles", "(isClass _x) && {2 == getNumber (_x >> 'scope')}", true];
@ -20,7 +23,10 @@ private _problemUIs = [];
_ballisticComputer = [_ballisticComputer, 5] call ace_common_fnc_toBin;
if ((_ballisticComputer select [(count _ballisticComputer) - 5, 1]) == "1") then {
_vanillaFCS = true;
if (_aceFCS) then {diag_log text format ["%1 -> %2: ACE FCS Enabled CONFLICTS with vanilla FCS [%3]", _vehicleType, _weapon, _ballisticComputer];};
if (_aceFCS) then {
_testPass = false;
diag_log text format ["%1 -> %2: ACE FCS Enabled CONFLICTS with vanilla FCS [%3]", _vehicleType, _weapon, _ballisticComputer];
};
};
} forEach _weapons;
@ -76,7 +82,8 @@ private _problemUIs = [];
};
};
};
} forEach [[0],[0,0]];
// } forEach [[0],[0,0]];
} forEach [[0],[0,0], [1], [2]];
} forEach _vehicles;
_problemUIs sort true;
@ -86,3 +93,5 @@ diag_log text format ["[ACE_FCS] ------- Problem UIs --------"];
diag_log text format ["- %1", _x];
} forEach _problemUIs;
diag_log text format ["[ACE_FCS] ---------------"];
_testPass

View File

@ -106,12 +106,8 @@ class CfgVehicles {
GVAR(defaultSupply) = 1200;
};
class Truck_02_Ammo_base_F;
class I_Truck_02_ammo_F: Truck_02_Ammo_base_F {
transportAmmo = 0;
GVAR(defaultSupply) = 1200;
};
class O_Truck_02_Ammo_F: Truck_02_Ammo_base_F {
class Truck_02_base_F;
class Truck_02_Ammo_base_F: Truck_02_base_F {
transportAmmo = 0;
GVAR(defaultSupply) = 1200;
};

View File

@ -24,10 +24,3 @@ if (isServer) then {
[QGVAR(rearmSuccessEH), LINKFUNC(rearmSuccess)] call CBA_fnc_addEventHandler;
[QGVAR(rearmSuccessLocalEH), LINKFUNC(rearmSuccessLocal)] call CBA_fnc_addEventHandler;
#ifdef DEBUG_MODE_FULL
INFO("Showing CfgVehicles with vanilla transportAmmo");
{
WARNING_2("Type [%1] needs config [transportAmmo: %2]", configName _x, getNumber (_x >> 'transportAmmo'));
} forEach (configProperties [configFile >> "CfgVehicles", "(isClass _x) && {(getNumber (_x >> 'transportAmmo')) > 0}", true]);
#endif

View File

@ -20,3 +20,7 @@ class CfgPatches {
#include "CfgAmmo.hpp"
#include "CfgMagazines.hpp"
#include "CfgVehicles.hpp"
class ACE_Tests {
vehicleTransportAmmo = QPATHTOF(dev\test_debugConfigs.sqf);
};

View File

@ -0,0 +1,14 @@
// ["vehicleTransportAmmo"] call ace_common_fnc_runTests;
// execVM "z\ace\addons\rearm\dev\test_debugConfigs.sqf";
#include "\z\ace\addons\rearm\script_component.hpp"
private _testPass = true;
INFO("Showing CfgVehicles with vanilla transportAmmo");
{
WARNING_2("Type [%1] needs config [transportAmmo: %2]", configName _x, getNumber (_x >> 'transportAmmo'));
_testPass = false;
} forEach (configProperties [configFile >> "CfgVehicles", "(isClass _x) && {(getNumber (_x >> 'transportAmmo')) > 0}", true]);
_testPass

View File

@ -26,18 +26,6 @@ if (hasInterface) then {
};
#ifdef DEBUG_MODE_FULL
diag_log text format ["[ACE-refuel] Showing CfgVehicles with vanilla transportFuel"];
private _fuelTrucks = configProperties [configFile >> "CfgVehicles", "(isClass _x) && {(getNumber (_x >> 'transportFuel')) > 0}", true];
{
if ((configName _x) isKindOf "Car") then {
diag_log text format ["Car [%1] needs config [fuel: %2]", configName _x, getNumber (_x >> 'transportFuel')];
} else {
diag_log text format ["Non-car? [%1] needs config [fuel: %2]", configName _x, getNumber (_x >> 'transportFuel')];
};
} forEach _fuelTrucks;
#endif
#ifdef DRAW_HOOKS_POS
addMissionEventHandler ["Draw3D", {
private _target = cursorObject;

View File

@ -17,3 +17,7 @@ class CfgPatches {
#include "ACE_Settings.hpp"
#include "CfgEventHandlers.hpp"
#include "CfgVehicles.hpp"
class ACE_Tests {
vehicleTransportFuel = QPATHTOF(dev\test_debugConfigs.sqf);
};

View File

@ -0,0 +1,18 @@
// ["vehicleTransportFuel"] call ace_common_fnc_runTests;
// execVM "z\ace\addons\refuel\dev\test_debugConfigs.sqf";
#include "\z\ace\addons\refuel\script_component.hpp"
private _testPass = true;
diag_log text format ["[ACE-refuel] Showing CfgVehicles with vanilla transportFuel"];
private _fuelTrucks = configProperties [configFile >> "CfgVehicles", "(isClass _x) && {(getNumber (_x >> 'transportFuel')) > 0}", true];
{
if ((configName _x) isKindOf "Car") then {
diag_log text format ["Car [%1] needs config [transportFuel: %2]", configName _x, getNumber (_x >> 'transportFuel')];
} else {
diag_log text format ["Non-car? [%1] needs config [transportFuel: %2]", configName _x, getNumber (_x >> 'transportFuel')];
};
} forEach _fuelTrucks;
_testPass