Scripting: qet.apiSignatures(), the calls a script can make

Read from the meta-object, so the list is the one the running build has:
for someone writing a script, and for an assistant that has to write one
without the source at hand.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
ispyisail
2026-10-02 09:04:06 +13:00
parent 1c1f9db3eb
commit b7ce89944e
3 changed files with 59 additions and 0 deletions
+22
View File
@@ -2,6 +2,7 @@
#include <QtTest>
#include <QFile>
#include <QJsonArray>
#include <QJsonDocument>
#include <QJsonObject>
#include <QProcess>
@@ -88,6 +89,27 @@ private slots:
QCOMPARE(r.value(QStringLiteral("current")).toInt(), -1);
}
// The list is read from the build itself: the calls a script uses
// are in it with their parameter names, each once.
void apiSignaturesListed()
{
const QJsonObject r = run(QStringLiteral(
"qet.log('PROBE ' + JSON.stringify({sigs: qet.apiSignatures()}));\n"),
QStringLiteral(QET_EXAMPLES_DIR "/perceuse.qet"));
QVERIFY2(!r.isEmpty(), "the script logged nothing");
QStringList sigs;
for (const QJsonValue &v : r.value(QStringLiteral("sigs")).toArray())
sigs << v.toString();
QVERIFY(sigs.size() > 100);
QVERIFY(sigs.contains(QStringLiteral("int currentFolio()")));
QVERIFY(sigs.contains(QStringLiteral(
"int addText(int folioIndex, QString text, double x, double y)")));
QVERIFY(sigs.contains(QStringLiteral(
"bool exportPdf(QString output, bool showTerminals)")));
QCOMPARE(sigs.filter(QStringLiteral(" exportPdf(")).size(), 1);
QVERIFY(sigs.filter(QStringLiteral("setUndoGrouped")).isEmpty());
}
void headlessUndoStaysPerCall()
{
const QJsonObject r = run(QStringLiteral(