NixOS: flake leaves out build/; export starvation tests start warm
The flake's source skips dev.sh's build folder, which nixpkgs' CMake hook took for its own. ProjectExportFailureTests crashed on NixOS inside fontconfig: its limit held the process's first font lookup. initTestCase now opens a panel and an alert first, as the app has before any export. A new test holds the JPEG render's snapshot to a move. Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
1 parent
d0088fac89
commit
2807b77e8c
4 files changed
+51
-3
No files matched your search
@@ -2,6 +2,7 @@
|
||||
#include "DialogDesk.h"
|
||||
#include "IO/ImageExporter.h"
|
||||
#include "IO/ProjectController.h"
|
||||
#include "UI/JPEGExportSheet.h"
|
||||
#include <QApplication>
|
||||
#include <QSemaphore>
|
||||
#include <QTemporaryDir>
|
||||
@@ -14,12 +15,14 @@
|
||||
class ProjectExportFailureTests : public QObject {
|
||||
Q_OBJECT
|
||||
private slots:
|
||||
void initTestCase();
|
||||
void aRenderThatFindsNoMemoryIsARenderError();
|
||||
void aSnapshotThatFindsNoMemoryIsExplained();
|
||||
void aJPEGRenderThatFindsNoMemoryIsExplained();
|
||||
void aPanelsHandOffThatFindsNoMemoryIsExplained();
|
||||
void thePanelOpensWithoutCopyingTheSnapshot();
|
||||
void aRefusedNameCopiesNoSnapshot();
|
||||
void theJPEGRenderTakesTheSnapshotWithoutACopy();
|
||||
};
|
||||
|
||||
namespace {
|
||||
@@ -56,6 +59,20 @@ struct Desk {
|
||||
};
|
||||
}
|
||||
|
||||
// The app opened panels and alerts before any export.
|
||||
void ProjectExportFailureTests::initTestCase()
|
||||
{
|
||||
Desk desk;
|
||||
QTemporaryDir folder;
|
||||
QFile taken(folder.filePath("taken.jpg.png"));
|
||||
QVERIFY(taken.open(QIODevice::WriteOnly));
|
||||
taken.close();
|
||||
desk.alerts.replies = {folder.filePath("taken.jpg"), "OK"};
|
||||
desk.controller.exportPNG([&desk] { desk.done = true; });
|
||||
QTRY_VERIFY(desk.done);
|
||||
QCOMPARE(desk.alerts.seen.size(), 2);
|
||||
}
|
||||
|
||||
void ProjectExportFailureTests::aRenderThatFindsNoMemoryIsARenderError()
|
||||
{
|
||||
const ProjectSnapshot snapshot = manyLayers();
|
||||
@@ -164,6 +181,30 @@ void ProjectExportFailureTests::aRefusedNameCopiesNoSnapshot()
|
||||
QVERIFY(!desk.session.isProjectBusy());
|
||||
}
|
||||
|
||||
// The worker takes the snapshot; a copy would not fit.
|
||||
void ProjectExportFailureTests::theJPEGRenderTakesTheSnapshotWithoutACopy()
|
||||
{
|
||||
Desk desk;
|
||||
QThreadPool *pool = QThreadPool::globalInstance();
|
||||
pool->setMaxThreadCount(1);
|
||||
QSemaphore entered, release;
|
||||
const QFuture<void> held = QtConcurrent::run([&] {
|
||||
entered.release();
|
||||
release.acquire();
|
||||
});
|
||||
entered.acquire();
|
||||
{
|
||||
malloc_trim(0);
|
||||
const AddressSpaceLimit limit(2048ll * 1024);
|
||||
desk.controller.exportJPEG([&desk] { desk.done = true; });
|
||||
}
|
||||
release.release();
|
||||
QTRY_VERIFY(desk.window.findChild<JPEGExportSheet *>());
|
||||
QTest::keyClick(desk.window.findChild<JPEGExportSheet *>(), Qt::Key_Escape);
|
||||
QTRY_VERIFY(desk.done);
|
||||
QVERIFY(desk.alerts.seen.isEmpty() && !desk.session.isProjectBusy());
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
// Before any thread: workers share the heap the limit counts.
|
||||
|
||||
Reference in new issue
Block a user