1
0
mirror of https://github.com/rwengine/openrw.git synced 2024-11-22 02:12:45 +01:00

Remove RW_TEST_WITH_DATA from test code

This commit is contained in:
Daniel Evans 2019-01-18 01:29:59 +00:00
parent 530a7d35ac
commit 6f9e23acc9
29 changed files with 46 additions and 107 deletions

View File

@ -13,7 +13,6 @@ set(_ARGS_BOOL
BUILD_VIEWER
RUN_TESTS
TESTS_NODATA
SEPARATE_TEST_SUITES
RUN_MEMCHECK
@ -164,7 +163,6 @@ set(_CONFIGURE_OPTIONS
"-DBUILD_TOOLS=${BUILD_TOOLS}"
"-DBUILD_VIEWER=${BUILD_VIEWER}"
"-DBUILD_TESTS=TRUE"
"-DTESTS_NODATA=${TESTS_NODATA}"
"-DTEST_COVERAGE=${TEST_COVERAGE}"
"-DSEPARATE_TEST_SUITES=${SEPARATE_TEST_SUITES}"
"-DCHECK_IWYU=${CHECK_IWYU}"

View File

@ -52,9 +52,8 @@ set(RUN_MEMCHECK FALSE)
openrw_should_submit_ci(SUBMIT)
# Build with no data and test
set(BUILDER_NAME "${BUILDER_NAME_BASE}-nodata")
set(BUILDER_NAME "${BUILDER_NAME_BASE}")
set(APPEND_RESULTS FALSE)
set(TESTS_NODATA TRUE)
set(RUN_TESTS TRUE)
if($ENV{TEST_COVERAGE})
set(TEST_COVERAGE TRUE)
@ -66,14 +65,4 @@ set(CODECOV_FLAGS "nodata")
include("${CTEST_SCRIPT_DIRECTORY}/build.ctest")
# Build with data and do not test
set(BUILDER_NAME "${BUILDER_NAME_BASE}-data")
set(APPEND_RESULTS FALSE)
set(TESTS_NODATA FALSE)
set(RUN_TESTS FALSE)
set(CODECOV_FLAGS "data")
include("${CTEST_SCRIPT_DIRECTORY}/build.ctest")
handle_warnings_errors()

View File

@ -62,7 +62,6 @@ else()
set(RES FALSE)
endif()
set(TESTS_NODATA FALSE)
set(RUN_TESTS TRUE)
set(SUBMIT $ENV{SUBMIT})

View File

@ -7,7 +7,7 @@ option(BUILD_VIEWER "Build GUI data viewer")
option(ENABLE_SCRIPT_DEBUG "Enable verbose script execution")
option(ENABLE_PROFILING "Enable detailed profiling metrics")
option(TESTS_NODATA "Build tests for no-data testing")
option(TEST_DATA "Enable tests that require game data")
set(FAILED_CHECK_ACTION "IGNORE" CACHE STRING "What action to perform on a failed RW_CHECK (in debug mode)")
set_property(CACHE FAILED_CHECK_ACTION PROPERTY STRINGS "IGNORE" "ABORT" "BREAKPOINT")

View File

@ -9,14 +9,12 @@ class OpenrwConan(ConanFile):
description = "OpenRW 'Open ReWrite' is an un-official open source recreation of the classic Grand Theft Auto III game executable"
settings = 'os', 'compiler', 'build_type', 'arch'
options = {
'test_data': [True, False],
'viewer': [True, False],
'tools': [True, False],
'profiling': [True, False],
}
default_options = {
'test_data': False,
'viewer': True,
'tools': True,
'profiling': True,
@ -68,7 +66,6 @@ class OpenrwConan(ConanFile):
'BUILD_TESTS': True,
'BUILD_VIEWER': self.options.viewer,
'BUILD_TOOLS': self.options.tools,
'TESTS_NODATA': not self.options.test_data,
'ENABLE_PROFILING': self.options.profiling,
'USE_CONAN': True,
'BOOST_STATIC': not self.options['boost'].shared,

View File

@ -53,11 +53,6 @@ add_executable(rwtests
${TEST_SOURCES}
)
target_compile_definitions(rwtests
PRIVATE
"RW_TEST_WITH_DATA=$<NOT:$<BOOL:${TESTS_NODATA}>>"
)
target_include_directories(rwtests
PRIVATE
"${PROJECT_SOURCE_DIR}/tests"
@ -97,3 +92,9 @@ else()
TIMEOUT 300
)
endif()
if(TEST_DATA)
add_test(NAME DataTests
COMMAND "$<TARGET_FILE:rwtests>" "--run_test=@data-test"
)
endif()

View File

@ -5,9 +5,8 @@
#include <glm/gtx/string_cast.hpp>
#include "test_Globals.hpp"
BOOST_AUTO_TEST_SUITE(AnimationTests)
BOOST_AUTO_TEST_SUITE(AnimationTests, DATA_TEST_PREDICATE)
#if RW_TEST_WITH_DATA
BOOST_AUTO_TEST_CASE(test_matrix) {
{
auto animation = std::make_shared<Animation>();
@ -44,6 +43,5 @@ BOOST_AUTO_TEST_CASE(test_matrix) {
glm::vec3(0.f, 1.f, 0.f));
}
}
#endif
BOOST_AUTO_TEST_SUITE_END()

View File

@ -2,9 +2,8 @@
#include <loaders/LoaderIMG.hpp>
#include "test_Globals.hpp"
BOOST_AUTO_TEST_SUITE(ArchiveTests)
BOOST_AUTO_TEST_SUITE(ArchiveTests, DATA_TEST_PREDICATE)
#if RW_TEST_WITH_DATA
BOOST_AUTO_TEST_CASE(test_open_archive) {
LoaderIMG archive;
@ -28,6 +27,5 @@ BOOST_AUTO_TEST_CASE(test_open_archive) {
BOOST_CHECK_EQUAL(f2.offset, f.offset);
BOOST_CHECK_EQUAL(f2.size, f.size);
}
#endif
BOOST_AUTO_TEST_SUITE_END()

View File

@ -2,9 +2,8 @@
#include <objects/VehicleObject.hpp>
#include "test_Globals.hpp"
BOOST_AUTO_TEST_SUITE(BuoyancyTests)
BOOST_AUTO_TEST_SUITE(BuoyancyTests, DATA_TEST_PREDICATE)
#if RW_TEST_WITH_DATA
BOOST_AUTO_TEST_CASE(test_vehicle_buoyancy) {
glm::vec2 tpos(-WATER_WORLD_SIZE / 2.f + 10.f);
{
@ -57,6 +56,5 @@ BOOST_AUTO_TEST_CASE(test_vehicle_buoyancy) {
Global::get().e->destroyObject(vehicle);
}
}
#endif
BOOST_AUTO_TEST_SUITE_END()

View File

@ -5,9 +5,8 @@
#include <objects/VehicleObject.hpp>
#include "test_Globals.hpp"
BOOST_AUTO_TEST_SUITE(CharacterTests)
BOOST_AUTO_TEST_SUITE(CharacterTests, DATA_TEST_PREDICATE)
#if RW_TEST_WITH_DATA
BOOST_AUTO_TEST_CASE(test_create) {
{
auto character =
@ -164,6 +163,5 @@ BOOST_AUTO_TEST_CASE(test_cycle_animating) {
static_cast<uint32_t>(AnimCycle::ArrestGun));
}
}
#endif
BOOST_AUTO_TEST_SUITE_END()

View File

@ -2,9 +2,8 @@
#include <data/Chase.hpp>
#include "test_Globals.hpp"
BOOST_AUTO_TEST_SUITE(ChaseTests)
BOOST_AUTO_TEST_SUITE(ChaseTests, DATA_TEST_PREDICATE)
#if RW_TEST_WITH_DATA
BOOST_AUTO_TEST_CASE(test_load_keyframes) {
std::vector<ChaseKeyframe> keyframes;
BOOST_REQUIRE(ChaseKeyframe::load(
@ -12,6 +11,5 @@ BOOST_AUTO_TEST_CASE(test_load_keyframes) {
BOOST_REQUIRE(keyframes.size() == 5400);
BOOST_CHECK_CLOSE(keyframes[0].position.x, 273.5422, 0.1);
}
#endif
BOOST_AUTO_TEST_SUITE_END()

View File

@ -4,9 +4,8 @@
#include <platform/FileHandle.hpp>
#include "test_Globals.hpp"
BOOST_AUTO_TEST_SUITE(CutsceneTests)
BOOST_AUTO_TEST_SUITE(CutsceneTests, DATA_TEST_PREDICATE)
#if RW_TEST_WITH_DATA
BOOST_AUTO_TEST_CASE(test_load) {
{
auto d = Global::get().e->data->index.openFile("intro.dat");
@ -29,6 +28,5 @@ BOOST_AUTO_TEST_CASE(test_load) {
BOOST_CHECK(tracks.duration == 64.8f);
}
}
#endif
BOOST_AUTO_TEST_SUITE_END()

View File

@ -8,9 +8,8 @@
// Tests against loading various data files
// These tests are bad but so are the interfaces so it cancels out.
BOOST_AUTO_TEST_SUITE(DataTests)
BOOST_AUTO_TEST_SUITE(DataTests, DATA_TEST_PREDICATE)
#if RW_TEST_WITH_DATA
BOOST_AUTO_TEST_CASE(test_weapon_dat) {
GenericDATLoader l;
std::vector<WeaponData> weaponData;
@ -121,6 +120,5 @@ BOOST_AUTO_TEST_CASE(test_model_archive_loaded) {
e->destroyObject(inst);
}
}
#endif
BOOST_AUTO_TEST_SUITE_END()

View File

@ -21,8 +21,7 @@ BOOST_AUTO_TEST_CASE(test_normalizeName) {
}
}
#if RW_TEST_WITH_DATA
BOOST_AUTO_TEST_CASE(test_indexTree) {
BOOST_AUTO_TEST_CASE(test_indexTree, DATA_TEST_PREDICATE) {
FileIndex index;
index.indexTree(Global::getGamePath());
@ -46,7 +45,7 @@ BOOST_AUTO_TEST_CASE(test_indexTree) {
}
}
BOOST_AUTO_TEST_CASE(test_openFile) {
BOOST_AUTO_TEST_CASE(test_openFile, DATA_TEST_PREDICATE) {
FileIndex index;
index.indexTree(Global::getGamePath() + "/data");
@ -54,7 +53,7 @@ BOOST_AUTO_TEST_CASE(test_openFile) {
BOOST_CHECK(handle.data != nullptr);
}
BOOST_AUTO_TEST_CASE(test_indexArchive) {
BOOST_AUTO_TEST_CASE(test_indexArchive, DATA_TEST_PREDICATE) {
FileIndex index;
index.indexTree(Global::getGamePath());
@ -70,6 +69,5 @@ BOOST_AUTO_TEST_CASE(test_indexArchive) {
BOOST_CHECK(handle.data != nullptr);
}
}
#endif
BOOST_AUTO_TEST_SUITE_END()

View File

@ -2,9 +2,8 @@
#include <engine/GameData.hpp>
#include "test_Globals.hpp"
BOOST_AUTO_TEST_SUITE(GameDataTests)
BOOST_AUTO_TEST_SUITE(GameDataTests, DATA_TEST_PREDICATE)
#if RW_TEST_WITH_DATA
BOOST_AUTO_TEST_CASE(test_object_data) {
GameData gd(&Global::get().log, Global::getGamePath());
gd.load();
@ -94,6 +93,5 @@ BOOST_AUTO_TEST_CASE(test_ped_groups) {
BOOST_REQUIRE_GE(red.size(), 8);
BOOST_CHECK_EQUAL(red[0], 34);
}
#endif
BOOST_AUTO_TEST_SUITE_END()

View File

@ -4,9 +4,8 @@
#include <objects/InstanceObject.hpp>
#include "test_Globals.hpp"
BOOST_AUTO_TEST_SUITE(GameWorldTests)
BOOST_AUTO_TEST_SUITE(GameWorldTests, DATA_TEST_PREDICATE)
#if RW_TEST_WITH_DATA
BOOST_AUTO_TEST_CASE(test_gameobject_id) {
auto& gw = *Global::get().e;
@ -67,6 +66,5 @@ BOOST_AUTO_TEST_CASE(test_offsetgametime) {
BOOST_CHECK_EQUAL(9, gw.getHour());
BOOST_CHECK_EQUAL(25, gw.getMinute());
}
#endif
BOOST_AUTO_TEST_SUITE_END()

View File

@ -1,9 +1,8 @@
#include <boost/test/unit_test.hpp>
#include <engine/Garage.hpp>
#include "test_Globals.hpp"
#if RW_TEST_WITH_DATA
BOOST_AUTO_TEST_SUITE(GarageTests)
BOOST_AUTO_TEST_SUITE(GarageTests, DATA_TEST_PREDICATE)
BOOST_AUTO_TEST_CASE(test_garage_interaction) {
{
@ -14,5 +13,3 @@ BOOST_AUTO_TEST_CASE(test_garage_interaction) {
}
BOOST_AUTO_TEST_SUITE_END()
#endif

View File

@ -2,7 +2,6 @@
#include <RWConfig.hpp>
#if RW_TEST_WITH_DATA
std::string Global::getGamePath() {
rwfs::path configPath = RWConfigParser::getDefaultConfigPath() / "openrw.ini";
RWConfigParser cfgParser;
@ -10,4 +9,3 @@ std::string Global::getGamePath() {
BOOST_REQUIRE(parseResult.isValid());
return *cfgLayer.gamedataPath;
}
#endif

View File

@ -19,6 +19,11 @@
#include <objects/GameObject.hpp>
#include <glm/gtx/string_cast.hpp>
#include <memory>
#define DATA_TEST_PREDICATE * boost::unit_test_framework::label("data-test")\
* boost::unit_test_framework::disabled()
std::ostream& operator<<(std::ostream& stream, glm::vec3 const& v);
// Boost moved the print_log_value struct in version 1.59
@ -80,12 +85,13 @@ BOOST_NS_MAGIC_CLOSING
class Global {
public:
GameWindow window;
#if RW_TEST_WITH_DATA
GameData* d;
GameWorld* e;
GameState* s;
std::unique_ptr<GameData> d_;
std::unique_ptr<GameWorld> e_;
std::unique_ptr<GameState> s_;
Logger log;
#endif
Global() {
if (SDL_Init(SDL_INIT_VIDEO) < 0)
@ -94,29 +100,25 @@ public:
window.create("Tests", 800, 600, false);
window.hideCursor();
#if RW_TEST_WITH_DATA
d = new GameData(&log, getGamePath());
d_ = std::make_unique<GameData>(&log, getGamePath());
d = d_.get();
d->load();
e = new GameWorld(&log, d);
s = new GameState;
e_ = std::make_unique<GameWorld>(&log, d);
e = e_.get();
s_ = std::make_unique<GameState>();
s = s_.get();
e->state = s;
e->dynamicsWorld->setGravity(btVector3(0.f, 0.f, 0.f));
#endif
}
~Global() {
window.close();
#if RW_TEST_WITH_DATA
delete e;
#endif
}
#if RW_TEST_WITH_DATA
static std::string getGamePath();
#endif
static Global& get() {
static Global g;

View File

@ -2,9 +2,8 @@
#include <objects/CharacterObject.hpp>
#include "test_Globals.hpp"
BOOST_AUTO_TEST_SUITE(ItemsTests)
BOOST_AUTO_TEST_SUITE(ItemsTests, DATA_TEST_PREDICATE)
#if RW_TEST_WITH_DATA
BOOST_AUTO_TEST_CASE(test_character_inventory) {
{
auto character = Global::get().e->createPedestrian(1, {0.f, 0.f, 0.f});
@ -25,6 +24,5 @@ BOOST_AUTO_TEST_CASE(test_character_inventory) {
Global::get().e->destroyObject(character);
}
}
#endif
BOOST_AUTO_TEST_SUITE_END()

View File

@ -4,9 +4,8 @@
#include <render/ViewCamera.hpp>
#include "test_Globals.hpp"
BOOST_AUTO_TEST_SUITE(LifetimeTests)
BOOST_AUTO_TEST_SUITE(LifetimeTests, DATA_TEST_PREDICATE)
#if RW_TEST_WITH_DATA
BOOST_AUTO_TEST_CASE(test_cleanup) {
GameObject* f =
Global::get().e->createInstance(1337, glm::vec3(0.f, 0.f, 1000.f));
@ -29,6 +28,5 @@ BOOST_AUTO_TEST_CASE(test_cleanup) {
BOOST_CHECK(search != objects.end());
}
}
#endif
BOOST_AUTO_TEST_SUITE_END()

View File

@ -5,8 +5,7 @@
BOOST_AUTO_TEST_SUITE(LoaderDFFTests)
#if RW_TEST_WITH_DATA
BOOST_AUTO_TEST_CASE(test_load_dff) {
BOOST_AUTO_TEST_CASE(test_load_dff, DATA_TEST_PREDICATE) {
{
auto d = Global::get().e->data->index.openFile("landstal.dff");
@ -26,8 +25,6 @@ BOOST_AUTO_TEST_CASE(test_load_dff) {
}
}
#endif
BOOST_AUTO_TEST_CASE(test_clump_clone) {
{
auto frame1 = std::make_shared<ModelFrame>(0);

View File

@ -6,9 +6,8 @@
#include <objects/GameObject.hpp>
#include <objects/InstanceObject.hpp>
#include "test_Globals.hpp"
#if RW_TEST_WITH_DATA
BOOST_AUTO_TEST_SUITE(PayphoneTests)
BOOST_AUTO_TEST_SUITE(PayphoneTests, DATA_TEST_PREDICATE)
BOOST_AUTO_TEST_CASE(test_payphone_interaction) {
{
@ -68,5 +67,3 @@ BOOST_AUTO_TEST_CASE(test_payphone_interaction) {
}
BOOST_AUTO_TEST_SUITE_END()
#endif

View File

@ -3,7 +3,6 @@
#include <objects/CharacterObject.hpp>
#include <objects/PickupObject.hpp>
#include "test_Globals.hpp"
#if RW_TEST_WITH_DATA
class TestPickup : public PickupObject {
public:
@ -20,7 +19,7 @@ public:
}
};
BOOST_AUTO_TEST_SUITE(PickupTests)
BOOST_AUTO_TEST_SUITE(PickupTests, DATA_TEST_PREDICATE)
BOOST_AUTO_TEST_CASE(test_pickup_interaction) {
{
@ -97,4 +96,3 @@ BOOST_AUTO_TEST_CASE(test_item_pickup) {
BOOST_AUTO_TEST_SUITE_END()
#endif

View File

@ -3,9 +3,8 @@
#include <platform/FileHandle.hpp>
#include "test_Globals.hpp"
BOOST_AUTO_TEST_SUITE(RWBStreamTests)
BOOST_AUTO_TEST_SUITE(RWBStreamTests, DATA_TEST_PREDICATE)
#if RW_TEST_WITH_DATA
BOOST_AUTO_TEST_CASE(iterate_stream_test) {
{
auto d = Global::get().e->data->index.openFile("landstal.dff");
@ -28,6 +27,5 @@ BOOST_AUTO_TEST_CASE(iterate_stream_test) {
BOOST_CHECK_EQUAL(*reinterpret_cast<std::uint32_t*>(innerCursor), 0x10);
}
}
#endif
BOOST_AUTO_TEST_SUITE_END()

View File

@ -9,8 +9,7 @@
BOOST_AUTO_TEST_SUITE(TextTests)
#if RW_TEST_WITH_DATA
BOOST_AUTO_TEST_CASE(load_test) {
BOOST_AUTO_TEST_CASE(load_test, DATA_TEST_PREDICATE) {
{
auto d = Global::get().e->data->index.openFileRaw("text/english.gxt");
@ -23,7 +22,6 @@ BOOST_AUTO_TEST_CASE(load_test) {
BOOST_CHECK_EQUAL(texts.text("1008"), T("BUSTED"));
}
}
#endif
BOOST_AUTO_TEST_CASE(special_chars) {
{

View File

@ -15,9 +15,8 @@ std::ostream& operator<<(std::ostream& os, const AIGraphNode* yt) {
return os;
}
BOOST_AUTO_TEST_SUITE(TrafficDirectorTests)
BOOST_AUTO_TEST_SUITE(TrafficDirectorTests, DATA_TEST_PREDICATE)
#if RW_TEST_WITH_DATA
BOOST_AUTO_TEST_CASE(test_available_nodes) {
AIGraph graph;
@ -164,6 +163,5 @@ BOOST_AUTO_TEST_CASE(test_create_traffic) {
// Global::get().e->destroyObject(created[0]);
}
#endif
BOOST_AUTO_TEST_SUITE_END()

View File

@ -3,9 +3,8 @@
#include <objects/VehicleObject.hpp>
#include "test_Globals.hpp"
BOOST_AUTO_TEST_SUITE(VehicleTests)
BOOST_AUTO_TEST_SUITE(VehicleTests, DATA_TEST_PREDICATE)
#if RW_TEST_WITH_DATA
BOOST_AUTO_TEST_CASE(test_create_vehicle) {
VehicleObject* vehicle =
Global::get().e->createVehicle(90u, glm::vec3(), glm::quat{1.0f,0.0f,0.0f,0.0f});
@ -130,6 +129,5 @@ BOOST_AUTO_TEST_CASE(test_open_part) {
Global::get().e->destroyObject(vehicle);
}
#endif
BOOST_AUTO_TEST_SUITE_END()

View File

@ -34,8 +34,7 @@ BOOST_FIXTURE_TEST_CASE(weapon_scan_does_injur_others, WeaponScanFixture) {
BOOST_CHECK(scan.doesDamage(reinterpret_cast<GameObject*>(0xDEADBEEF)));
}
#if RW_TEST_WITH_DATA
BOOST_AUTO_TEST_CASE(TestDoWeaponScan) {
BOOST_AUTO_TEST_CASE(TestDoWeaponScan, DATA_TEST_PREDICATE) {
{
// Test RADIUS scan
auto character = Global::get().e->createPedestrian(1, {0.f, 0.f, 0.f});
@ -53,7 +52,7 @@ BOOST_AUTO_TEST_CASE(TestDoWeaponScan) {
}
}
BOOST_AUTO_TEST_CASE(TestProjectile) {
BOOST_AUTO_TEST_CASE(TestProjectile, DATA_TEST_PREDICATE) {
{
auto character = Global::get().e->createPedestrian(1, {25.f, 0.f, 0.f});
BOOST_REQUIRE(character != nullptr);
@ -141,6 +140,5 @@ BOOST_AUTO_TEST_CASE(TestProjectile) {
Global::get().e->destroyQueuedObjects();
}
}
#endif
BOOST_AUTO_TEST_SUITE_END()