Skip to content

Commit

Permalink
win test fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
cen1 committed Oct 1, 2024
1 parent 50d2a4c commit 1a6f971
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 10 deletions.
3 changes: 2 additions & 1 deletion cmake/windeployqt.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ function(windeployqt target)
add_custom_command(TARGET ${target} POST_BUILD
COMMAND "${_qt_bin_dir}/windeployqt.exe"
--verbose 1
--release
$<$<CONFIG:Debug>:--debug>
$<$<CONFIG:Release>:--release>
--no-plugins
--no-translations
--no-system-d3d-compiler
Expand Down
8 changes: 7 additions & 1 deletion qztest/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,11 @@ if (WIN32 AND BUILD_SHARED_LIBS)
message(STATUS "Setting up windeployqt")
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/cmake")
include(windeployqt)
windeployqt(qztest)
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
message(STATUS "Deploying with debug libraries")
windeployqt(qztest --debug)
else()
message(STATUS "Deploying with release libraries")
windeployqt(qztest)
endif()
endif()
30 changes: 22 additions & 8 deletions qztest/testjlcompress.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,19 +79,22 @@ void TestJlCompress::compressFileOptions_data()
QTest::addColumn<QString>("zipName");
QTest::addColumn<QString>("fileName");
QTest::addColumn<QDateTime>("dateTime");
QTest::addColumn<QString>("sha256sum");
QTest::addColumn<QString>("sha256sum_unix"); // Due to extra data archives are not identical
QTest::addColumn<QString>("sha256sum_win");
QTest::newRow("simple") << "jlsimplefile.zip"
<< "test0.txt"
<< QDateTime(QDate(2024, 9, 19), QTime(21, 0, 0), QTimeZone::utc())
<< "5eedd83aee92cf3381155d167fee54a4ef6e43b8bc7a979c903611d9aa28610a";
<< "5eedd83aee92cf3381155d167fee54a4ef6e43b8bc7a979c903611d9aa28610a"
<< "cb1847dff1a5c33a805efde2558fc74024ad4c64c8607f8b12903e4d92385955";
}

void TestJlCompress::compressFileOptions()
{
QFETCH(QString, zipName);
QFETCH(QString, fileName);
QFETCH(QDateTime, dateTime);
QFETCH(QString, sha256sum);
QFETCH(QString, sha256sum_unix);
QFETCH(QString, sha256sum_win);
QDir curDir;
if (curDir.exists(zipName)) {
if (!curDir.remove(zipName))
Expand All @@ -116,7 +119,11 @@ void TestJlCompress::compressFileOptions()
// Hash is computed on the resulting file externally, then hardcoded in the test data
// This should help detecting any library breakage since we compare against a well-known stable result
QString hash = QCryptographicHash::hash(zipFile.readAll(), QCryptographicHash::Sha256).toHex();
QCOMPARE(sha256sum, hash);
#ifdef _WIN32
QCOMPARE(hash, sha256sum_win);
#else
QCOMPARE(hash, sha256sum_unix);
#endif
zipFile.close();
removeTestFiles(QStringList() << fileName);
curDir.remove(zipName);
Expand Down Expand Up @@ -217,7 +224,8 @@ void TestJlCompress::compressDirOptions_data()
QTest::addColumn<QStringList>("fileNames");
QTest::addColumn<QStringList>("expected");
QTest::addColumn<QDateTime>("dateTime");
QTest::addColumn<QString>("sha256sum");
QTest::addColumn<QString>("sha256sum_unix");
QTest::addColumn<QString>("sha256sum_win");
QTest::newRow("simple") << "jldir.zip"
<< (QStringList() << "test0.txt" << "testdir1/test1.txt"
<< "testdir2/test2.txt" << "testdir2/subdir/test2sub.txt")
Expand All @@ -226,7 +234,8 @@ void TestJlCompress::compressDirOptions_data()
<< "testdir2/" << "testdir2/test2.txt"
<< "testdir2/subdir/" << "testdir2/subdir/test2sub.txt")
<< QDateTime(QDate(2024, 9, 19), QTime(21, 0, 0), QTimeZone::utc())
<< "ed0d5921b2fc11b6b4cb214b3e43ea3ea28987d6ff8080faab54c4756de30af6";
<< "ed0d5921b2fc11b6b4cb214b3e43ea3ea28987d6ff8080faab54c4756de30af6"
<< "1eba110a33718c07a4ddf3fa515d1b4c6e3f4fc912b2e29e5e32783e2cddf852";
}

void TestJlCompress::compressDirOptions()
Expand All @@ -235,7 +244,8 @@ void TestJlCompress::compressDirOptions()
QFETCH(QStringList, fileNames);
QFETCH(QStringList, expected);
QFETCH(QDateTime, dateTime);
QFETCH(QString, sha256sum);
QFETCH(QString, sha256sum_unix);
QFETCH(QString, sha256sum_win);
QDir curDir;
if (curDir.exists(zipName)) {
if (!curDir.remove(zipName))
Expand Down Expand Up @@ -265,7 +275,11 @@ void TestJlCompress::compressDirOptions()
QFAIL("Can't read output zip file");
}
QString hash = QCryptographicHash::hash(zipFile.readAll(), QCryptographicHash::Sha256).toHex();
QCOMPARE(sha256sum, hash);
#ifdef _WIN32
QCOMPARE(hash, sha256sum_win);
#else
QCOMPARE(hash, sha256sum_unix);
#endif
zipFile.close();
removeTestFiles(fileNames, "compressDir_tmp");
curDir.remove(zipName);
Expand Down

0 comments on commit 1a6f971

Please sign in to comment.