Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate to CTest #7062

Merged
merged 13 commits into from
Jan 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ jobs:
cmake .. $CMAKE_OPTS -DCMAKE_INSTALL_PREFIX=./install
- name: Build
run: cmake --build build
- name: Build tests
run: cmake --build build --target tests
- name: Run tests
run: build/tests/tests
run: |
cd build/tests
ctest --output-on-failure -j2
- name: Package
run: |
cmake --build build --target install
Expand Down Expand Up @@ -123,10 +123,10 @@ jobs:
-DUSE_WERROR=OFF
- name: Build
run: cmake --build build
- name: Build tests
run: cmake --build build --target tests
- name: Run tests
run: build/tests/tests
run: |
cd build/tests
ctest --output-on-failure -j3
- name: Package
run: |
cmake --build build --target install
Expand Down Expand Up @@ -194,8 +194,6 @@ jobs:
../cmake/build_win${{ matrix.arch }}.sh
- name: Build
run: cmake --build build
- name: Build tests
run: cmake --build build --target tests
- name: Package
run: cmake --build build --target package
- name: Upload artifacts
Expand Down Expand Up @@ -286,8 +284,10 @@ jobs:
${{ steps.cache-deps.outputs.cache-hit == 'true' && 'NO' || 'YES' }}
- name: Build
run: cmake --build build
- name: Build tests
run: cmake --build build --target tests
- name: Run tests
run: |
cd build/tests
ctest --output-on-failure -j2
- name: Package
sakertooth marked this conversation as resolved.
Show resolved Hide resolved
run: cmake --build build --target package
- name: Upload artifacts
Expand Down
7 changes: 4 additions & 3 deletions include/lmms_math.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,13 @@
#ifndef LMMS_MATH_H
#define LMMS_MATH_H

#include <QtGlobal>
#include <algorithm>
JohannesLorenz marked this conversation as resolved.
Show resolved Hide resolved
#include <cmath>
#include <cstdint>

#include "lmms_constants.h"
#include "lmmsconfig.h"
#include <QtGlobal>

#include <cmath>

namespace lmms
{
Expand Down
49 changes: 24 additions & 25 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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
JohannesLorenz marked this conversation as resolved.
Show resolved Hide resolved
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()
19 changes: 0 additions & 19 deletions tests/QTestSuite.cpp

This file was deleted.

21 changes: 0 additions & 21 deletions tests/QTestSuite.h

This file was deleted.

24 changes: 0 additions & 24 deletions tests/main.cpp

This file was deleted.

10 changes: 5 additions & 5 deletions tests/src/core/ArrayVectorTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@

#include "ArrayVector.h"

#include <QObject>
#include <QtTest/QtTest>
#include <array>
#include <iterator>

#include "QTestSuite.h"

using lmms::ArrayVector;

struct ShouldNotConstruct
Expand Down Expand Up @@ -59,10 +59,9 @@ struct DestructorCheck
bool* destructed;
};

class ArrayVectorTest : QTestSuite
class ArrayVectorTest : public QObject
{
Q_OBJECT

private slots:
void defaultConstructorTest()
{
Expand Down Expand Up @@ -826,6 +825,7 @@ private slots:
QVERIFY(!(e != v));
QVERIFY(g != v);
sakertooth marked this conversation as resolved.
Show resolved Hide resolved
}
} ArrayVectorTests;
};

QTEST_GUILESS_MAIN(ArrayVectorTest)
#include "ArrayVectorTest.moc"
23 changes: 19 additions & 4 deletions tests/src/core/AutomatableModelTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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; }

Expand All @@ -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;
JohannesLorenz marked this conversation as resolved.
Show resolved Hide resolved
Engine::init(true);
}

void cleanupTestCase()
{
using namespace lmms;
Engine::destroy();
}

void CastTests()
{
using namespace lmms;
Expand Down Expand Up @@ -100,6 +114,7 @@ private slots: // tests
QVERIFY(m2.value());
QVERIFY(!m3.value());
}
} AutomatableModelTests;
};

QTEST_GUILESS_MAIN(AutomatableModelTest)
#include "AutomatableModelTest.moc"
11 changes: 6 additions & 5 deletions tests/src/core/MathTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -48,6 +48,7 @@ private slots:
QCOMPARE(numDigitsAsInt(900000000), 9);
QCOMPARE(numDigitsAsInt(-900000000), 10);
}
} MathTests;
};

QTEST_GUILESS_MAIN(MathTest)
#include "MathTest.moc"
9 changes: 5 additions & 4 deletions tests/src/core/ProjectVersionTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@
*
*/

#include "QTestSuite.h"

#include "ProjectVersion.h"

class ProjectVersionTest : QTestSuite
#include <QtTest/QtTest>

class ProjectVersionTest : public QObject
{
Q_OBJECT
private slots:
Expand Down Expand Up @@ -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"
13 changes: 7 additions & 6 deletions tests/src/core/RelativePathsTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -66,6 +66,7 @@ private slots:
QCOMPARE(PathUtil::toAbsolute(""), empty);
QCOMPARE(PathUtil::toShortestRelative(""), empty);
}
} RelativePathTests;
};

QTEST_GUILESS_MAIN(RelativePathsTest)
#include "RelativePathsTest.moc"
15 changes: 12 additions & 3 deletions tests/src/tracks/AutomationTrackTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
*
*/

#include "QTestSuite.h"
#include <QtTest/QtTest>

#include "QCoreApplication"

Expand All @@ -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()
Expand Down Expand Up @@ -232,6 +240,7 @@ private slots:
QCOMPARE(song->automatedValuesAt(0)[&model], 50.0f);
}

} AutomationTrackTest;
};

QTEST_GUILESS_MAIN(AutomationTrackTest)
#include "AutomationTrackTest.moc"
Loading