NOISSUE add instance-local library storage
Any libraries stored in $instanceroot/libraries/ will override the libraries from MultiMC's global folders, as long as they are marked 'local' in the json patch.
This commit is contained in:
@ -31,6 +31,7 @@ slots:
|
||||
{
|
||||
cache.reset(new HttpMetaCache());
|
||||
cache->addBase("libraries", QDir("libraries").absolutePath());
|
||||
dataDir = QDir("data").absolutePath();
|
||||
}
|
||||
void test_legacy()
|
||||
{
|
||||
@ -39,7 +40,7 @@ slots:
|
||||
QCOMPARE(test.isNative(), false);
|
||||
|
||||
QStringList jar, native, native32, native64;
|
||||
test.getApplicableFiles(currentSystem, jar, native, native32, native64);
|
||||
test.getApplicableFiles(currentSystem, jar, native, native32, native64, QString());
|
||||
QCOMPARE(jar, getStorage("test/package/testname/testversion/testname-testversion.jar"));
|
||||
QCOMPARE(native, {});
|
||||
QCOMPARE(native32, {});
|
||||
@ -50,7 +51,7 @@ slots:
|
||||
QStringList failedFiles;
|
||||
Library test("test.package:testname:testversion");
|
||||
test.setRepositoryURL("file://foo/bar");
|
||||
auto downloads = test.getDownloads(currentSystem, cache.get(), failedFiles);
|
||||
auto downloads = test.getDownloads(currentSystem, cache.get(), failedFiles, QString());
|
||||
QCOMPARE(downloads.size(), 1);
|
||||
QCOMPARE(failedFiles, {});
|
||||
NetActionPtr dl = downloads[0];
|
||||
@ -62,10 +63,27 @@ slots:
|
||||
QCOMPARE(test.isNative(), false);
|
||||
QStringList failedFiles;
|
||||
test.setHint("local");
|
||||
auto downloads = test.getDownloads(currentSystem, cache.get(), failedFiles);
|
||||
auto downloads = test.getDownloads(currentSystem, cache.get(), failedFiles, QString());
|
||||
QCOMPARE(downloads.size(), 0);
|
||||
QCOMPARE(failedFiles, getStorage("test/package/testname/testversion/testname-testversion.jar"));
|
||||
}
|
||||
void test_legacy_url_local_override()
|
||||
{
|
||||
Library test("com.paulscode:codecwav:20101023");
|
||||
QCOMPARE(test.isNative(), false);
|
||||
QStringList failedFiles;
|
||||
test.setHint("local");
|
||||
auto downloads = test.getDownloads(currentSystem, cache.get(), failedFiles, QString("data"));
|
||||
QCOMPARE(downloads.size(), 0);
|
||||
QCOMPARE(failedFiles.size(), 0);
|
||||
|
||||
QStringList jar, native, native32, native64;
|
||||
test.getApplicableFiles(currentSystem, jar, native, native32, native64, QString("data"));
|
||||
QCOMPARE(jar, {QFileInfo("data/codecwav-20101023.jar").absoluteFilePath()});
|
||||
QCOMPARE(native, {});
|
||||
QCOMPARE(native32, {});
|
||||
QCOMPARE(native64, {});
|
||||
}
|
||||
void test_legacy_native()
|
||||
{
|
||||
Library test("test.package:testname:testversion");
|
||||
@ -74,13 +92,13 @@ slots:
|
||||
test.setRepositoryURL("file://foo/bar");
|
||||
{
|
||||
QStringList jar, native, native32, native64;
|
||||
test.getApplicableFiles(Os_Linux, jar, native, native32, native64);
|
||||
test.getApplicableFiles(Os_Linux, jar, native, native32, native64, QString());
|
||||
QCOMPARE(jar, {});
|
||||
QCOMPARE(native, getStorage("test/package/testname/testversion/testname-testversion-linux.jar"));
|
||||
QCOMPARE(native32, {});
|
||||
QCOMPARE(native64, {});
|
||||
QStringList failedFiles;
|
||||
auto dls = test.getDownloads(Os_Linux, cache.get(), failedFiles);
|
||||
auto dls = test.getDownloads(Os_Linux, cache.get(), failedFiles, QString());
|
||||
QCOMPARE(dls.size(), 1);
|
||||
QCOMPARE(failedFiles, {});
|
||||
auto dl = dls[0];
|
||||
@ -97,13 +115,13 @@ slots:
|
||||
test.setRepositoryURL("file://foo/bar");
|
||||
{
|
||||
QStringList jar, native, native32, native64;
|
||||
test.getApplicableFiles(Os_Linux, jar, native, native32, native64);
|
||||
test.getApplicableFiles(Os_Linux, jar, native, native32, native64, QString());
|
||||
QCOMPARE(jar, {});
|
||||
QCOMPARE(native, {});
|
||||
QCOMPARE(native32, getStorage("test/package/testname/testversion/testname-testversion-linux-32.jar"));
|
||||
QCOMPARE(native64, getStorage("test/package/testname/testversion/testname-testversion-linux-64.jar"));
|
||||
QStringList failedFiles;
|
||||
auto dls = test.getDownloads(Os_Linux, cache.get(), failedFiles);
|
||||
auto dls = test.getDownloads(Os_Linux, cache.get(), failedFiles, QString());
|
||||
QCOMPARE(dls.size(), 2);
|
||||
QCOMPARE(failedFiles, {});
|
||||
QCOMPARE(dls[0]->m_url, QUrl("file://foo/bar/test/package/testname/testversion/testname-testversion-linux-32.jar"));
|
||||
@ -111,13 +129,13 @@ slots:
|
||||
}
|
||||
{
|
||||
QStringList jar, native, native32, native64;
|
||||
test.getApplicableFiles(Os_Windows, jar, native, native32, native64);
|
||||
test.getApplicableFiles(Os_Windows, jar, native, native32, native64, QString());
|
||||
QCOMPARE(jar, {});
|
||||
QCOMPARE(native, {});
|
||||
QCOMPARE(native32, getStorage("test/package/testname/testversion/testname-testversion-windows-32.jar"));
|
||||
QCOMPARE(native64, getStorage("test/package/testname/testversion/testname-testversion-windows-64.jar"));
|
||||
QStringList failedFiles;
|
||||
auto dls = test.getDownloads(Os_Windows, cache.get(), failedFiles);
|
||||
auto dls = test.getDownloads(Os_Windows, cache.get(), failedFiles, QString());
|
||||
QCOMPARE(dls.size(), 2);
|
||||
QCOMPARE(failedFiles, {});
|
||||
QCOMPARE(dls[0]->m_url, QUrl("file://foo/bar/test/package/testname/testversion/testname-testversion-windows-32.jar"));
|
||||
@ -125,45 +143,103 @@ slots:
|
||||
}
|
||||
{
|
||||
QStringList jar, native, native32, native64;
|
||||
test.getApplicableFiles(Os_OSX, jar, native, native32, native64);
|
||||
test.getApplicableFiles(Os_OSX, jar, native, native32, native64, QString());
|
||||
QCOMPARE(jar, {});
|
||||
QCOMPARE(native, {});
|
||||
QCOMPARE(native32, getStorage("test/package/testname/testversion/testname-testversion-osx-32.jar"));
|
||||
QCOMPARE(native64, getStorage("test/package/testname/testversion/testname-testversion-osx-64.jar"));
|
||||
QStringList failedFiles;
|
||||
auto dls = test.getDownloads(Os_OSX, cache.get(), failedFiles);
|
||||
auto dls = test.getDownloads(Os_OSX, cache.get(), failedFiles, QString());
|
||||
QCOMPARE(dls.size(), 2);
|
||||
QCOMPARE(failedFiles, {});
|
||||
QCOMPARE(dls[0]->m_url, QUrl("file://foo/bar/test/package/testname/testversion/testname-testversion-osx-32.jar"));
|
||||
QCOMPARE(dls[1]->m_url, QUrl("file://foo/bar/test/package/testname/testversion/testname-testversion-osx-64.jar"));
|
||||
}
|
||||
}
|
||||
void test_legacy_native_arch_local_override()
|
||||
{
|
||||
Library test("test.package:testname:testversion");
|
||||
test.m_nativeClassifiers[OpSys::Os_Linux]="linux-${arch}";
|
||||
test.setHint("local");
|
||||
QCOMPARE(test.isNative(), true);
|
||||
test.setRepositoryURL("file://foo/bar");
|
||||
{
|
||||
QStringList jar, native, native32, native64;
|
||||
test.getApplicableFiles(Os_Linux, jar, native, native32, native64, QString("data"));
|
||||
QCOMPARE(jar, {});
|
||||
QCOMPARE(native, {});
|
||||
QCOMPARE(native32, {QFileInfo("data/testname-testversion-linux-32.jar").absoluteFilePath()});
|
||||
QCOMPARE(native64, getStorage("test/package/testname/testversion/testname-testversion-linux-64.jar"));
|
||||
QStringList failedFiles;
|
||||
auto dls = test.getDownloads(Os_Linux, cache.get(), failedFiles, QString("data"));
|
||||
QCOMPARE(dls.size(), 0);
|
||||
QCOMPARE(failedFiles, {getStorage("test/package/testname/testversion/testname-testversion-linux-64.jar")});
|
||||
}
|
||||
}
|
||||
void test_onenine()
|
||||
{
|
||||
auto test = readMojangJson("data/lib-simple.json");
|
||||
QStringList jar, native, native32, native64;
|
||||
test->getApplicableFiles(Os_OSX, jar, native, native32, native64);
|
||||
QCOMPARE(jar, getStorage("com/paulscode/codecwav/20101023/codecwav-20101023.jar"));
|
||||
QCOMPARE(native, {});
|
||||
QCOMPARE(native32, {});
|
||||
QCOMPARE(native64, {});
|
||||
QStringList failedFiles;
|
||||
auto dls = test->getDownloads(Os_Linux, cache.get(), failedFiles);
|
||||
QCOMPARE(dls.size(), 1);
|
||||
QCOMPARE(failedFiles, {});
|
||||
QCOMPARE(dls[0]->m_url, QUrl("https://libraries.minecraft.net/com/paulscode/codecwav/20101023/codecwav-20101023.jar"));
|
||||
{
|
||||
QStringList jar, native, native32, native64;
|
||||
test->getApplicableFiles(Os_OSX, jar, native, native32, native64, QString());
|
||||
QCOMPARE(jar, getStorage("com/paulscode/codecwav/20101023/codecwav-20101023.jar"));
|
||||
QCOMPARE(native, {});
|
||||
QCOMPARE(native32, {});
|
||||
QCOMPARE(native64, {});
|
||||
}
|
||||
{
|
||||
QStringList failedFiles;
|
||||
auto dls = test->getDownloads(Os_Linux, cache.get(), failedFiles, QString());
|
||||
QCOMPARE(dls.size(), 1);
|
||||
QCOMPARE(failedFiles, {});
|
||||
QCOMPARE(dls[0]->m_url, QUrl("https://libraries.minecraft.net/com/paulscode/codecwav/20101023/codecwav-20101023.jar"));
|
||||
}
|
||||
test->setHint("local");
|
||||
{
|
||||
QStringList jar, native, native32, native64;
|
||||
test->getApplicableFiles(Os_OSX, jar, native, native32, native64, QString("data"));
|
||||
QCOMPARE(jar, {QFileInfo("data/codecwav-20101023.jar").absoluteFilePath()});
|
||||
QCOMPARE(native, {});
|
||||
QCOMPARE(native32, {});
|
||||
QCOMPARE(native64, {});
|
||||
}
|
||||
{
|
||||
QStringList failedFiles;
|
||||
auto dls = test->getDownloads(Os_Linux, cache.get(), failedFiles, QString("data"));
|
||||
QCOMPARE(dls.size(), 0);
|
||||
QCOMPARE(failedFiles, {});
|
||||
}
|
||||
}
|
||||
void test_onenine_local_override()
|
||||
{
|
||||
auto test = readMojangJson("data/lib-simple.json");
|
||||
test->setHint("local");
|
||||
{
|
||||
QStringList jar, native, native32, native64;
|
||||
test->getApplicableFiles(Os_OSX, jar, native, native32, native64, QString("data"));
|
||||
QCOMPARE(jar, {QFileInfo("data/codecwav-20101023.jar").absoluteFilePath()});
|
||||
QCOMPARE(native, {});
|
||||
QCOMPARE(native32, {});
|
||||
QCOMPARE(native64, {});
|
||||
}
|
||||
{
|
||||
QStringList failedFiles;
|
||||
auto dls = test->getDownloads(Os_Linux, cache.get(), failedFiles, QString("data"));
|
||||
QCOMPARE(dls.size(), 0);
|
||||
QCOMPARE(failedFiles, {});
|
||||
}
|
||||
}
|
||||
void test_onenine_native()
|
||||
{
|
||||
auto test = readMojangJson("data/lib-native.json");
|
||||
QStringList jar, native, native32, native64;
|
||||
test->getApplicableFiles(Os_OSX, jar, native, native32, native64);
|
||||
test->getApplicableFiles(Os_OSX, jar, native, native32, native64, QString());
|
||||
QCOMPARE(jar, getStorage("org/lwjgl/lwjgl/lwjgl-platform/2.9.4-nightly-20150209/lwjgl-platform-2.9.4-nightly-20150209.jar"));
|
||||
QCOMPARE(native, getStorage("org/lwjgl/lwjgl/lwjgl-platform/2.9.4-nightly-20150209/lwjgl-platform-2.9.4-nightly-20150209-natives-osx.jar"));
|
||||
QCOMPARE(native32, {});
|
||||
QCOMPARE(native64, {});
|
||||
QStringList failedFiles;
|
||||
auto dls = test->getDownloads(Os_OSX, cache.get(), failedFiles);
|
||||
auto dls = test->getDownloads(Os_OSX, cache.get(), failedFiles, QString());
|
||||
QCOMPARE(dls.size(), 2);
|
||||
QCOMPARE(failedFiles, {});
|
||||
QCOMPARE(dls[0]->m_url, QUrl("https://libraries.minecraft.net/org/lwjgl/lwjgl/lwjgl-platform/2.9.4-nightly-20150209/lwjgl-platform-2.9.4-nightly-20150209.jar"));
|
||||
@ -173,13 +249,13 @@ slots:
|
||||
{
|
||||
auto test = readMojangJson("data/lib-native-arch.json");
|
||||
QStringList jar, native, native32, native64;
|
||||
test->getApplicableFiles(Os_Windows, jar, native, native32, native64);
|
||||
test->getApplicableFiles(Os_Windows, jar, native, native32, native64, QString());
|
||||
QCOMPARE(jar, {});
|
||||
QCOMPARE(native, {});
|
||||
QCOMPARE(native32, getStorage("tv/twitch/twitch-platform/5.16/twitch-platform-5.16-natives-windows-32.jar"));
|
||||
QCOMPARE(native64, getStorage("tv/twitch/twitch-platform/5.16/twitch-platform-5.16-natives-windows-64.jar"));
|
||||
QStringList failedFiles;
|
||||
auto dls = test->getDownloads(Os_Windows, cache.get(), failedFiles);
|
||||
auto dls = test->getDownloads(Os_Windows, cache.get(), failedFiles, QString());
|
||||
QCOMPARE(dls.size(), 2);
|
||||
QCOMPARE(failedFiles, {});
|
||||
QCOMPARE(dls[0]->m_url, QUrl("https://libraries.minecraft.net/tv/twitch/twitch-platform/5.16/twitch-platform-5.16-natives-windows-32.jar"));
|
||||
@ -187,7 +263,7 @@ slots:
|
||||
}
|
||||
private:
|
||||
std::unique_ptr<HttpMetaCache> cache;
|
||||
QString workDir;
|
||||
QString dataDir;
|
||||
};
|
||||
|
||||
QTEST_GUILESS_MAIN(LibraryTest)
|
||||
|
Reference in New Issue
Block a user