qmlformat: do not generate backup files
qmlformat used to backup the original input file up to 2 copies when used with --inplace mode. Change this hardcoded number into 0 and generate no backup file. Fixes: QTBUG-107685 Change-Id: Ifca86968fa65be0fd678012fc2e41b9ed8601d21 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
This commit is contained in:
parent
61199f3309
commit
bc6c900b15
|
@ -38,6 +38,8 @@ private Q_SLOTS:
|
|||
void normalizeExample_data();
|
||||
#endif
|
||||
|
||||
void testBackupFileLimit();
|
||||
|
||||
private:
|
||||
QString readTestFile(const QString &path);
|
||||
QString runQmlformat(const QString &fileToFormat, QStringList args, bool shouldSucceed = true,
|
||||
|
@ -366,6 +368,29 @@ void TestQmlformat::normalizeExample()
|
|||
}
|
||||
#endif
|
||||
|
||||
void TestQmlformat::testBackupFileLimit()
|
||||
{
|
||||
// Create a temporary directory
|
||||
QTemporaryDir tempDir;
|
||||
|
||||
// Unformatted file to format
|
||||
const QString fileToFormat{ testFile("Annotations.qml") };
|
||||
|
||||
{
|
||||
const QString tempFile = tempDir.path() + QDir::separator() + "test_0.qml";
|
||||
const QString backupFile = tempFile + QStringLiteral("~");
|
||||
QFile::copy(fileToFormat, tempFile);
|
||||
|
||||
QProcess process;
|
||||
process.start(m_qmlformatPath, QStringList{ "--verbose", "--inplace", tempFile });
|
||||
QVERIFY(process.waitForFinished());
|
||||
QCOMPARE(process.exitStatus(), QProcess::NormalExit);
|
||||
QCOMPARE(process.exitCode(), 0);
|
||||
QVERIFY(QFileInfo::exists(tempFile));
|
||||
QVERIFY(!QFileInfo::exists(backupFile));
|
||||
};
|
||||
}
|
||||
|
||||
QString TestQmlformat::runQmlformat(const QString &fileToFormat, QStringList args,
|
||||
bool shouldSucceed, RunOption rOptions)
|
||||
{
|
||||
|
|
|
@ -123,7 +123,8 @@ bool parseFile(const QString &filename, const Options &options)
|
|||
if (options.verbose)
|
||||
qWarning().noquote() << "Writing to file" << filename;
|
||||
FileWriter fw;
|
||||
res = qmlFile.writeOut(filename, 2, lwOptions, &fw, checks);
|
||||
const unsigned numberOfBackupFiles = 0;
|
||||
res = qmlFile.writeOut(filename, numberOfBackupFiles, lwOptions, &fw, checks);
|
||||
} else {
|
||||
QFile out;
|
||||
out.open(stdout, QIODevice::WriteOnly);
|
||||
|
|
Loading…
Reference in New Issue