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

Enable mtests under Windows with MSVC #5954

Merged
merged 4 commits into from
Apr 20, 2020
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
25 changes: 19 additions & 6 deletions mscore/musescore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7393,6 +7393,24 @@ MuseScoreApplication* MuseScoreApplication::initApplication(int& argc, char** ar
return app;
}

//---------------------------------------------------------
// setCustomConfigFolder
//---------------------------------------------------------

bool MuseScoreApplication::setCustomConfigFolder(const QString& path)
{
const QFileInfo pinfo(path);

if (pinfo.exists() && pinfo.isDir()) {
QSettings::setPath(QSettings::IniFormat, QSettings::UserScope, path);
QSettings::setPath(QSettings::IniFormat, QSettings::SystemScope, path);
dataPath = path;
return true;
}

return false;
}

//---------------------------------------------------------
// parseCommandLineArguments
//---------------------------------------------------------
Expand Down Expand Up @@ -7553,12 +7571,7 @@ MuseScoreApplication::CommandLineParseResult MuseScoreApplication::parseCommandL
QString path = parser.value("c");
if (path.isEmpty())
parser.showHelp(EXIT_FAILURE);
QDir dir;
if (dir.exists(path)) {
QSettings::setPath(QSettings::IniFormat, QSettings::UserScope, path);
QSettings::setPath(QSettings::IniFormat, QSettings::SystemScope, path);
dataPath = path;
}
setCustomConfigFolder(path);
}
MScore::testMode = parser.isSet("t");
if (parser.isSet("M")) {
Expand Down
2 changes: 2 additions & 0 deletions mscore/musescore.h
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,8 @@ class MuseScoreApplication : public QtSingleApplication {
};
static CommandLineParseResult parseCommandLineArguments(MuseScoreApplication* app);
static MuseScoreApplication* initApplication(int& argc, char** argv);

static bool setCustomConfigFolder(const QString& path);
};


Expand Down
16 changes: 12 additions & 4 deletions mtest/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@
# set(CMAKE_VERBOSE_MAKEFILE ON)
enable_testing()

if (MSVC)
project(mtest)
set (PROJECT_BINARY_DIR ${PROJECT_BINARY_DIR}/..)
set (PROJECT_SOURCE_DIR ${PROJECT_SOURCE_DIR}/..)
endif (MSVC)

include_directories(
${PROJECT_BINARY_DIR}
${PROJECT_SOURCE_DIR}
Expand Down Expand Up @@ -82,7 +88,7 @@ set (SOURCE_LIB
${PROJECT_SOURCE_DIR}/mscore/extension.cpp # required by zerberus tests
${OMR_SRC}
omr
)
)

