Commit cd1f7f8f authored by Elvis Angelaccio's avatar Elvis Angelaccio
Browse files

Add unit tests for "single-file" archives

While at it, also add missing extraction tests for ZSTD tarballs.

For lz4, lzop and lrzip we can run the tests only if their binary is
available.
parent 69453c83
Pipeline #260071 passed with stage
in 3 minutes and 35 seconds
......@@ -267,7 +267,7 @@ void ExtractTest::testExtraction_data()
<< optionsPreservePaths
<< 7;
// Only run tests if tar.lzo format is available
// Only run tests for lzop compressed files if tar.lzo format is available
if (PluginManager().supportedMimeTypes().contains(QLatin1String("application/x-tzo"))) {
archivePath = QFINDTESTDATA("data/simplearchive.tar.lzo");
QTest::newRow("extract selected entries from a lzop-compressed tarball without path")
......@@ -285,9 +285,16 @@ void ExtractTest::testExtraction_data()
<< QVector<Archive::Entry*>()
<< optionsPreservePaths
<< 7;
archivePath = QFINDTESTDATA("data/test.png.lzo");
QTest::newRow("extract the single-file test.png.lzo")
<< archivePath
<< QVector<Archive::Entry*>()
<< optionsPreservePaths
<< 1;
}
// Only run test for lrzipped tar if lrzip executable is found in path.
// Only run tests for lrzipped files if lrzip executable is found in path.
if (!QStandardPaths::findExecutable(QStringLiteral("lrzip")).isEmpty()) {
archivePath = QFINDTESTDATA("data/simplearchive.tar.lrz");
QTest::newRow("extract selected entries from a lrzip-compressed tarball without path")
......@@ -305,11 +312,47 @@ void ExtractTest::testExtraction_data()
<< QVector<Archive::Entry*>()
<< optionsPreservePaths
<< 7;
archivePath = QFINDTESTDATA("data/test.txt.lrz");
QTest::newRow("extract the single-file test.txt.lrz")
<< archivePath
<< QVector<Archive::Entry*>()
<< optionsPreservePaths
<< 1;
} else {
qDebug() << "lrzip executable not found in path. Skipping lrzip test.";
}
// Only run test for lz4-compressed tar if lz4 executable is found in path.
// Only run tests for zstd-compressed files if zstd executable is found in path.
if (!QStandardPaths::findExecutable(QStringLiteral("zstd")).isEmpty()) {
archivePath = QFINDTESTDATA("data/simplearchive.tar.zst");
QTest::newRow("extract selected entries from a zstd-compressed tarball without path")
<< archivePath
<< QVector<Archive::Entry*> {
new Archive::Entry(this, QStringLiteral("file3.txt"), QString()),
new Archive::Entry(this, QStringLiteral("dir2/file22.txt"), QString())
}
<< optionsNoPaths
<< 2;
archivePath = QFINDTESTDATA("data/simplearchive.tar.zst");
QTest::newRow("extract all entries from a zst-compressed tarball with path")
<< archivePath
<< QVector<Archive::Entry*>()
<< optionsPreservePaths
<< 7;
archivePath = QFINDTESTDATA("data/test.txt.zst");
QTest::newRow("extract the single-file test.txt.zst")
<< archivePath
<< QVector<Archive::Entry*>()
<< optionsPreservePaths
<< 1;
} else {
qDebug() << "zstd executable not found in path. Skipping zstd test.";
}
// Only run tests for lz4-compressed files if lz4 executable is found in path.
if (!QStandardPaths::findExecutable(QStringLiteral("lz4")).isEmpty()) {
archivePath = QFINDTESTDATA("data/simplearchive.tar.lz4");
QTest::newRow("extract selected entries from a lz4-compressed tarball without path")
......@@ -327,6 +370,13 @@ void ExtractTest::testExtraction_data()
<< QVector<Archive::Entry*>()
<< optionsPreservePaths
<< 7;
archivePath = QFINDTESTDATA("data/test.txt.lz4");
QTest::newRow("extract the single-file test.txt.lz4")
<< archivePath
<< QVector<Archive::Entry*>()
<< optionsPreservePaths
<< 1;
} else {
qDebug() << "lz4 executable not found in path. Skipping lz4 test.";
}
......@@ -446,6 +496,48 @@ void ExtractTest::testExtraction_data()
<< dragAndDropOptions
<< 4;
archivePath = QFINDTESTDATA("data/test.z");
QTest::newRow("extract the single-file test.z")
<< archivePath
<< QVector<Archive::Entry*>()
<< optionsPreservePaths
<< 1;
archivePath = QFINDTESTDATA("data/test.zz");
QTest::newRow("extract the single-file test.zz")
<< archivePath
<< QVector<Archive::Entry*>()
<< optionsPreservePaths
<< 1;
archivePath = QFINDTESTDATA("data/test.txt.gz");
QTest::newRow("extract the single-file test.txt.gz")
<< archivePath
<< QVector<Archive::Entry*>()
<< optionsPreservePaths
<< 1;
archivePath = QFINDTESTDATA("data/test.txt.bz2");
QTest::newRow("extract the single-file test.txt.bz2")
<< archivePath
<< QVector<Archive::Entry*>()
<< optionsPreservePaths
<< 1;
archivePath = QFINDTESTDATA("data/test.png.lzma");
QTest::newRow("extract the single-file test.png.lzma")
<< archivePath
<< QVector<Archive::Entry*>()
<< optionsPreservePaths
<< 1;
archivePath = QFINDTESTDATA("data/test.svgz");
QTest::newRow("extract the single-file test.svgz")
<< archivePath
<< QVector<Archive::Entry*>()
<< optionsPreservePaths
<< 1;
m_expectedWorkingDir = QDir::currentPath();
}
......
......@@ -127,6 +127,7 @@ void LoadTest::testProperties_data()
<< QStringLiteral("simplearchive")
<< QString();
// Only run tests for lzop compressed files if tar.lzo format is available
if (PluginManager().supportedMimeTypes().contains(QLatin1String("application/x-tzo"))) {
QTest::newRow("lzop-compressed tarball")
<< QFINDTESTDATA("data/simplearchive.tar.lzo")
......@@ -134,11 +135,18 @@ void LoadTest::testProperties_data()
<< false << false << false << false << false << 0 << Archive::Unencrypted
<< QStringLiteral("simplearchive")
<< QString();
QTest::newRow("single-file lzop compressed")
<< QFINDTESTDATA("data/test.png.lzo")
<< QStringLiteral("test.png")
<< true << false << true << false << false << 0 << Archive::Unencrypted
<< QStringLiteral("test.png")
<< QString();
} else {
qDebug() << "tar.lzo format not available. Skipping lzo test.";
}
// Only run test for lrzipped tar if lrzip executable is found in path.
// Only run tests for lrzipped files if lrzip executable is found in path.
if (!QStandardPaths::findExecutable(QStringLiteral("lrzip")).isEmpty()) {
QTest::newRow("lrzipped tarball")
<< QFINDTESTDATA("data/simplearchive.tar.lrz")
......@@ -146,11 +154,18 @@ void LoadTest::testProperties_data()
<< false << false << false << false << false << 0 << Archive::Unencrypted
<< QStringLiteral("simplearchive")
<< QString();
QTest::newRow("single-file lrzip compressed")
<< QFINDTESTDATA("data/test.txt.lrz")
<< QStringLiteral("test.txt")
<< true << false << true << false << false << 0 << Archive::Unencrypted
<< QStringLiteral("test.txt")
<< QString();
} else {
qDebug() << "lrzip executable not found in path. Skipping lrzip test.";
}
// Only run test for lz4-compressed tar if lz4 executable is found in path.
// Only run tests for lz4-compressed files if lz4 executable is found in path.
if (!QStandardPaths::findExecutable(QStringLiteral("lz4")).isEmpty()) {
QTest::newRow("lz4-compressed tarball")
<< QFINDTESTDATA("data/simplearchive.tar.lz4")
......@@ -158,6 +173,13 @@ void LoadTest::testProperties_data()
<< false << false << false << false << false << 0 << Archive::Unencrypted
<< QStringLiteral("simplearchive")
<< QString();
QTest::newRow("single-file lz4 compressed")
<< QFINDTESTDATA("data/test.txt.lz4")
<< QStringLiteral("test.txt")
<< true << false << true << false << false << 0 << Archive::Unencrypted
<< QStringLiteral("test.txt")
<< QString();
} else {
qDebug() << "lz4 executable not found in path. Skipping lz4 test.";
}
......@@ -211,7 +233,7 @@ void LoadTest::testProperties_data()
<< QStringLiteral("addonsu-remove-14.1-x86-signed")
<< QStringLiteral("signed by SignApk");
// Only run test for zstd-compressed tar if zstd executable is found in path.
// Only run tests for zstd-compressed files if zstd executable is found in path.
if (!QStandardPaths::findExecutable(QStringLiteral("zstd")).isEmpty()) {
QTest::newRow("zstd-compressed tarball")
<< QFINDTESTDATA("data/simplearchive.tar.zst")
......@@ -219,6 +241,13 @@ void LoadTest::testProperties_data()
<< false << false << false << false << false << 0 << Archive::Unencrypted
<< QStringLiteral("simplearchive")
<< QString();
QTest::newRow("single-file zstd compressed")
<< QFINDTESTDATA("data/test.txt.zst")
<< QStringLiteral("test.txt")
<< true << false << true << false << false << 0 << Archive::Unencrypted
<< QStringLiteral("test.txt")
<< QString();
} else {
qDebug() << "zstd executable not found in path. Skipping zstd test.";
}
......@@ -236,6 +265,48 @@ void LoadTest::testProperties_data()
<< false << false << false << false << false << 0 << Archive::Encrypted
<< QStringLiteral("test_encrypted")
<< QString();
QTest::newRow("single-file UNIX-compressed")
<< QFINDTESTDATA("data/test.z")
<< QStringLiteral("test")
<< true << false << true << false << false << 0 << Archive::Unencrypted
<< QStringLiteral("test")
<< QString();
QTest::newRow("single-file zlib compressed")
<< QFINDTESTDATA("data/test.zz")
<< QStringLiteral("test")
<< true << false << true << false << false << 0 << Archive::Unencrypted
<< QStringLiteral("test")
<< QString();
QTest::newRow("single-file gz compressed")
<< QFINDTESTDATA("data/test.txt.gz")
<< QStringLiteral("test.txt")
<< true << false << true << false << false << 0 << Archive::Unencrypted
<< QStringLiteral("test.txt")
<< QString();
QTest::newRow("single-file bzip compressed")
<< QFINDTESTDATA("data/test.txt.bz2")
<< QStringLiteral("test.txt")
<< true << false << true << false << false << 0 << Archive::Unencrypted
<< QStringLiteral("test.txt")
<< QString();
QTest::newRow("single-file lzma compressed")
<< QFINDTESTDATA("data/test.png.lzma")
<< QStringLiteral("test.png")
<< true << false << true << false << false << 0 << Archive::Unencrypted
<< QStringLiteral("test.png")
<< QString();
QTest::newRow("single-file compressed SVG")
<< QFINDTESTDATA("data/test.svgz")
<< QStringLiteral("test")
<< true << false << true << false << false << 0 << Archive::Unencrypted
<< QStringLiteral("test")
<< QString();
}
void LoadTest::testProperties()
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment