MCPcopy Create free account
hub / github.com/FreesmTeam/FreesmLauncher / test_link

Method test_link

tests/FileSystem_test.cpp:358–401  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

356 void test_getDesktop() { QCOMPARE(FS::getDesktopDir(), QStandardPaths::writableLocation(QStandardPaths::DesktopLocation)); }
357
358 void test_link()
359 {
360 QString folder = QFINDTESTDATA("testdata/FileSystem/test_folder");
361 auto f = [&folder]() {
362 QTemporaryDir tempDir;
363 tempDir.setAutoRemove(true);
364 qDebug() << "From:" << folder << "To:" << tempDir.path();
365
366 QDir target_dir(FS::PathCombine(tempDir.path(), "test_folder"));
367 qDebug() << tempDir.path();
368 qDebug() << target_dir.path();
369
370 LinkTask lnk_tsk(folder, target_dir.path());
371 lnk_tsk.linkRecursively(false);
372 QObject::connect(&lnk_tsk, &Task::finished,
373 [&] { QVERIFY2(lnk_tsk.wasSuccessful(), "Task finished but was not successful when it should have been."); });
374 lnk_tsk.start();
375
376 QVERIFY2(QTest::qWaitFor([&]() { return lnk_tsk.isFinished(); }, 100000), "Task didn't finish as it should.");
377
378 for (auto entry : target_dir.entryList()) {
379 qDebug() << entry;
380 QFileInfo entry_lnk_info(target_dir.filePath(entry));
381 if (!entry_lnk_info.isDir())
382 QVERIFY(!entry_lnk_info.isSymLink());
383 }
384
385 QFileInfo lnk_info(target_dir.path());
386 QVERIFY(lnk_info.exists());
387 QVERIFY(lnk_info.isSymLink());
388
389 QVERIFY(target_dir.entryList().contains("pack.mcmeta"));
390 QVERIFY(target_dir.entryList().contains("assets"));
391 };
392
393 // first try variant without trailing /
394 QVERIFY(!folder.endsWith('/'));
395 f();
396
397 // then variant with trailing /
398 folder.append('/');
399 QVERIFY(folder.endsWith('/'));
400 f();
401 }
402
403 void test_hard_link()
404 {

Callers

nothing calls this directly

Calls 11

PathCombineFunction · 0.85
linkRecursivelyMethod · 0.80
wasSuccessfulMethod · 0.80
isFinishedMethod · 0.80
filePathMethod · 0.80
existsMethod · 0.80
appendMethod · 0.80
pathMethod · 0.45
startMethod · 0.45
isSymLinkMethod · 0.45
containsMethod · 0.45

Tested by

no test coverage detected