Migrate to CTest (#7062)
This commit is contained in:
@@ -1,34 +1,33 @@
|
||||
INCLUDE_DIRECTORIES("${CMAKE_CURRENT_SOURCE_DIR}")
|
||||
INCLUDE_DIRECTORIES("${CMAKE_CURRENT_BINARY_DIR}")
|
||||
INCLUDE_DIRECTORIES("${CMAKE_SOURCE_DIR}/include")
|
||||
INCLUDE_DIRECTORIES("${CMAKE_BINARY_DIR}")
|
||||
INCLUDE_DIRECTORIES("${CMAKE_BINARY_DIR}/src")
|
||||
include(CTest)
|
||||
|
||||
SET(CMAKE_CXX_STANDARD 17)
|
||||
|
||||
SET(CMAKE_AUTOMOC ON)
|
||||
|
||||
# FIXME: remove this once we export include directories for LMMS
|
||||
IF(LMMS_BUILD_APPLE)
|
||||
INCLUDE_DIRECTORIES("/usr/local/include")
|
||||
ENDIF()
|
||||
|
||||
ADD_EXECUTABLE(tests
|
||||
EXCLUDE_FROM_ALL
|
||||
main.cpp
|
||||
QTestSuite.cpp
|
||||
$<TARGET_OBJECTS:lmmsobjs>
|
||||
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
||||
set(CMAKE_AUTOMOC ON)
|
||||
|
||||
set(LMMS_TESTS
|
||||
src/core/ArrayVectorTest.cpp
|
||||
src/core/AutomatableModelTest.cpp
|
||||
src/core/MathTest.cpp
|
||||
src/core/ProjectVersionTest.cpp
|
||||
src/core/RelativePathsTest.cpp
|
||||
|
||||
src/tracks/AutomationTrackTest.cpp
|
||||
)
|
||||
TARGET_COMPILE_DEFINITIONS(tests
|
||||
PRIVATE $<TARGET_PROPERTY:lmmsobjs,INTERFACE_COMPILE_DEFINITIONS>
|
||||
)
|
||||
TARGET_LINK_LIBRARIES(tests ${QT_LIBRARIES} ${QT_QTTEST_LIBRARY})
|
||||
TARGET_LINK_LIBRARIES(tests ${LMMS_REQUIRED_LIBS})
|
||||
|
||||
foreach(LMMS_TEST_SRC IN LISTS LMMS_TESTS)
|
||||
# TODO CMake 3.20: Use cmake_path
|
||||
get_filename_component(LMMS_TEST_NAME ${LMMS_TEST_SRC} NAME_WE)
|
||||
|
||||
add_executable(${LMMS_TEST_NAME} $<TARGET_OBJECTS:lmmsobjs> ${LMMS_TEST_SRC})
|
||||
add_test(NAME ${LMMS_TEST_NAME} COMMAND ${LMMS_TEST_NAME})
|
||||
|
||||
# TODO CMake 3.12: Propagate usage requirements by linking to lmmsobjs
|
||||
target_include_directories(${LMMS_TEST_NAME} PRIVATE $<TARGET_PROPERTY:lmmsobjs,INCLUDE_DIRECTORIES>)
|
||||
|
||||
target_link_libraries(${LMMS_TEST_NAME} PRIVATE
|
||||
${LMMS_REQUIRED_LIBS}
|
||||
${QT_LIBRARIES}
|
||||
${QT_QTTEST_LIBRARY}
|
||||
)
|
||||
|
||||
target_compile_features(${LMMS_TEST_NAME} PRIVATE cxx_std_17)
|
||||
target_compile_definitions(${LMMS_TEST_NAME} PRIVATE $<TARGET_PROPERTY:lmmsobjs,INTERFACE_COMPILE_DEFINITIONS>)
|
||||
endforeach()
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
#include "QTestSuite.h"
|
||||
|
||||
QList<QTestSuite*> QTestSuite::m_suites;
|
||||
|
||||
QTestSuite::QTestSuite(QObject *parent) : QObject(parent)
|
||||
{
|
||||
m_suites << this;
|
||||
}
|
||||
|
||||
QTestSuite::~QTestSuite()
|
||||
{
|
||||
m_suites.removeAll(this);
|
||||
}
|
||||
|
||||
QList<QTestSuite*> QTestSuite::suites()
|
||||
{
|
||||
return m_suites;
|
||||
}
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
#ifndef QTESTSUITE_H
|
||||
#define QTESTSUITE_H
|
||||
|
||||
#include <QTest>
|
||||
#include <QObject>
|
||||
#include <QList>
|
||||
|
||||
class QTestSuite : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit QTestSuite(QObject *parent = 0);
|
||||
~QTestSuite() override;
|
||||
|
||||
static QList<QTestSuite*> suites();
|
||||
|
||||
private:
|
||||
static QList<QTestSuite*> m_suites;
|
||||
};
|
||||
|
||||
#endif // QTESTSUITE_H
|
||||
@@ -1,24 +0,0 @@
|
||||
#include "QTestSuite.h"
|
||||
|
||||
#include <QTest>
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
#include "Engine.h"
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
new QCoreApplication(argc, argv);
|
||||
lmms::Engine::init(true);
|
||||
|
||||
int numsuites = QTestSuite::suites().size();
|
||||
qDebug() << ">> Will run" << numsuites << "test suites";
|
||||
int failed = 0;
|
||||
for (QTestSuite*& suite : QTestSuite::suites())
|
||||
{
|
||||
if (QTest::qExec(suite, argc, argv) != 0) { ++failed; }
|
||||
}
|
||||
qDebug() << "<<" << failed << "out of"<<numsuites<<"test suites failed.";
|
||||
lmms::Engine::destroy();
|
||||
return failed;
|
||||
}
|
||||
@@ -24,11 +24,11 @@
|
||||
|
||||
#include "ArrayVector.h"
|
||||
|
||||
#include <QObject>
|
||||
#include <QtTest/QtTest>
|
||||
#include <array>
|
||||
#include <iterator>
|
||||
|
||||
#include "QTestSuite.h"
|
||||
|
||||
using lmms::ArrayVector;
|
||||
|
||||
struct ShouldNotConstruct
|
||||
@@ -59,10 +59,9 @@ struct DestructorCheck
|
||||
bool* destructed;
|
||||
};
|
||||
|
||||
class ArrayVectorTest : QTestSuite
|
||||
class ArrayVectorTest : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
private slots:
|
||||
void defaultConstructorTest()
|
||||
{
|
||||
@@ -826,6 +825,7 @@ private slots:
|
||||
QVERIFY(!(e != v));
|
||||
QVERIFY(g != v);
|
||||
}
|
||||
} ArrayVectorTests;
|
||||
};
|
||||
|
||||
QTEST_GUILESS_MAIN(ArrayVectorTest)
|
||||
#include "ArrayVectorTest.moc"
|
||||
|
||||
@@ -22,15 +22,16 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "QTestSuite.h"
|
||||
|
||||
#include <QtTest/QtTest>
|
||||
#include "AutomatableModel.h"
|
||||
#include "ComboBoxModel.h"
|
||||
#include "Engine.h"
|
||||
|
||||
class AutomatableModelTest : QTestSuite
|
||||
class AutomatableModelTest : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
bool m1Changed, m2Changed;
|
||||
void resetChanged() { m1Changed = m2Changed = false; }
|
||||
|
||||
@@ -41,6 +42,19 @@ private slots: // helper slots
|
||||
private slots: // tests
|
||||
//! Test that upcast and exact casts work,
|
||||
//! but no downcast or any other casts
|
||||
|
||||
void initTestCase()
|
||||
{
|
||||
using namespace lmms;
|
||||
Engine::init(true);
|
||||
}
|
||||
|
||||
void cleanupTestCase()
|
||||
{
|
||||
using namespace lmms;
|
||||
Engine::destroy();
|
||||
}
|
||||
|
||||
void CastTests()
|
||||
{
|
||||
using namespace lmms;
|
||||
@@ -100,6 +114,7 @@ private slots: // tests
|
||||
QVERIFY(m2.value());
|
||||
QVERIFY(!m3.value());
|
||||
}
|
||||
} AutomatableModelTests;
|
||||
};
|
||||
|
||||
QTEST_GUILESS_MAIN(AutomatableModelTest)
|
||||
#include "AutomatableModelTest.moc"
|
||||
|
||||
@@ -22,13 +22,13 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "QTestSuite.h"
|
||||
#include <QDir>
|
||||
#include <QObject>
|
||||
#include <QtTest/QtTest>
|
||||
|
||||
#include "lmms_math.h"
|
||||
|
||||
#include <QDir>
|
||||
|
||||
class MathTest : QTestSuite
|
||||
class MathTest : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
private slots:
|
||||
@@ -48,6 +48,7 @@ private slots:
|
||||
QCOMPARE(numDigitsAsInt(900000000), 9);
|
||||
QCOMPARE(numDigitsAsInt(-900000000), 10);
|
||||
}
|
||||
} MathTests;
|
||||
};
|
||||
|
||||
QTEST_GUILESS_MAIN(MathTest)
|
||||
#include "MathTest.moc"
|
||||
|
||||
@@ -22,11 +22,11 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "QTestSuite.h"
|
||||
|
||||
#include "ProjectVersion.h"
|
||||
|
||||
class ProjectVersionTest : QTestSuite
|
||||
#include <QtTest/QtTest>
|
||||
|
||||
class ProjectVersionTest : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
private slots:
|
||||
@@ -75,6 +75,7 @@ private slots:
|
||||
//An identifier of the form "-x" is non-numeric, not negative
|
||||
QVERIFY(ProjectVersion("1.0.0-alpha.-1") > "1.0.0-alpha.1");
|
||||
}
|
||||
} ProjectVersionTests;
|
||||
};
|
||||
|
||||
QTEST_GUILESS_MAIN(ProjectVersionTest)
|
||||
#include "ProjectVersionTest.moc"
|
||||
|
||||
@@ -22,15 +22,15 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "QTestSuite.h"
|
||||
#include <QDir>
|
||||
#include <QObject>
|
||||
#include <QtTest/QtTest>
|
||||
|
||||
#include "ConfigManager.h"
|
||||
#include "SampleBuffer.h"
|
||||
#include "PathUtil.h"
|
||||
#include "SampleBuffer.h"
|
||||
|
||||
#include <QDir>
|
||||
|
||||
class RelativePathsTest : QTestSuite
|
||||
class RelativePathsTest : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
private slots:
|
||||
@@ -66,6 +66,7 @@ private slots:
|
||||
QCOMPARE(PathUtil::toAbsolute(""), empty);
|
||||
QCOMPARE(PathUtil::toShortestRelative(""), empty);
|
||||
}
|
||||
} RelativePathTests;
|
||||
};
|
||||
|
||||
QTEST_GUILESS_MAIN(RelativePathsTest)
|
||||
#include "RelativePathsTest.moc"
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "QTestSuite.h"
|
||||
#include <QtTest/QtTest>
|
||||
|
||||
#include "QCoreApplication"
|
||||
|
||||
@@ -39,12 +39,20 @@
|
||||
#include "Engine.h"
|
||||
#include "Song.h"
|
||||
|
||||
class AutomationTrackTest : QTestSuite
|
||||
class AutomationTrackTest : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
private slots:
|
||||
void initTestCase()
|
||||
{
|
||||
using namespace lmms;
|
||||
Engine::init(true);
|
||||
}
|
||||
|
||||
void cleanupTestCase()
|
||||
{
|
||||
using namespace lmms;
|
||||
Engine::destroy();
|
||||
}
|
||||
|
||||
void testClipLinear()
|
||||
@@ -232,6 +240,7 @@ private slots:
|
||||
QCOMPARE(song->automatedValuesAt(0)[&model], 50.0f);
|
||||
}
|
||||
|
||||
} AutomationTrackTest;
|
||||
};
|
||||
|
||||
QTEST_GUILESS_MAIN(AutomationTrackTest)
|
||||
#include "AutomationTrackTest.moc"
|
||||
|
||||
Reference in New Issue
Block a user