From 3599577b83a3f873eb813ac217f2f84259ce7781 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Fri, 6 Jan 2023 17:41:45 +0200 Subject: [PATCH] Coping files for collection test. --- src/app/puzzle/puzzle.qbs | 13 ++ src/app/tape/tape.qbs | 13 ++ src/app/valentina/valentina.qbs | 14 ++ src/libs/vtest/abstracttest.cpp | 27 ++++ src/libs/vtest/abstracttest.h | 1 + src/libs/vtest/vtest.qbs | 3 + src/test/CollectionTest/CollectionTest.qbs | 160 ++++++++++++++++++++- 7 files changed, 230 insertions(+), 1 deletion(-) diff --git a/src/app/puzzle/puzzle.qbs b/src/app/puzzle/puzzle.qbs index c72219462..3f9f14ede 100644 --- a/src/app/puzzle/puzzle.qbs +++ b/src/app/puzzle/puzzle.qbs @@ -1,3 +1,5 @@ +import qbs.FileInfo + VApp { Depends { name: "buildconfig" } Depends { name: "ib"; condition: qbs.targetOS.contains("macos") } @@ -169,4 +171,15 @@ VApp { } cpp.includePaths: [product.sourceDirectory] + + Export { + Depends { name: "cpp" } + cpp.defines: { + var defines = []; + var extension = qbs.targetOS.contains("windows") ? ".exe" : ""; + defines.push('PUZZLE_BUILDDIR="' + exportingProduct.buildDirectory + FileInfo.pathSeparator() + + exportingProduct.targetName + extension +'"'); + return defines; + } + } } diff --git a/src/app/tape/tape.qbs b/src/app/tape/tape.qbs index 221c0636c..776a58ee5 100644 --- a/src/app/tape/tape.qbs +++ b/src/app/tape/tape.qbs @@ -1,3 +1,5 @@ +import qbs.FileInfo + VApp { Depends { name: "buildconfig" } Depends { name: "ib"; condition: qbs.targetOS.contains("macos") } @@ -91,4 +93,15 @@ VApp { } fileTags: ["cpp_pch_src"] } + + Export { + Depends { name: "cpp" } + cpp.defines: { + var defines = []; + var extension = qbs.targetOS.contains("windows") ? ".exe" : ""; + defines.push('TAPE_BUILDDIR="' + exportingProduct.buildDirectory + FileInfo.pathSeparator() + + exportingProduct.targetName + extension +'"'); + return defines; + } + } } diff --git a/src/app/valentina/valentina.qbs b/src/app/valentina/valentina.qbs index 54c94fa50..b0922234c 100644 --- a/src/app/valentina/valentina.qbs +++ b/src/app/valentina/valentina.qbs @@ -1,3 +1,5 @@ +import qbs.FileInfo + VApp { Depends { name: "buildconfig" } Depends { name: "ib"; condition: qbs.targetOS.contains("macos") } @@ -171,4 +173,16 @@ VApp { } fileTags: ["cpp_pch_src"] } + + Export { + Depends { name: "cpp" } + cpp.defines: { + var defines = []; + var extension = qbs.targetOS.contains("windows") ? ".exe" : ""; + defines.push('VALENTINA_BUILDDIR="' + exportingProduct.buildDirectory + FileInfo.pathSeparator() + + exportingProduct.targetName + extension +'"'); + defines.push('TRANSLATIONS_DIR="' + exportingProduct.buildDirectory + FileInfo.pathSeparator() + 'translations"'); + return defines; + } + } } diff --git a/src/libs/vtest/abstracttest.cpp b/src/libs/vtest/abstracttest.cpp index 5ca43c614..274f02082 100644 --- a/src/libs/vtest/abstracttest.cpp +++ b/src/libs/vtest/abstracttest.cpp @@ -328,32 +328,59 @@ void AbstractTest::CompareLinesDistance(const QVector &result, const QVe } } +//--------------------------------------------------------------------------------------------------------------------- +QString AbstractTest::PuzzlePath() const +{ +#ifdef QBS_BUILD + return QStringLiteral(PUZZLE_BUILDDIR); +#else + const QString path = QStringLiteral("/../../../app/puzzle/bin/puzzle"); +#ifdef Q_OS_WIN + return QCoreApplication::applicationDirPath() + path + QLatin1String(".exe"); +#else + return QCoreApplication::applicationDirPath() + path; +#endif +#endif +} + //--------------------------------------------------------------------------------------------------------------------- QString AbstractTest::ValentinaPath() const { +#ifdef QBS_BUILD + return QStringLiteral(VALENTINA_BUILDDIR); +#else const QString path = QStringLiteral("/../../../app/valentina/bin/valentina"); #ifdef Q_OS_WIN return QCoreApplication::applicationDirPath() + path + QLatin1String(".exe"); #else return QCoreApplication::applicationDirPath() + path; #endif +#endif } //--------------------------------------------------------------------------------------------------------------------- QString AbstractTest::TapePath() const { +#ifdef QBS_BUILD + return QStringLiteral(TAPE_BUILDDIR); +#else const QString path = QStringLiteral("/../../../app/tape/bin/tape"); #ifdef Q_OS_WIN return QCoreApplication::applicationDirPath() + path + QLatin1String(".exe"); #else return QCoreApplication::applicationDirPath() + path; #endif +#endif } //--------------------------------------------------------------------------------------------------------------------- QString AbstractTest::TranslationsPath() const { +#ifdef QBS_BUILD + return QStringLiteral(TRANSLATIONS_DIR); +#else return QCoreApplication::applicationDirPath() + QStringLiteral("/../../../app/valentina/bin/translations"); +#endif } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vtest/abstracttest.h b/src/libs/vtest/abstracttest.h index 1fd9c2fb0..9d6c6ef2f 100644 --- a/src/libs/vtest/abstracttest.h +++ b/src/libs/vtest/abstracttest.h @@ -92,6 +92,7 @@ protected: void ComparePointsDistance(const QPointF &result, const QPointF &expected, qreal testAccuracy) const; void CompareLinesDistance(const QVector &result, const QVector &expected) const; + auto PuzzlePath() const -> QString; auto ValentinaPath() const -> QString; auto TapePath() const -> QString; auto TranslationsPath() const -> QString; diff --git a/src/libs/vtest/vtest.qbs b/src/libs/vtest/vtest.qbs index 59e6dcfd5..303820b51 100644 --- a/src/libs/vtest/vtest.qbs +++ b/src/libs/vtest/vtest.qbs @@ -3,6 +3,9 @@ VLib { Depends { name: "VGeometryLib" } Depends { name: "VPatternDBLib" } Depends { name: "VLayoutLib" } + Depends { name: "Tape" } + Depends { name: "Valentina" } + Depends { name: "Puzzle" } name: "VTestLib" files: [ diff --git a/src/test/CollectionTest/CollectionTest.qbs b/src/test/CollectionTest/CollectionTest.qbs index 79b4f70f7..2cff0e31d 100644 --- a/src/test/CollectionTest/CollectionTest.qbs +++ b/src/test/CollectionTest/CollectionTest.qbs @@ -1,3 +1,6 @@ +import qbs.FileInfo +import qbs.File + VApp { Depends { name: "buildconfig" } Depends { name: "Qt"; submodules: ["testlib", "gui", "printsupport"] } @@ -6,7 +9,7 @@ VApp { name: "CollectionTest" buildconfig.appTarget: qbs.targetOS.contains("macos") ? "CollectionTest" : "collectionTest" targetName: buildconfig.appTarget - type: base.concat("autotest") + type: base.concat("autotest", "tst_files") bundle.isBundle: false install: false @@ -28,4 +31,159 @@ VApp { } fileTags: ["cpp_pch_src"] } + + Group { + name: "Tape test files" + prefix: "tst_tape" + FileInfo.pathSeparator() + files: [ + "keiko.vit", + "empty.vit", + "all_measurements_v0.3.0.vit", + "all_measurements_v0.4.0.vst", + "GOST_man_ru_v0.3.0.vst", + "all_measurements_v0.3.3.vit", + "all_measurements_v0.4.2.vst", + "GOST_man_ru_v0.4.2.vst", + "broken1.vit", + "broken2.vit", + "broken3.vit", + "broken4.vit", + "text.vit", + "text.vst" + ] + fileTags: ["tst_tape_files"] + } + + Group { + name: "Valentina test files" + prefix: "tst_valentina" + FileInfo.pathSeparator() + files: [ + "empty.val", + "issue_372.val", + "wrong_obj_type.val", + "text.val", + "issue_256.val", + "issue_256_wrong_path.val", + "issue_256_correct.vit", + "issue_256_wrong.vit", + "issue_256_correct.vst", + "wrong_formula.val", + "test_pedantic.val" + ] + fileTags: ["tst_valentina_files"] + } + + Group { + name: "Collection files" + prefix: FileInfo.joinPaths(project.sourceDirectory, "src", "app", "share", + FileInfo.pathSeparator()) + files: [ + FileInfo.joinPaths("collection", "bra.val"), + FileInfo.joinPaths("collection", "bra.vit"), + FileInfo.joinPaths("collection", "jacketM1_52-176.val"), + FileInfo.joinPaths("collection", "jacketM2_40-146.val"), + FileInfo.joinPaths("collection", "jacketM3_40-146.val"), + FileInfo.joinPaths("collection", "jacketM4_40-146.val"), + FileInfo.joinPaths("collection", "jacketM5_30-110.val"), + FileInfo.joinPaths("collection", "jacketM6_30-110.val"), + FileInfo.joinPaths("collection", "pantsM1_52-176.val"), + FileInfo.joinPaths("collection", "pantsM2_40-146.val"), + FileInfo.joinPaths("collection", "pantsM7.val"), + FileInfo.joinPaths("collection", "TShirt_test.val"), + FileInfo.joinPaths("collection", "TestDart.val"), + FileInfo.joinPaths("collection", "pattern_blusa.val"), + FileInfo.joinPaths("collection", "blusa.vit"), + FileInfo.joinPaths("collection", "PajamaTopWrap2.val"), + FileInfo.joinPaths("collection", "Susan.vit"), + FileInfo.joinPaths("collection", "Moulage_0.5_armhole_neckline.val"), + FileInfo.joinPaths("collection", "0.7_Armhole_adjustment_0.10.val"), + FileInfo.joinPaths("collection", "my_calculated_measurements_for_val.vit"), + FileInfo.joinPaths("collection", "Keiko_skirt.val"), + FileInfo.joinPaths("collection", "keiko.vit"), + FileInfo.joinPaths("collection", "medidas_eli2015.vit"), + FileInfo.joinPaths("collection", "pantalon_base_Eli.val"), + FileInfo.joinPaths("collection", "Razmernye_priznaki_dlya_zhenskogo_zhaketa.vit"), + FileInfo.joinPaths("collection", "IMK_Zhaketa_poluprilegayuschego_silueta.val"), + FileInfo.joinPaths("collection", "Lara_Jil.vit"), + FileInfo.joinPaths("collection", "modell_2.val"), + FileInfo.joinPaths("collection", "MaleShirt", "MaleShirt.val"), + FileInfo.joinPaths("collection", "MaleShirt", "MaleShirt.vit"), + FileInfo.joinPaths("collection", "Trousers", "Trousers.val"), + FileInfo.joinPaths("collection", "Trousers", "trousers.vit"), + FileInfo.joinPaths("collection", "Steampunk_trousers.val"), + FileInfo.joinPaths("collection", "Steampunk_trousers.vit"), + FileInfo.joinPaths("collection", "Basic_block_women-2016.val"), + FileInfo.joinPaths("collection", "Gent_Jacket_with_tummy.val"), + FileInfo.joinPaths("tables", "multisize", "GOST_man_ru.vst") + ] + fileTags: ["tst_collection_files"] + } + + Rule { + multiplex: true +// alwaysRun: true + inputs: ["tst_tape_files", "tst_valentina_files", "tst_collection_files"] + outputFileTags: ["tst_files"] + outputArtifacts: { + var artifactNames = inputs["tst_valentina_files"].map(function(file){ + return FileInfo.joinPaths(product.buildDirectory, "tst_valentina", file.fileName); + }); + + artifactNames = artifactNames.concat(inputs["tst_collection_files"].map(function(file){ + return FileInfo.joinPaths(product.buildDirectory, "tst_valentina_collection", file.fileName); + })); + + artifactNames = artifactNames.concat(inputs["tst_tape_files"].map(function(file){ + return FileInfo.joinPaths(product.buildDirectory, "tst_tape", file.fileName); + })); + + var artifacts = artifactNames.map(function(art){ + var a = { + filePath: art, + fileTags: ["tst_files"] + } + return a; + }); + return artifacts; + } + prepare: { + var cmd = new JavaScriptCommand(); + cmd.description = "Preparing Valentina test file"; + + var sources = inputs["tst_valentina_files"].map(function(file) { + return file.filePath; + }); + + sources = sources.concat(inputs["tst_collection_files"].map(function(file) { + return file.filePath; + })); + + sources = sources.concat(inputs["tst_tape_files"].map(function(file) { + return file.filePath; + })); + + cmd.sources = sources; + + var destination = inputs["tst_valentina_files"].map(function(file) { + return FileInfo.joinPaths(product.buildDirectory, "tst_valentina", file.fileName); + }); + + destination = destination.concat(inputs["tst_collection_files"].map(function(file) { + return FileInfo.joinPaths(product.buildDirectory, "tst_valentina_collection", file.fileName); + })); + + destination = destination.concat(inputs["tst_tape_files"].map(function(file) { + return FileInfo.joinPaths(product.buildDirectory, "tst_tape", file.fileName); + })); + + cmd.destination = destination; + + cmd.sourceCode = function() { + for (var i in sources) { + File.copy(sources[i], destination[i]); + } + }; + return [cmd]; + } + } }