mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-27 20:58:47 +00:00
Use SUBSURFACE_TEST_DATA definition to point to test data dir
Update tests with a (compile time) option SUBSURFACE_TEST_DATA, pointing to test data base path. It is needed for cross compilation cases. SUBSURFACE_TEST_DATA is set to SUBSURFACE_SOURCE by default, or configurable via cmake option -DSUBSURFACE_TEST_DATA="...". Signed-off-by: Jeremie Guichard <djebrest@gmail.com>
This commit is contained in:
parent
5b8bde8e1e
commit
1e2580c3fd
8 changed files with 48 additions and 38 deletions
|
@ -57,7 +57,9 @@ if (${_index} EQUAL -1)
|
|||
Example: -DSUBSURFACE_TARGET_EXECUTABLE=DesktopExecutable")
|
||||
endif()
|
||||
|
||||
add_definitions(-DSUBSURFACE_SOURCE="${CMAKE_SOURCE_DIR}")
|
||||
# SUBSURFACE_SOURCE may be used in subdirectories (tests)
|
||||
set(SUBSURFACE_SOURCE ${CMAKE_SOURCE_DIR})
|
||||
add_definitions(-DSUBSURFACE_SOURCE="${SUBSURFACE_SOURCE}")
|
||||
|
||||
#evenrything's correct, moving on.
|
||||
set(CMAKE_MODULE_PATH
|
||||
|
@ -421,7 +423,7 @@ elseif(CMAKE_SYSTEM_NAME STREQUAL "Windows")
|
|||
# the script we created above is now added as a command to run at
|
||||
# install time - so this ensures that subsurface.exe has been
|
||||
# built before this is run
|
||||
install(CODE "execute_process(COMMAND ${CMAKE_COMMAND} -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER} -DSUBSURFACE_TARGET=${SUBSURFACE_TARGET} -DSUBSURFACE_SOURCE=${CMAKE_SOURCE_DIR} -DSTAGING=${WINDOWSSTAGING} -P ${CMAKE_SOURCE_DIR}/cmake/Modules/dlllist.cmake)")
|
||||
install(CODE "execute_process(COMMAND ${CMAKE_COMMAND} -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER} -DSUBSURFACE_TARGET=${SUBSURFACE_TARGET} -DSUBSURFACE_SOURCE=${SUBSURFACE_SOURCE} -DSTAGING=${WINDOWSSTAGING} -P ${CMAKE_SOURCE_DIR}/cmake/Modules/dlllist.cmake)")
|
||||
|
||||
# create the subsurface-x.y.z.exe installer - this needs to depend
|
||||
# on the install target but cmake doesn't allow that, so we depend
|
||||
|
|
|
@ -1,6 +1,13 @@
|
|||
# QTest based tests
|
||||
qt5_add_resources(SUBSURFACE_TEST_RESOURCES ../subsurface.qrc)
|
||||
|
||||
# Access test data (dive folder) from SUBSURFACE_SOURCE by default.
|
||||
# In cross compilation cases or when test will not be executed at build time
|
||||
# a differnt value can be set via cmake -DSUBSURFACE_TEST_DATA.
|
||||
if(NOT SUBSURFACE_TEST_DATA)
|
||||
set(SUBSURFACE_TEST_DATA ${SUBSURFACE_SOURCE})
|
||||
endif()
|
||||
|
||||
add_library(RESOURCE_LIBRARY STATIC ${SUBSURFACE_TEST_RESOURCES})
|
||||
|
||||
macro(TEST NAME FILE)
|
||||
|
@ -11,6 +18,7 @@ endmacro()
|
|||
|
||||
enable_testing()
|
||||
add_definitions(-g)
|
||||
add_definitions(-DSUBSURFACE_TEST_DATA="${SUBSURFACE_TEST_DATA}")
|
||||
TEST(TestUnitConversion testunitconversion.cpp)
|
||||
TEST(TestProfile testprofile.cpp)
|
||||
TEST(TestGpsCoords testgpscoords.cpp)
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
void TestDiveSiteDuplication::testReadV2()
|
||||
{
|
||||
QCOMPARE(parse_file(SUBSURFACE_SOURCE "/dives/TwoTimesTwo.ssrf"), 0);
|
||||
QCOMPARE(parse_file(SUBSURFACE_TEST_DATA "/dives/TwoTimesTwo.ssrf"), 0);
|
||||
QCOMPARE(dive_site_table.nr, 2);
|
||||
}
|
||||
|
||||
|
|
|
@ -64,7 +64,7 @@ void TestGitStorage::testGitStorageLocal()
|
|||
// test writing and reading back from local git storage
|
||||
git_repository *repo;
|
||||
git_libgit2_init();
|
||||
QCOMPARE(parse_file(SUBSURFACE_SOURCE "/dives/SampleDivesV2.ssrf"), 0);
|
||||
QCOMPARE(parse_file(SUBSURFACE_TEST_DATA "/dives/SampleDivesV2.ssrf"), 0);
|
||||
QString testDirName("./gittest");
|
||||
QDir testDir(testDirName);
|
||||
QCOMPARE(testDir.removeRecursively(), true);
|
||||
|
@ -93,7 +93,7 @@ void TestGitStorage::testGitStorageCloud()
|
|||
// connect to the ssrftest repository on the cloud server
|
||||
// and repeat the same test as before with the local git storage
|
||||
QString cloudTestRepo("https://cloud.subsurface-divelog.org/git/ssrftest@hohndel.org[ssrftest@hohndel.org]");
|
||||
QCOMPARE(parse_file(SUBSURFACE_SOURCE "/dives/SampleDivesV2.ssrf"), 0);
|
||||
QCOMPARE(parse_file(SUBSURFACE_TEST_DATA "/dives/SampleDivesV2.ssrf"), 0);
|
||||
QCOMPARE(save_dives(qPrintable(cloudTestRepo)), 0);
|
||||
clear_dive_file_data();
|
||||
QCOMPARE(parse_file(qPrintable(cloudTestRepo)), 0);
|
||||
|
@ -119,7 +119,7 @@ void TestGitStorage::testGitStorageCloudOfflineSync()
|
|||
QString localCacheRepo = localCacheDir + "[ssrftest@hohndel.org]";
|
||||
// read the local repo from the previous test and add dive 10
|
||||
QCOMPARE(parse_file(qPrintable(localCacheRepo)), 0);
|
||||
QCOMPARE(parse_file(SUBSURFACE_SOURCE "/dives/test10.xml"), 0);
|
||||
QCOMPARE(parse_file(SUBSURFACE_TEST_DATA "/dives/test10.xml"), 0);
|
||||
// calling process_dive() sorts the table, but calling it with
|
||||
// is_imported == true causes it to try to update the window title... let's not do that
|
||||
process_dives(false, false);
|
||||
|
@ -169,14 +169,14 @@ void TestGitStorage::testGitStorageCloudMerge()
|
|||
QString localCacheDir(get_local_dir("https://cloud.subsurface-divelog.org/git/ssrftest@hohndel.org", "ssrftest@hohndel.org"));
|
||||
QString localCacheRepoSave = localCacheDir + "save[ssrftest@hohndel.org]";
|
||||
QCOMPARE(parse_file(qPrintable(localCacheRepoSave)), 0);
|
||||
QCOMPARE(parse_file(SUBSURFACE_SOURCE "/dives/test11.xml"), 0);
|
||||
QCOMPARE(parse_file(SUBSURFACE_TEST_DATA "/dives/test11.xml"), 0);
|
||||
process_dives(false, false);
|
||||
QCOMPARE(save_dives(qPrintable(localCacheRepoSave)), 0);
|
||||
clear_dive_file_data();
|
||||
|
||||
// now we open the cloud storage repo and add a different dive to it
|
||||
QCOMPARE(parse_file(qPrintable(cloudTestRepo)), 0);
|
||||
QCOMPARE(parse_file(SUBSURFACE_SOURCE "/dives/test12.xml"), 0);
|
||||
QCOMPARE(parse_file(SUBSURFACE_TEST_DATA "/dives/test12.xml"), 0);
|
||||
process_dives(false, false);
|
||||
QCOMPARE(save_dives(qPrintable(cloudTestRepo)), 0);
|
||||
clear_dive_file_data();
|
||||
|
@ -191,9 +191,9 @@ void TestGitStorage::testGitStorageCloudMerge()
|
|||
QCOMPARE(save_dives("./SapleDivesV3plus10-11-12-merged.ssrf"), 0);
|
||||
clear_dive_file_data();
|
||||
QCOMPARE(parse_file("./SampleDivesV3plus10local.ssrf"), 0);
|
||||
QCOMPARE(parse_file(SUBSURFACE_SOURCE "/dives/test11.xml"), 0);
|
||||
QCOMPARE(parse_file(SUBSURFACE_TEST_DATA "/dives/test11.xml"), 0);
|
||||
process_dives(false, false);
|
||||
QCOMPARE(parse_file(SUBSURFACE_SOURCE "/dives/test12.xml"), 0);
|
||||
QCOMPARE(parse_file(SUBSURFACE_TEST_DATA "/dives/test12.xml"), 0);
|
||||
process_dives(false, false);
|
||||
QCOMPARE(save_dives("./SapleDivesV3plus10-11-12.ssrf"), 0);
|
||||
QFile org("./SapleDivesV3plus10-11-12-merged.ssrf");
|
||||
|
|
|
@ -15,12 +15,12 @@ void TestMerge::testMergeEmpty()
|
|||
/*
|
||||
* check that we correctly merge mixed cylinder dives
|
||||
*/
|
||||
QCOMPARE(parse_file(SUBSURFACE_SOURCE "/dives/test47.xml"), 0);
|
||||
QCOMPARE(parse_file(SUBSURFACE_TEST_DATA "/dives/test47.xml"), 0);
|
||||
process_dives(true, false);
|
||||
QCOMPARE(parse_file(SUBSURFACE_SOURCE "/dives/test48.xml"), 0);
|
||||
QCOMPARE(parse_file(SUBSURFACE_TEST_DATA "/dives/test48.xml"), 0);
|
||||
process_dives(true, false);
|
||||
QCOMPARE(save_dives("./testmerge47+48.ssrf"), 0);
|
||||
QFile org(SUBSURFACE_SOURCE "/dives/test47+48.xml");
|
||||
QFile org(SUBSURFACE_TEST_DATA "/dives/test47+48.xml");
|
||||
org.open(QFile::ReadOnly);
|
||||
QFile out("./testmerge47+48.ssrf");
|
||||
out.open(QFile::ReadOnly);
|
||||
|
@ -39,12 +39,12 @@ void TestMerge::testMergeBackwards()
|
|||
/*
|
||||
* check that we correctly merge mixed cylinder dives
|
||||
*/
|
||||
QCOMPARE(parse_file(SUBSURFACE_SOURCE "/dives/test48.xml"), 0);
|
||||
QCOMPARE(parse_file(SUBSURFACE_TEST_DATA "/dives/test48.xml"), 0);
|
||||
process_dives(true, false);
|
||||
QCOMPARE(parse_file(SUBSURFACE_SOURCE "/dives/test47.xml"), 0);
|
||||
QCOMPARE(parse_file(SUBSURFACE_TEST_DATA "/dives/test47.xml"), 0);
|
||||
process_dives(true, false);
|
||||
QCOMPARE(save_dives("./testmerge47+48.ssrf"), 0);
|
||||
QFile org(SUBSURFACE_SOURCE "/dives/test47+48.xml");
|
||||
QFile org(SUBSURFACE_TEST_DATA "/dives/test47+48.xml");
|
||||
org.open(QFile::ReadOnly);
|
||||
QFile out("./testmerge47+48.ssrf");
|
||||
out.open(QFile::ReadOnly);
|
||||
|
|
|
@ -80,7 +80,7 @@ void TestParse::testParseCSV()
|
|||
params[pnr++] = intdup(-1);
|
||||
params[pnr++] = NULL;
|
||||
|
||||
QCOMPARE(parse_manual_file(SUBSURFACE_SOURCE "/dives/test41.csv", params, pnr - 1), 0);
|
||||
QCOMPARE(parse_manual_file(SUBSURFACE_TEST_DATA "/dives/test41.csv", params, pnr - 1), 0);
|
||||
fprintf(stderr, "number of dives %d \n", dive_table.nr);
|
||||
}
|
||||
|
||||
|
@ -92,7 +92,7 @@ void TestParse::testParseDivingLog()
|
|||
struct dive_site *ds = alloc_or_get_dive_site(0xdeadbeef);
|
||||
ds->name = copy_string("Suomi - - Hälvälä");
|
||||
|
||||
QCOMPARE(sqlite3_open(SUBSURFACE_SOURCE "/dives/TestDivingLog4.1.1.sql", &handle), 0);
|
||||
QCOMPARE(sqlite3_open(SUBSURFACE_TEST_DATA "/dives/TestDivingLog4.1.1.sql", &handle), 0);
|
||||
QCOMPARE(parse_divinglog_buffer(handle, 0, 0, 0, &dive_table), 0);
|
||||
|
||||
sqlite3_close(handle);
|
||||
|
@ -101,19 +101,19 @@ void TestParse::testParseDivingLog()
|
|||
void TestParse::testParseV2NoQuestion()
|
||||
{
|
||||
// parsing of a V2 file should work
|
||||
QCOMPARE(parse_file(SUBSURFACE_SOURCE "/dives/test40.xml"), 0);
|
||||
QCOMPARE(parse_file(SUBSURFACE_TEST_DATA "/dives/test40.xml"), 0);
|
||||
}
|
||||
|
||||
void TestParse::testParseV3()
|
||||
{
|
||||
// parsing of a V3 files should succeed
|
||||
QCOMPARE(parse_file(SUBSURFACE_SOURCE "/dives/test42.xml"), 0);
|
||||
QCOMPARE(parse_file(SUBSURFACE_TEST_DATA "/dives/test42.xml"), 0);
|
||||
}
|
||||
|
||||
void TestParse::testParseCompareOutput()
|
||||
{
|
||||
QCOMPARE(save_dives("./testout.ssrf"), 0);
|
||||
QFile org(SUBSURFACE_SOURCE "/dives/test40-42.xml");
|
||||
QFile org(SUBSURFACE_TEST_DATA "/dives/test40-42.xml");
|
||||
org.open(QFile::ReadOnly);
|
||||
QFile out("./testout.ssrf");
|
||||
out.open(QFile::ReadOnly);
|
||||
|
@ -131,7 +131,7 @@ void TestParse::testParseDM4()
|
|||
{
|
||||
sqlite3 *handle;
|
||||
|
||||
QCOMPARE(sqlite3_open(SUBSURFACE_SOURCE "/dives/TestDiveDM4.db", &handle), 0);
|
||||
QCOMPARE(sqlite3_open(SUBSURFACE_TEST_DATA "/dives/TestDiveDM4.db", &handle), 0);
|
||||
QCOMPARE(parse_dm4_buffer(handle, 0, 0, 0, &dive_table), 0);
|
||||
|
||||
sqlite3_close(handle);
|
||||
|
@ -140,7 +140,7 @@ void TestParse::testParseDM4()
|
|||
void TestParse::testParseCompareDM4Output()
|
||||
{
|
||||
QCOMPARE(save_dives("./testdm4out.ssrf"), 0);
|
||||
QFile org(SUBSURFACE_SOURCE "/dives/TestDiveDM4.xml");
|
||||
QFile org(SUBSURFACE_TEST_DATA "/dives/TestDiveDM4.xml");
|
||||
org.open(QFile::ReadOnly);
|
||||
QFile out("./testdm4out.ssrf");
|
||||
out.open(QFile::ReadOnly);
|
||||
|
@ -193,7 +193,7 @@ void TestParse::testParseHUDC()
|
|||
params[pnr++] = strdup("\"DC text\"");
|
||||
params[pnr++] = NULL;
|
||||
|
||||
QCOMPARE(parse_csv_file(SUBSURFACE_SOURCE "/dives/TestDiveSeabearHUDC.csv",
|
||||
QCOMPARE(parse_csv_file(SUBSURFACE_TEST_DATA "/dives/TestDiveSeabearHUDC.csv",
|
||||
params, pnr - 1, "csv"), 0);
|
||||
|
||||
QCOMPARE(dive_table.nr, 1);
|
||||
|
@ -212,7 +212,7 @@ void TestParse::testParseHUDC()
|
|||
void TestParse::testParseCompareHUDCOutput()
|
||||
{
|
||||
QCOMPARE(save_dives("./testhudcout.ssrf"), 0);
|
||||
QFile org(SUBSURFACE_SOURCE "/dives/TestDiveSeabearHUDC.xml");
|
||||
QFile org(SUBSURFACE_TEST_DATA "/dives/TestDiveSeabearHUDC.xml");
|
||||
org.open(QFile::ReadOnly);
|
||||
QFile out("./testhudcout.ssrf");
|
||||
out.open(QFile::ReadOnly);
|
||||
|
@ -240,7 +240,7 @@ void TestParse::testParseNewFormat()
|
|||
* Set the directory location and file filter for H3 CSV files.
|
||||
*/
|
||||
|
||||
dir = QString::fromLatin1(SUBSURFACE_SOURCE "/dives");
|
||||
dir = QString::fromLatin1(SUBSURFACE_TEST_DATA "/dives");
|
||||
filter << "TestDiveSeabearH3*.csv";
|
||||
filter << "TestDiveSeabearT1*.csv";
|
||||
files = dir.entryList(filter, QDir::Files);
|
||||
|
@ -253,7 +253,7 @@ void TestParse::testParseNewFormat()
|
|||
QString delta;
|
||||
QStringList currColumns;
|
||||
QStringList headers;
|
||||
QString file = QString::fromLatin1(SUBSURFACE_SOURCE "/dives/").append(files.at(i));
|
||||
QString file = QString::fromLatin1(SUBSURFACE_TEST_DATA "/dives/").append(files.at(i));
|
||||
QFile f(file);
|
||||
|
||||
/*
|
||||
|
@ -368,7 +368,7 @@ void TestParse::testParseNewFormat()
|
|||
void TestParse::testParseCompareNewFormatOutput()
|
||||
{
|
||||
QCOMPARE(save_dives("./testsbnewout.ssrf"), 0);
|
||||
QFile org(SUBSURFACE_SOURCE "/dives/TestDiveSeabearNewFormat.xml");
|
||||
QFile org(SUBSURFACE_TEST_DATA "/dives/TestDiveSeabearNewFormat.xml");
|
||||
org.open(QFile::ReadOnly);
|
||||
QFile out("./testsbnewout.ssrf");
|
||||
out.open(QFile::ReadOnly);
|
||||
|
@ -388,7 +388,7 @@ void TestParse::testParseCompareNewFormatOutput()
|
|||
void TestParse::testParseDLD()
|
||||
{
|
||||
struct memblock mem;
|
||||
QString filename = SUBSURFACE_SOURCE "/dives/TestDiveDivelogsDE.DLD";
|
||||
QString filename = SUBSURFACE_TEST_DATA "/dives/TestDiveDivelogsDE.DLD";
|
||||
|
||||
QVERIFY(readfile(filename.toLatin1().data(), &mem) > 0);
|
||||
QVERIFY(try_to_open_zip(filename.toLatin1().data()) > 0);
|
||||
|
@ -405,7 +405,7 @@ void TestParse::testParseCompareDLDOutput()
|
|||
*/
|
||||
|
||||
QCOMPARE(save_dives("./testdldout.ssrf"), 0);
|
||||
QFile org(SUBSURFACE_SOURCE "/dives/TestDiveDivelogsDE.xml");
|
||||
QFile org(SUBSURFACE_TEST_DATA "/dives/TestDiveDivelogsDE.xml");
|
||||
org.open(QFile::ReadOnly);
|
||||
QFile out("./testdldout.ssrf");
|
||||
out.open(QFile::ReadOnly);
|
||||
|
@ -424,10 +424,10 @@ void TestParse::testParseMerge()
|
|||
/*
|
||||
* check that we correctly merge mixed cylinder dives
|
||||
*/
|
||||
QCOMPARE(parse_file(SUBSURFACE_SOURCE "/dives/ostc.xml"), 0);
|
||||
QCOMPARE(parse_file(SUBSURFACE_SOURCE "/dives/vyper.xml"), 0);
|
||||
QCOMPARE(parse_file(SUBSURFACE_TEST_DATA "/dives/ostc.xml"), 0);
|
||||
QCOMPARE(parse_file(SUBSURFACE_TEST_DATA "/dives/vyper.xml"), 0);
|
||||
QCOMPARE(save_dives("./testmerge.ssrf"), 0);
|
||||
QFile org(SUBSURFACE_SOURCE "/dives/mergedVyperOstc.xml");
|
||||
QFile org(SUBSURFACE_TEST_DATA "/dives/mergedVyperOstc.xml");
|
||||
org.open(QFile::ReadOnly);
|
||||
QFile out("./testmerge.ssrf");
|
||||
out.open(QFile::ReadOnly);
|
||||
|
|
|
@ -17,14 +17,14 @@ void TestPicture::addPicture()
|
|||
struct picture *pic;
|
||||
verbose = 1;
|
||||
|
||||
QCOMPARE(parse_file(SUBSURFACE_SOURCE "/dives/test44.xml"), 0);
|
||||
QCOMPARE(parse_file(SUBSURFACE_TEST_DATA "/dives/test44.xml"), 0);
|
||||
dive = get_dive(0);
|
||||
QVERIFY(dive != NULL);
|
||||
pic = dive->picture_list;
|
||||
// So far no picture in dive
|
||||
QVERIFY(pic == NULL);
|
||||
|
||||
dive_create_picture(dive, SUBSURFACE_SOURCE "/wreck.jpg", 0, false);
|
||||
dive_create_picture(dive, SUBSURFACE_TEST_DATA "/wreck.jpg", 0, false);
|
||||
pic = dive->picture_list;
|
||||
// Now there is a picture
|
||||
QVERIFY(pic != NULL);
|
||||
|
|
|
@ -6,14 +6,14 @@
|
|||
|
||||
void TestRenumber::setup()
|
||||
{
|
||||
QCOMPARE(parse_file(SUBSURFACE_SOURCE "/dives/test47.xml"), 0);
|
||||
QCOMPARE(parse_file(SUBSURFACE_TEST_DATA "/dives/test47.xml"), 0);
|
||||
process_dives(false, false);
|
||||
dive_table.preexisting = dive_table.nr;
|
||||
}
|
||||
|
||||
void TestRenumber::testMerge()
|
||||
{
|
||||
QCOMPARE(parse_file(SUBSURFACE_SOURCE "/dives/test47b.xml"), 0);
|
||||
QCOMPARE(parse_file(SUBSURFACE_TEST_DATA "/dives/test47b.xml"), 0);
|
||||
process_dives(true, false);
|
||||
QCOMPARE(dive_table.nr, 1);
|
||||
QCOMPARE(unsaved_changes(), 1);
|
||||
|
@ -23,7 +23,7 @@ void TestRenumber::testMerge()
|
|||
|
||||
void TestRenumber::testMergeAndAppend()
|
||||
{
|
||||
QCOMPARE(parse_file(SUBSURFACE_SOURCE "/dives/test47c.xml"), 0);
|
||||
QCOMPARE(parse_file(SUBSURFACE_TEST_DATA "/dives/test47c.xml"), 0);
|
||||
process_dives(true, false);
|
||||
QCOMPARE(dive_table.nr, 2);
|
||||
QCOMPARE(unsaved_changes(), 1);
|
||||
|
|
Loading…
Reference in a new issue