tst_QFile::setPermissions: add QScopeGuard to remove temporary file

Pick-to: 6.4
Change-Id: If5d5ef6220874ae8858efffd17125580b5943cc2
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
This commit is contained in:
Thiago Macieira 2022-09-06 10:27:03 -07:00
parent 4b997d1851
commit 0193b4d219

View File

@ -1426,8 +1426,9 @@ void tst_QFile::setPermissions()
#ifdef Q_OS_QNX #ifdef Q_OS_QNX
QSKIP("This test doesn't pass on QNX and no one has cared to investigate."); QSKIP("This test doesn't pass on QNX and no one has cared to investigate.");
#endif #endif
if ( QFile::exists( "createme.txt" ) ) auto remove = []() { QFile::remove("createme.txt"); };
QFile::remove( "createme.txt" ); auto guard = qScopeGuard(remove);
remove();
QVERIFY( !QFile::exists( "createme.txt" ) ); QVERIFY( !QFile::exists( "createme.txt" ) );
QFile f("createme.txt"); QFile f("createme.txt");