Navigation Menu

Skip to content

Commit

Permalink
#5361: Set up configure.ac to detect the gtest framework. Adjust auto…
Browse files Browse the repository at this point in the history
…make files
  • Loading branch information
codereader committed Oct 24, 2020
1 parent 993b1f1 commit 30ec4fa
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 12 deletions.
2 changes: 1 addition & 1 deletion Makefile.am
@@ -1,6 +1,6 @@
ACLOCAL_AMFLAGS = -I m4

SUBDIRS = libs radiantcore radiant plugins install/i18n doc test
SUBDIRS = libs radiantcore radiant plugins install/i18n doc @test_subdir@

# Install data and stuff
gamedir = $(pkgdatadir)/games
Expand Down
15 changes: 15 additions & 0 deletions configure.ac
Expand Up @@ -306,6 +306,14 @@ else
AC_MSG_NOTICE([Using the fmtlib headers shipped with the sources (header-only mode)])
fi

# Check for google test framework
AC_CHECK_HEADER([gtest/gtest.h], [test_subdir=test], [test_subdir=''])
# We assume that if gtest_main is present, gtest is present too
AC_CHECK_LIB([gtest_main], [main],
[AC_MSG_NOTICE(Google test headers and libraries are present)],
[test_subdir=''])
AC_SUBST([test_subdir])

# dynamic link library
AC_CHECK_LIB([dl], [main],
[DL_LIBS='-ldl'],
Expand Down Expand Up @@ -453,4 +461,11 @@ fi
# echo " Use system fmtlib: no"
#fi

if test -n "$test_subdir"
then
echo " DarkRadiant Tests: yes"
else
echo " DarkRadiant Tests: no"
fi

echo " Use boost.filesystem: $use_boost_filesystem"
10 changes: 5 additions & 5 deletions radiant/Makefile.am
Expand Up @@ -202,12 +202,12 @@ darkradiant_SOURCES = main.cpp \
map/StartupMapLoader.cpp \
log/Console.cpp

check_PROGRAMS = facePlaneTest vfsTest shadersTest
TESTS = $(check_PROGRAMS)
#check_PROGRAMS = facePlaneTest vfsTest shadersTest
#TESTS = $(check_PROGRAMS)

facePlaneTest_SOURCES = test/facePlaneTest.cpp \
brush/FacePlane.cpp
facePlaneTest_LDADD = $(top_builddir)/libs/math/libmath.la
#facePlaneTest_SOURCES = test/facePlaneTest.cpp \
# brush/FacePlane.cpp
#facePlaneTest_LDADD = $(top_builddir)/libs/math/libmath.la

#vfsTest_SOURCES = test/vfsTest.cpp $(VFS_SOURCES)
#vfsTest_LDFLAGS = $(FILESYSTEM_LIBS) $(Z_LIBS)
Expand Down
14 changes: 8 additions & 6 deletions test/Makefile.am
@@ -1,10 +1,12 @@
AM_CPPFLAGS = -I$(top_srcdir)/include -I$(top_srcdir)/libs \
$(XML_CFLAGS)

bin_PROGRAMS = test
testdir = $(pkglibdir)/bin/
test_CPPFLAGS = $(AM_CPPFLAGS)
test_LDFLAGS = -lgtest -lgtest_main -lX11 \
check_PROGRAMS = drtest
TESTS = $(check_PROGRAMS)

drtestdir = $(pkglibdir)/bin/
drtest_CPPFLAGS = $(AM_CPPFLAGS)
drtest_LDFLAGS = -lgtest -lgtest_main -lX11 \
$(XML_LIBS) \
$(GLEW_LIBS) \
$(GL_LIBS) \
Expand All @@ -18,12 +20,12 @@ test_LDFLAGS = -lgtest -lgtest_main -lX11 \
$(INTL_LIBS) \
$(WX_LIBS) \
$(Z_LIBS)
test_LDADD = $(top_builddir)/libs/scene/libscenegraph.la \
drtest_LDADD = $(top_builddir)/libs/scene/libscenegraph.la \
$(top_builddir)/libs/wxutil/libwxutil.la \
$(top_builddir)/libs/xmlutil/libxmlutil.la \
$(top_builddir)/libs/math/libmath.la \
$(top_builddir)/libs/module/libmodule.la
test_SOURCES = Camera.cpp \
drtest_SOURCES = Camera.cpp \
CSG.cpp \
HeadlessOpenGLContext.cpp \
ModelScale.cpp \
Expand Down
26 changes: 26 additions & 0 deletions test/RadiantTest.h
Expand Up @@ -13,6 +13,7 @@
#include "HeadlessOpenGLContext.h"
#include "module/CoreModule.h"
#include "messages/GameConfigNeededMessage.h"
#include "messages/NotificationMessage.h"

namespace test
{
Expand All @@ -32,6 +33,7 @@ class RadiantTest :
std::unique_ptr<module::CoreModule> _coreModule;

std::size_t _gameSetupListener;
std::size_t _notificationListener;

std::shared_ptr<gl::HeadlessOpenGLContextModule> _glContextModule;

Expand Down Expand Up @@ -72,6 +74,11 @@ class RadiantTest :
radiant::TypeListener<game::ConfigurationNeeded>(
sigc::mem_fun(this, &RadiantTest::handleGameConfigMessage)));

_notificationListener = _coreModule->get()->getMessageBus().addListener(
radiant::IMessage::Type::Notification,
radiant::TypeListener<radiant::NotificationMessage>(
sigc::mem_fun(this, &RadiantTest::handleNotification)));

try
{
// Startup the application
Expand All @@ -89,6 +96,7 @@ class RadiantTest :

void TearDown() override
{
_coreModule->get()->getMessageBus().removeListener(_notificationListener);
_coreModule->get()->getMessageBus().removeListener(_gameSetupListener);

// Issue a shutdown() call to all the modules
Expand Down Expand Up @@ -126,6 +134,24 @@ class RadiantTest :
message.setConfig(config);
message.setHandled(true);
}

void handleNotification(radiant::NotificationMessage& msg)
{
switch (msg.getType())
{
case radiant::NotificationMessage::Information:
rMessage() << msg.getMessage() << std::endl;
break;

case radiant::NotificationMessage::Warning:
rWarning() << msg.getMessage() << std::endl;
break;

case radiant::NotificationMessage::Error:
rError() << msg.getMessage() << std::endl;
break;
};
}
};

}

0 comments on commit 30ec4fa

Please sign in to comment.