mirror of
https://github.com/lubosz/overte.git
synced 2025-04-25 18:15:26 +02:00
Revert unfinished alternative implementation
This commit is contained in:
parent
acd07e904f
commit
5e3777999d
2 changed files with 37 additions and 167 deletions
|
@ -15,8 +15,6 @@
|
||||||
#include <QHostInfo>
|
#include <QHostInfo>
|
||||||
#include <QImageReader>
|
#include <QImageReader>
|
||||||
#include <QImageWriter>
|
#include <QImageWriter>
|
||||||
#include <QJsonDocument>
|
|
||||||
#include <QJsonArray>
|
|
||||||
|
|
||||||
#include <quazip5/quazip.h>
|
#include <quazip5/quazip.h>
|
||||||
#include <quazip5/JlCompress.h>
|
#include <quazip5/JlCompress.h>
|
||||||
|
@ -499,15 +497,8 @@ void TestCreator::createTests(const QString& clientProfile) {
|
||||||
QMessageBox::information(0, "Success", "Test images have been created");
|
QMessageBox::information(0, "Success", "Test images have been created");
|
||||||
}
|
}
|
||||||
|
|
||||||
void ExtractedText::error(const QString& fileName, const QString& error) {
|
namespace TestProfile {
|
||||||
QMessageBox::critical(0,
|
std::vector<QString> tiers = [](){
|
||||||
"Test File Parse Error",
|
|
||||||
error + " Test file: '" + fileName + "'"
|
|
||||||
);
|
|
||||||
hasError = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
const std::vector<QString> TestProfile::tiers = [](){
|
|
||||||
std::vector<QString> toReturn;
|
std::vector<QString> toReturn;
|
||||||
for (int tier = (int)platform::Profiler::Tier::LOW; tier < (int)platform::Profiler::Tier::NumTiers; ++tier) {
|
for (int tier = (int)platform::Profiler::Tier::LOW; tier < (int)platform::Profiler::Tier::NumTiers; ++tier) {
|
||||||
QString tierStringUpper = platform::Profiler::TierNames[tier];
|
QString tierStringUpper = platform::Profiler::TierNames[tier];
|
||||||
|
@ -515,8 +506,11 @@ const std::vector<QString> TestProfile::tiers = [](){
|
||||||
}
|
}
|
||||||
return toReturn;
|
return toReturn;
|
||||||
}();
|
}();
|
||||||
const std::vector<QString> TestProfile::operatingSystems = { "windows", "mac", "linux", "android" };
|
|
||||||
const std::vector<QString> TestProfile::gpus = { "amd", "nvidia", "intel" };
|
std::vector<QString> operatingSystems = { "windows", "mac", "linux", "android" };
|
||||||
|
|
||||||
|
std::vector<QString> gpus = { "amd", "nvidia", "intel" };
|
||||||
|
};
|
||||||
|
|
||||||
enum class ProfileCategory {
|
enum class ProfileCategory {
|
||||||
TIER,
|
TIER,
|
||||||
|
@ -537,18 +531,6 @@ const std::map<QString, ProfileCategory> propertyToProfileCategory = [](){
|
||||||
return toReturn;
|
return toReturn;
|
||||||
}();
|
}();
|
||||||
|
|
||||||
std::vector<TestProfile> TestProfile::getAllTestProfiles() {
|
|
||||||
std::vector<TestProfile> testProfiles;
|
|
||||||
for (int tier = (int)platform::Profiler::Tier::LOW; tier < (int)platform::Profiler::Tier::NumTiers; ++tier) {
|
|
||||||
for (const auto& os : operatingSystems) {
|
|
||||||
for (const auto& gpu : gpus) {
|
|
||||||
testProfiles.push_back(TestProfile((platform::Profiler::Tier)tier, os, gpu));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return testProfiles;
|
|
||||||
}
|
|
||||||
|
|
||||||
TestFilter::TestFilter(const QString& filterString) {
|
TestFilter::TestFilter(const QString& filterString) {
|
||||||
auto filterParts = filterString.split(".", QString::SkipEmptyParts);
|
auto filterParts = filterString.split(".", QString::SkipEmptyParts);
|
||||||
for (const auto& filterPart : filterParts) {
|
for (const auto& filterPart : filterParts) {
|
||||||
|
@ -594,13 +576,6 @@ TestFilter::TestFilter(const QString& filterString) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TestFilter::matches(const TestProfile& testProfile) const {
|
|
||||||
return isValid() &&
|
|
||||||
(allowedTiers.empty() || std::find(allowedTiers.cbegin(), allowedTiers.cend(), testProfile.tier) != allowedTiers.cend()) &&
|
|
||||||
(allowedOperatingSystems.empty() || std::find(allowedOperatingSystems.cbegin(), allowedOperatingSystems.cend(), testProfile.os) != allowedOperatingSystems.cend()) &&
|
|
||||||
(allowedGPUs.empty() || std::find(allowedGPUs.cbegin(), allowedGPUs.cend(), testProfile.gpu) != allowedGPUs.cend());
|
|
||||||
}
|
|
||||||
|
|
||||||
bool TestFilter::isValid() const {
|
bool TestFilter::isValid() const {
|
||||||
return error.isEmpty();
|
return error.isEmpty();
|
||||||
}
|
}
|
||||||
|
@ -609,12 +584,6 @@ QString TestFilter::getError() const {
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
enum class ParseTarget {
|
|
||||||
PERFORM_FUNCTION = 0,
|
|
||||||
TEST_FILTER,
|
|
||||||
NITPICK_COMMANDS
|
|
||||||
};
|
|
||||||
|
|
||||||
ExtractedText TestCreator::getTestScriptLines(QString testFileName) {
|
ExtractedText TestCreator::getTestScriptLines(QString testFileName) {
|
||||||
ExtractedText relevantTextFromTest;
|
ExtractedText relevantTextFromTest;
|
||||||
|
|
||||||
|
@ -627,20 +596,17 @@ ExtractedText TestCreator::getTestScriptLines(QString testFileName) {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QTextStream stream(&inputFile);
|
||||||
|
QString line = stream.readLine();
|
||||||
|
|
||||||
// Name of test is the string in the following line:
|
// Name of test is the string in the following line:
|
||||||
// nitpick.perform("Apply Material Entities to Avatars", Script.resolvePath("."), "secondary", undefined, function(testType) {...
|
// nitpick.perform("Apply Material Entities to Avatars", Script.resolvePath("."), "secondary", undefined, function(testType) {...
|
||||||
const QString ws("\\h*"); // One or more white-space characters
|
const QString ws("\\h*"); //white-space character
|
||||||
const QString functionPerformName(ws + "nitpick" + ws + "\\." + ws + "perform");
|
const QString functionPerformName(ws + "nitpick" + ws + "\\." + ws + "perform");
|
||||||
const QString quote("[\"\']");
|
const QString quotedString("\\\".+\\\"");
|
||||||
const QString notAQuote("[^\"\']");
|
|
||||||
const QString quotedString(quote + notAQuote + "*" + quote);
|
|
||||||
QString regexTestTitle(ws + functionPerformName + "\\(" + quotedString);
|
QString regexTestTitle(ws + functionPerformName + "\\(" + quotedString);
|
||||||
QRegularExpression lineContainingTitle = QRegularExpression(regexTestTitle);
|
QRegularExpression lineContainingTitle = QRegularExpression(regexTestTitle);
|
||||||
|
|
||||||
// Test filter, for example: undefined, [["high"]], [["linux,mac,windows", "tier.gpu"]], etc...
|
|
||||||
// This is currently the only Nitpick property that can be set to undefined
|
|
||||||
const QRegularExpression testFilter = QRegularExpression("(undefined|(\\[[\\[\"'\\w\\h\\.,\\]]*\\])*)" + ws + ",");
|
|
||||||
|
|
||||||
|
|
||||||
// Each step is either of the following forms:
|
// Each step is either of the following forms:
|
||||||
// nitpick.addStepSnapshot("Take snapshot"...
|
// nitpick.addStepSnapshot("Take snapshot"...
|
||||||
|
@ -653,66 +619,12 @@ ExtractedText TestCreator::getTestScriptLines(QString testFileName) {
|
||||||
const QString regexStep(ws + functionAddStepName + ws + "\\(" + ws + quotedString + ".*");
|
const QString regexStep(ws + functionAddStepName + ws + "\\(" + ws + quotedString + ".*");
|
||||||
const QRegularExpression lineStep = QRegularExpression(regexStep);
|
const QRegularExpression lineStep = QRegularExpression(regexStep);
|
||||||
|
|
||||||
QTextStream stream(&inputFile);
|
while (!line.isNull()) {
|
||||||
int lineNumber = 1;
|
line = stream.readLine();
|
||||||
ParseTarget parseTarget = ParseTarget::PERFORM_FUNCTION;
|
|
||||||
for (QString line = stream.readLine(); !line.isNull(); line = stream.readLine()) {
|
|
||||||
switch (parseTarget) {
|
|
||||||
case ParseTarget::PERFORM_FUNCTION:
|
|
||||||
if (lineContainingTitle.match(line).hasMatch()) {
|
if (lineContainingTitle.match(line).hasMatch()) {
|
||||||
QStringList tokens = line.split('"');
|
QStringList tokens = line.split('"');
|
||||||
relevantTextFromTest.title = tokens[1];
|
relevantTextFromTest.title = tokens[1];
|
||||||
parseTarget = ParseTarget::TEST_FILTER;
|
} else if (lineStepSnapshot.match(line).hasMatch()) {
|
||||||
} else {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case ParseTarget::TEST_FILTER:
|
|
||||||
{
|
|
||||||
auto result = testFilter.match(line);
|
|
||||||
if (result.hasMatch()) {
|
|
||||||
// Therefore, must be in the form of a list, ideally a double list [[...]]
|
|
||||||
QString filterListDefinition = result.captured(1);
|
|
||||||
if (filterListDefinition != "undefined") {
|
|
||||||
std::string filterListDefinitionStd = filterListDefinition.toStdString();
|
|
||||||
QJsonDocument filterListJSON = QJsonDocument::fromRawData(filterListDefinitionStd.c_str(), (int)filterListDefinitionStd.size());
|
|
||||||
QJsonArray filterList = filterListJSON.array();
|
|
||||||
|
|
||||||
std::vector<TestFilter> testFilters;
|
|
||||||
testFilters.reserve((size_t)filterList.size());
|
|
||||||
for (const auto& filter : filterList) {
|
|
||||||
QJsonArray filterArgs = filter.toArray();
|
|
||||||
if (filterArgs.isEmpty()) {
|
|
||||||
relevantTextFromTest.error(testFileName, "Invalid empty list of test filters at line " + QString::number(lineNumber) + ".");
|
|
||||||
return relevantTextFromTest;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto filterString = filterArgs[0].toString();
|
|
||||||
TestFilter testFilter(filterString);
|
|
||||||
if (!testFilter.isValid()) {
|
|
||||||
relevantTextFromTest.error(testFileName, testFilter.getError() + " at line " + QString::number(lineNumber) + ".");
|
|
||||||
return relevantTextFromTest;
|
|
||||||
} else {
|
|
||||||
testFilters.push_back(testFilter);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
std::vector<TestProfile> allowedVariants;
|
|
||||||
for (const auto& variant : TestProfile::getAllTestProfiles()) {
|
|
||||||
for (const auto& filter : testFilters) {
|
|
||||||
if (filter.matches(variant)) {
|
|
||||||
allowedVariants.push_back(variant);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
relevantTextFromTest.expectedImageProfileVariants = allowedVariants;
|
|
||||||
|
|
||||||
parseTarget = ParseTarget::NITPICK_COMMANDS;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case ParseTarget::NITPICK_COMMANDS:
|
|
||||||
if (lineStepSnapshot.match(line).hasMatch()) {
|
|
||||||
QStringList tokens = line.split('"');
|
QStringList tokens = line.split('"');
|
||||||
QString nameOfStep = tokens[1];
|
QString nameOfStep = tokens[1];
|
||||||
|
|
||||||
|
@ -720,6 +632,7 @@ ExtractedText TestCreator::getTestScriptLines(QString testFileName) {
|
||||||
step->text = nameOfStep;
|
step->text = nameOfStep;
|
||||||
step->takeSnapshot = true;
|
step->takeSnapshot = true;
|
||||||
relevantTextFromTest.stepList.emplace_back(step);
|
relevantTextFromTest.stepList.emplace_back(step);
|
||||||
|
|
||||||
} else if (lineStep.match(line).hasMatch()) {
|
} else if (lineStep.match(line).hasMatch()) {
|
||||||
QStringList tokens = line.split('"');
|
QStringList tokens = line.split('"');
|
||||||
QString nameOfStep = tokens[1];
|
QString nameOfStep = tokens[1];
|
||||||
|
@ -729,10 +642,6 @@ ExtractedText TestCreator::getTestScriptLines(QString testFileName) {
|
||||||
step->takeSnapshot = false;
|
step->takeSnapshot = false;
|
||||||
relevantTextFromTest.stepList.emplace_back(step);
|
relevantTextFromTest.stepList.emplace_back(step);
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
++lineNumber;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inputFile.close();
|
inputFile.close();
|
||||||
|
@ -835,7 +744,6 @@ QString joinVector(const std::vector<QString>& qStringVector, char* separator) {
|
||||||
return joined;
|
return joined;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Rename this function + related functions, testScriptLines
|
|
||||||
bool TestCreator::createMDFile(const QString& directory) {
|
bool TestCreator::createMDFile(const QString& directory) {
|
||||||
// Verify folder contains test.js file
|
// Verify folder contains test.js file
|
||||||
QString testFileName(directory + "/" + TEST_FILENAME);
|
QString testFileName(directory + "/" + TEST_FILENAME);
|
||||||
|
@ -846,9 +754,6 @@ bool TestCreator::createMDFile(const QString& directory) {
|
||||||
}
|
}
|
||||||
|
|
||||||
ExtractedText testScriptLines = getTestScriptLines(testFileName);
|
ExtractedText testScriptLines = getTestScriptLines(testFileName);
|
||||||
if (testScriptLines.hasError) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
QDir qDirectory(directory);
|
QDir qDirectory(directory);
|
||||||
|
|
||||||
|
|
|
@ -32,40 +32,9 @@ public:
|
||||||
|
|
||||||
using StepList = std::vector<Step*>;
|
using StepList = std::vector<Step*>;
|
||||||
|
|
||||||
class TestProfile {
|
|
||||||
public:
|
|
||||||
TestProfile() {}
|
|
||||||
TestProfile(platform::Profiler::Tier tier, const QString& os, const QString& gpu) :
|
|
||||||
tier(tier),
|
|
||||||
os(os),
|
|
||||||
gpu(gpu) {
|
|
||||||
}
|
|
||||||
TestProfile(const TestProfile& other) :
|
|
||||||
tier(other.tier),
|
|
||||||
os(other.os),
|
|
||||||
gpu(other.gpu) {
|
|
||||||
}
|
|
||||||
bool operator==(const TestProfile& other) const {
|
|
||||||
return tier == other.tier &&
|
|
||||||
os == other.os &&
|
|
||||||
gpu == other.gpu;
|
|
||||||
}
|
|
||||||
|
|
||||||
const static std::vector<QString> tiers;
|
|
||||||
const static std::vector<QString> operatingSystems;
|
|
||||||
const static std::vector<QString> gpus;
|
|
||||||
|
|
||||||
static std::vector<TestProfile> getAllTestProfiles();
|
|
||||||
|
|
||||||
QString tier;
|
|
||||||
QString os;
|
|
||||||
QString gpu;
|
|
||||||
};
|
|
||||||
|
|
||||||
class TestFilter {
|
class TestFilter {
|
||||||
public:
|
public:
|
||||||
TestFilter(const QString& filterString);
|
TestFilter(const QString& filterString);
|
||||||
bool matches(const TestProfile& testProfile) const;
|
|
||||||
bool isValid() const;
|
bool isValid() const;
|
||||||
QString getError() const;
|
QString getError() const;
|
||||||
|
|
||||||
|
@ -81,10 +50,6 @@ class ExtractedText {
|
||||||
public:
|
public:
|
||||||
QString title;
|
QString title;
|
||||||
StepList stepList;
|
StepList stepList;
|
||||||
std::vector<TestProfile> expectedImageProfileVariants;
|
|
||||||
|
|
||||||
bool hasError { false };
|
|
||||||
void error(const QString& fileName, const QString& error);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
enum TestRailCreateMode {
|
enum TestRailCreateMode {
|
||||||
|
|
Loading…
Reference in a new issue