if (MSVC)
add_library(
Expand Down Expand Up @@ -146,7 +152,7 @@ endif (APPLE AND (CMAKE_VERSION VERSION_LESS "3.5.0"))
set_target_properties(testutils PROPERTIES COMPILE_FLAGS "${TESTUTILS_COMPILE_FLAGS}")
set_target_properties(testutils_mscoreapp PROPERTIES COMPILE_FLAGS "${TESTUTILS_COMPILE_FLAGS}")


if (NOT MSVC)
add_custom_target(report
COMMAND ant -f ${PROJECT_SOURCE_DIR}/mtest/build.xml -Droot.dir=${PROJECT_BINARY_DIR}/mtest report
WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/mtest"
Expand All @@ -156,6 +162,7 @@ add_custom_target(reporthtml
COMMAND ant -f ${PROJECT_SOURCE_DIR}/mtest/build.xml -Droot.dir=${PROJECT_BINARY_DIR}/mtest reporthtml
WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/mtest"
)
endif (NOT MSVC)

subdirs (
libmscore/compat114
Expand Down Expand Up @@ -206,6 +213,7 @@ subdirs (
# libmscore/text work in progress...
libmscore/utils
mscore/workspaces
importmidi
capella
biab
musicxml
Expand All @@ -223,7 +231,7 @@ subdirs (
testscript
)


if (NOT MSVC)
install(FILES
../share/styles/chords_std.xml
../share/styles/chords_jazz.xml
Expand All @@ -236,7 +244,7 @@ install(FILES
../share/styles/cchords_sym.xml
DESTINATION ${PROJECT_BINARY_DIR}/mtest/styles
)

endif (NOT MSVC)

if (OMR)
subdirs(omr)
Expand Down
10 changes: 8 additions & 2 deletions mtest/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,14 @@

To build all tests:

| Linux | OSX | Windows |
| ----- | --- | ------- |
| Linux | OSX | Windows (MinGW) |
| ----- | --- | --------------- |
| make debug<br>sudo make installdebug<br>cd build.debug/mtest<br>make</pre> | make -f Makefile.osx debug<br>make -f Makefile.osx installdebug<br>cd build.debug/mtest<br>make -f Makefile.osx | mingw32-make -f Makefile.mingw debug<br>mingw32-make -f Makefile.mingw installdebug<br>cd build.debug\mtest<br>mingw32-make -f Makefile.mingw |

| Windows (MSVC) |
| -------------- |
| (Compile MuseScore in debug mode)<br>(Install MuseScore)<br>cd msvc.build_x64\mtest<br>cmake --build .<br>cmake --build . --target INSTALL |

To run all tests:

ctest
Expand All @@ -21,6 +25,8 @@ To see how the CI environment is doing it check `.travis.yml` and `build/run_tes

**Note: You need to have `diff` in your path. For Windows, get a copy of [diffutils for Windows](http://gnuwin32.sourceforge.net/packages/diffutils.htm "diffutils for Windows").**

**Note-2: For Windows MSVC, you also need MuseScore installation bin folder (for example C:\MuseScore\msvc.install_x64\bin) in your path.**

## Test case conventions

Tests are grouped in directories by feature (like libmscore or mxl).
Expand Down
96 changes: 73 additions & 23 deletions mtest/cmake.inc
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,33 @@ else (MTEST_LINK_MSCOREAPP)
target_link_libraries(${TARGET} testutils)
endif (MTEST_LINK_MSCOREAPP)

target_link_libraries(
${TARGET}
${QT_QTTEST_LIBRARY}
testResources
libmscore
audio
qzip
z
)
if (MSVC)
set(_all_h_file "${PROJECT_SOURCE_DIR}/all.h")
target_sources(${TARGET} PRIVATE
${_all_h_file}
${PCH}
)
include(FindStaticLibrary)
target_link_libraries(
${TARGET}
${QT_QTTEST_LIBRARY}
testResources
libmscore
audio
qzip
zlibstat
)
else (MSVC)
target_link_libraries(
${TARGET}
${QT_QTTEST_LIBRARY}
testResources
libmscore
audio
qzip
z
)
endif (MSVC)

if (OMR)
target_link_libraries(${TARGET} omr poppler-qt5)
Expand All @@ -40,23 +58,31 @@ if (OMR)
endif (OCR)
endif (OMR)

target_link_libraries(
${TARGET}
${QT_LIBRARIES}
z
)
if (MSVC)
target_link_libraries(
${TARGET}
${QT_LIBRARIES}
zlibstat
)
else (MSVC)
target_link_libraries(
${TARGET}
${QT_LIBRARIES}
z
)
endif (MSVC)

if (USE_SYSTEM_FREETYPE)
target_link_libraries(${TARGET} freetype)
else (USE_SYSTEM_FREETYPE)
target_link_libraries(${TARGET} mscore_freetype)
endif (USE_SYSTEM_FREETYPE)

if (NOT MINGW AND NOT APPLE)
if (NOT MINGW AND NOT APPLE AND NOT MSVC)
target_link_libraries(${TARGET}
dl
pthread)
endif (NOT MINGW AND NOT APPLE)
endif (NOT MINGW AND NOT APPLE AND NOT MSVC)

if (APPLE)
target_link_libraries(${TARGET} ${OsxFrameworks})
Expand All @@ -72,13 +98,22 @@ set_target_properties (
LINK_FLAGS "-g -stdlib=libc++"
)
else(APPLE)
set_target_properties (
${TARGET}
PROPERTIES
AUTOMOC true
COMPILE_FLAGS "-include all.h -D QT_GUI_LIB -D TESTROOT=\\\"${PROJECT_SOURCE_DIR}\\\" -g -Wall -Wextra"
LINK_FLAGS "-g"
)
if (MSVC)
set_target_properties (
${TARGET}
PROPERTIES
AUTOMOC true
COMPILE_FLAGS "/Zi ${PCH_INCLUDE} /D QT_GUI_LIB /D TESTROOT=\\\"${PROJECT_SOURCE_DIR}\\\""
)
else (MSVC)
set_target_properties (
${TARGET}
PROPERTIES
AUTOMOC true
COMPILE_FLAGS "-include all.h -D QT_GUI_LIB -D TESTROOT=\\\"${PROJECT_SOURCE_DIR}\\\" -g -Wall -Wextra"
LINK_FLAGS "-g"
)
endif (MSVC)
endif(APPLE)

if (APPLE AND (CMAKE_VERSION VERSION_LESS "3.5.0"))
Expand All @@ -90,3 +125,18 @@ set_target_properties (
endif (APPLE AND (CMAKE_VERSION VERSION_LESS "3.5.0"))

add_test(${TARGET} ${CMAKE_CURRENT_BINARY_DIR}/${TARGET} -xunitxml -o result.xml)

if (MSVC)
install(FILES
${PROJECT_SOURCE_DIR}/share/styles/chords_std.xml
${PROJECT_SOURCE_DIR}/share/styles/chords_jazz.xml
${PROJECT_SOURCE_DIR}/share/styles/chords.xml
${PROJECT_SOURCE_DIR}/share/styles/stdchords.xml
${PROJECT_SOURCE_DIR}/share/styles/jazzchords.xml
${PROJECT_SOURCE_DIR}/share/styles/cchords_muse.xml
${PROJECT_SOURCE_DIR}/share/styles/cchords_nrb.xml
${PROJECT_SOURCE_DIR}/share/styles/cchords_rb.xml
${PROJECT_SOURCE_DIR}/share/styles/cchords_sym.xml
DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/styles
)
endif (MSVC)
20 changes: 10 additions & 10 deletions mtest/importmidi/tst_importmidi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,20 @@
#include "libmscore/chord.h"
#include "libmscore/note.h"
#include "libmscore/keysig.h"
#include "mscore/exportmidi.h"
#include "audio/exports/exportmidi.h"

#include "libmscore/mcursor.h"
#include "mtest/testutils.h"
#include "inner_func_decl.h"
#include "mscore/importmidi/importmidi_chord.h"
#include "mscore/importmidi/importmidi_tuplet.h"
#include "mscore/importmidi/importmidi_meter.h"
#include "mscore/importmidi/importmidi_inner.h"
#include "mscore/importmidi/importmidi_quant.h"
#include "mscore/importmidi/importmidi_fraction.h"
#include "mscore/importmidi/importmidi_operations.h"
#include "mscore/importmidi/importmidi_model.h"
#include "mscore/importmidi/importmidi_lyrics.h"
#include "importexport/midiimport/importmidi_chord.h"
#include "importexport/midiimport/importmidi_tuplet.h"
#include "importexport/midiimport/importmidi_meter.h"
#include "importexport/midiimport/importmidi_inner.h"
#include "importexport/midiimport/importmidi_quant.h"
#include "importexport/midiimport/importmidi_fraction.h"
#include "importexport/midiimport/importmidi_operations.h"
#include "importexport/midiimport/importmidi_model.h"
#include "importexport/midiimport/importmidi_lyrics.h"
#include "mscore/preferences.h"


Expand Down
2 changes: 1 addition & 1 deletion mtest/libmscore/tuplet/tst_tuplet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ void TestTuplet::tuplet(const char* p1, const char* p2)

Segment* s = m2->first(SegmentType::ChordRest);
QVERIFY(s != 0);
Chord* c = toChord(s->element(0));
Ms::Chord* c = toChord(s->element(0));
QVERIFY(c != 0);

QVERIFY(createTuplet(3, c));
Expand Down
8 changes: 8 additions & 0 deletions mtest/mscore/workspaces/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,11 @@ set(TARGET tst_workspaces)
set(MTEST_LINK_MSCOREAPP TRUE)

include(${PROJECT_SOURCE_DIR}/mtest/cmake.inc)

if (MSVC)
install(DIRECTORY
${CMAKE_INSTALL_PREFIX}/workspaces
USE_SOURCE_PERMISSIONS
DESTINATION ${CMAKE_CURRENT_BINARY_DIR}
)
endif (MSVC)
4 changes: 3 additions & 1 deletion mtest/mscore/workspaces/tst_workspaces.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ void TestWorkspaces::initTestCase()
{
qputenv("QML_DISABLE_DISK_CACHE", "true");
qSetMessagePattern("%{function}: %{message}");
// Force INI settings format to store settings in a temporary directory
QSettings::setDefaultFormat(QSettings::IniFormat);
MScore::noGui = true;
MScore::testMode = true;
initMuseScoreResources();
Expand All @@ -90,7 +92,7 @@ void TestWorkspaces::initTestCase()

void TestWorkspaces::initMuseScore()
{
Ms::dataPath = tmpDataDir->path();
MuseScoreApplication::setCustomConfigFolder(tmpDataDir->path());
QStringList temp;
MuseScore::init(temp);
WorkspacesManager::initCurrentWorkspace();
Expand Down
2 changes: 1 addition & 1 deletion mtest/mtestglobals.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ QString revision;

MasterSynthesizer* synti;
QString dataPath;
QIcon* icons[0];
QIcon* icons[1];
QString mscoreGlobalShare;

}
12 changes: 12 additions & 0 deletions mtest/scripting/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,15 @@ set(TARGET tst_scripting)
set(MTEST_LINK_MSCOREAPP TRUE)

include(${PROJECT_SOURCE_DIR}/mtest/cmake.inc)

if (MSVC)
install(DIRECTORY
${QT_INSTALL_QML}
DESTINATION ${CMAKE_CURRENT_BINARY_DIR}
REGEX ".*d\\.dll" EXCLUDE
REGEX ".*QtMultimedia.*" EXCLUDE
REGEX ".*QtSensors.*" EXCLUDE
REGEX ".*QtTest.*" EXCLUDE
REGEX ".*QtWebkit.*" EXCLUDE
)
endif (MSVC)
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<metaTag name="lyricist"></metaTag>
<metaTag name="movementNumber"></metaTag>
<metaTag name="movementTitle"></metaTag>
<metaTag name="platform">Linux</metaTag>
<metaTag name="platform"></metaTag>
<metaTag name="poet"></metaTag>
<metaTag name="source"></metaTag>
<metaTag name="translator"></metaTag>
Expand Down
2 changes: 1 addition & 1 deletion mtest/testscript/scripts/#173381-mmrest-copy.mscx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<metaTag name="lyricist"></metaTag>
<metaTag name="movementNumber"></metaTag>
<metaTag name="movementTitle"></metaTag>
<metaTag name="platform">Linux</metaTag>
<metaTag name="platform"></metaTag>
<metaTag name="poet"></metaTag>
<metaTag name="source"></metaTag>
<metaTag name="translator"></metaTag>
Expand Down
2 changes: 1 addition & 1 deletion mtest/testscript/scripts/#173381-mmrest-repeat-1.mscx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<metaTag name="lyricist"></metaTag>
<metaTag name="movementNumber"></metaTag>
<metaTag name="movementTitle"></metaTag>
<metaTag name="platform">Linux</metaTag>
<metaTag name="platform"></metaTag>
<metaTag name="poet"></metaTag>
<metaTag name="source"></metaTag>
<metaTag name="translator"></metaTag>
Expand Down
Loading