mirror of
https://github.com/overte-org/overte.git
synced 2025-08-10 23:32:48 +02:00
Implemented creation of allTests.js
This commit is contained in:
parent
51f7a03ecc
commit
346c691f0c
5 changed files with 81 additions and 23 deletions
|
@ -31,6 +31,7 @@
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <QtCore/QTextStream>
|
#include <QtCore/QTextStream>
|
||||||
|
#include <QDirIterator>
|
||||||
|
|
||||||
Test::Test() {
|
Test::Test() {
|
||||||
snapshotFilenameFormat = QRegularExpression("hifi-snap-by-.+-on-\\d\\d\\d\\d-\\d\\d-\\d\\d_\\d\\d-\\d\\d-\\d\\d.jpg");
|
snapshotFilenameFormat = QRegularExpression("hifi-snap-by-.+-on-\\d\\d\\d\\d-\\d\\d-\\d\\d_\\d\\d-\\d\\d-\\d\\d.jpg");
|
||||||
|
@ -106,6 +107,44 @@ void Test::evaluateTests() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Creates a single script in a user-selected folder.
|
||||||
|
// This script will run all text.js scripts in every applicable sub-folder
|
||||||
|
void Test::createRecursiveScript() {
|
||||||
|
// Select folder to start recursing from
|
||||||
|
QString topLevelDirectory = QFileDialog::getExistingDirectory(nullptr, "Please select folder that will contain the top level test script", ".", QFileDialog::ShowDirsOnly);
|
||||||
|
QDirIterator it(topLevelDirectory.toStdString().c_str(), QDirIterator::Subdirectories);
|
||||||
|
|
||||||
|
QFile allTestsFilename(topLevelDirectory + "/" + "allTests.js");
|
||||||
|
if (!allTestsFilename.open(QIODevice::WriteOnly | QIODevice::Text)) {
|
||||||
|
messageBox.critical(0,
|
||||||
|
"Internal Error",
|
||||||
|
"Failed to create \"allTests.js\" in directory \"" + topLevelDirectory + "\"");
|
||||||
|
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
QTextStream textStream(&allTestsFilename);
|
||||||
|
textStream << "// This is an automatically generated file, created by auto-tester" << endl;
|
||||||
|
|
||||||
|
const QString testFilename{ "test.js" };
|
||||||
|
while (it.hasNext()) {
|
||||||
|
QString directory = it.next();
|
||||||
|
if (directory[directory.length() - 1] == '.') {
|
||||||
|
continue; // ignore '.', '..' directories
|
||||||
|
}
|
||||||
|
|
||||||
|
const QString testPathname{ directory + "/" + testFilename };
|
||||||
|
|
||||||
|
QFileInfo fileInfo(testPathname);
|
||||||
|
if (fileInfo.exists()) {
|
||||||
|
// Current folder contains a test
|
||||||
|
textStream << "Script.include(\"" << testPathname << "/" << " ? raw = true\")" << endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
allTestsFilename.close();
|
||||||
|
}
|
||||||
|
|
||||||
void Test::createTest() {
|
void Test::createTest() {
|
||||||
// Rename files sequentially, as ExpectedResult_1.jpeg, ExpectedResult_2.jpg and so on
|
// Rename files sequentially, as ExpectedResult_1.jpeg, ExpectedResult_2.jpg and so on
|
||||||
// Any existing expected result images will be deleted
|
// Any existing expected result images will be deleted
|
||||||
|
@ -130,7 +169,7 @@ void Test::createTest() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Test::createListOfAllJPEGimagesInDirectory() {
|
void Test::createListOfAllJPEGimagesInDirectory() {
|
||||||
// get list of JPEG images in folder, sorted by name
|
// Get list of JPEG images in folder, sorted by name
|
||||||
pathToImageDirectory = QFileDialog::getExistingDirectory(nullptr, "Please select folder containing the test images", ".", QFileDialog::ShowDirsOnly);
|
pathToImageDirectory = QFileDialog::getExistingDirectory(nullptr, "Please select folder containing the test images", ".", QFileDialog::ShowDirsOnly);
|
||||||
|
|
||||||
imageDirectory = QDir(pathToImageDirectory);
|
imageDirectory = QDir(pathToImageDirectory);
|
||||||
|
|
|
@ -24,6 +24,7 @@ public:
|
||||||
Test();
|
Test();
|
||||||
|
|
||||||
void evaluateTests();
|
void evaluateTests();
|
||||||
|
void createRecursiveScript();
|
||||||
void createTest();
|
void createTest();
|
||||||
|
|
||||||
void createListOfAllJPEGimagesInDirectory();
|
void createListOfAllJPEGimagesInDirectory();
|
||||||
|
|
|
@ -16,17 +16,23 @@ AutoTester::AutoTester(QWidget *parent)
|
||||||
ui.setupUi(this);
|
ui.setupUi(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AutoTester::on_closeButton_clicked()
|
|
||||||
{
|
|
||||||
exit(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
void AutoTester::on_evaluateTestsButton_clicked()
|
void AutoTester::on_evaluateTestsButton_clicked()
|
||||||
{
|
{
|
||||||
test.evaluateTests();
|
test.evaluateTests();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AutoTester::on_createRecursiveScriptButton_clicked()
|
||||||
|
{
|
||||||
|
test.createRecursiveScript();
|
||||||
|
}
|
||||||
|
|
||||||
void AutoTester::on_createTestButton_clicked()
|
void AutoTester::on_createTestButton_clicked()
|
||||||
{
|
{
|
||||||
test.createTest();
|
test.createTest();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AutoTester::on_closeButton_clicked()
|
||||||
|
{
|
||||||
|
exit(0);
|
||||||
|
}
|
|
@ -24,6 +24,7 @@ public:
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void on_evaluateTestsButton_clicked();
|
void on_evaluateTestsButton_clicked();
|
||||||
|
void on_createRecursiveScriptButton_clicked();
|
||||||
void on_createTestButton_clicked();
|
void on_createTestButton_clicked();
|
||||||
void on_closeButton_clicked();
|
void on_closeButton_clicked();
|
||||||
|
|
||||||
|
|
|
@ -6,8 +6,8 @@
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>261</width>
|
<width>277</width>
|
||||||
<height>330</height>
|
<height>351</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
|
@ -17,10 +17,10 @@
|
||||||
<widget class="QPushButton" name="closeButton">
|
<widget class="QPushButton" name="closeButton">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>80</x>
|
<x>60</x>
|
||||||
<y>210</y>
|
<y>240</y>
|
||||||
<width>100</width>
|
<width>159</width>
|
||||||
<height>23</height>
|
<height>40</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
|
@ -30,10 +30,10 @@
|
||||||
<widget class="QPushButton" name="createTestButton">
|
<widget class="QPushButton" name="createTestButton">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>80</x>
|
<x>60</x>
|
||||||
<y>160</y>
|
<y>180</y>
|
||||||
<width>100</width>
|
<width>160</width>
|
||||||
<height>23</height>
|
<height>40</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
|
@ -43,23 +43,36 @@
|
||||||
<widget class="QPushButton" name="evaluateTestsButton">
|
<widget class="QPushButton" name="evaluateTestsButton">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>80</x>
|
<x>60</x>
|
||||||
<y>20</y>
|
<y>20</y>
|
||||||
<width>100</width>
|
<width>160</width>
|
||||||
<height>23</height>
|
<height>40</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Evaulate Tests</string>
|
<string>Evaulate Tests</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
|
<widget class="QPushButton" name="createRecursiveScriptButton">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>60</x>
|
||||||
|
<y>120</y>
|
||||||
|
<width>160</width>
|
||||||
|
<height>40</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Create Recursive Script</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QMenuBar" name="menuBar">
|
<widget class="QMenuBar" name="menuBar">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>261</width>
|
<width>277</width>
|
||||||
<height>21</height>
|
<height>21</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
|
@ -75,8 +88,6 @@
|
||||||
<widget class="QStatusBar" name="statusBar"/>
|
<widget class="QStatusBar" name="statusBar"/>
|
||||||
</widget>
|
</widget>
|
||||||
<layoutdefault spacing="6" margin="11"/>
|
<layoutdefault spacing="6" margin="11"/>
|
||||||
<resources>
|
<resources/>
|
||||||
<include location="../src/AutoTester.qrc"/>
|
|
||||||
</resources>
|
|
||||||
<connections/>
|
<connections/>
|
||||||
</ui>
|
</ui>
|
||||||
|
|
Loading…
Reference in a new issue